Performance drop on M1 Mac
IDDD-Dennis opened this issue ยท 16 comments
- Operating system: M1 mac
- Python version: Python 3.8
- pyvirtualcam version: Latest
- Virtual camera (OBS, v4l2loopback, UnityCapture): OBS
- Virtual camera version: Latest
Describe the bug
Noticeable performance drop when using pyvirtualcam on M1 mac versus Intel mac. Output stream is laggy and has low FPS. Didn't change any of the source code so not sure where I am going wrong.
Are you using an arm64 Python together with building pyvirtualcam from source? If so, then any performance drop is unexpected.
If you're using an Intel (x86-64) Python together with the wheel from PyPI then it may be less surprising since that wouldn't be native.
Can you comment on how you observed the performance drop exactly?
Yes, using arm64 Python together with building from source. Followed these steps to build:
git clone https://github.com/letmaik/pyvirtualcam --recursive
cd pyvirtualcam
pip install
From the beginning when I use virtual camera in any video app (skype, zoom, etc) the output is very low FPS and laggy.
Seems to be the same issue discussed here: #94
EDIT: Would be good to confirm the exact apps you tested with. The referenced discussion says the issue only appears on Chromium/Electron-based apps, so not Zoom.
Also, please check if you see the same issue using OBS directly without pyvirtualcam.
Works on Zoom and Webex (desktop app)
Doesn't work on Teams, Meet, Skype, and Slack (both desktop and Chrome web apps)
Tried with Meet on Safari and it worked.
No issue using OBS directly without pyvirtualcam in all cases.
I have same issue on M1. on intel, no issue
native_macos_obs/virtual_output.h
I have found this problem on line 162-164 of this file.
I tried to change these lines. small changes are detected.
This runloop part is not exist on obs-plugin source code.
[letmaik] what's your idea about this?
@avinashsureka Can you clarify what you mean by "on Intel"? Do you mean on an M1 mac but running an Intel Python?
@avinashsureka Can you clarify what you mean by "on Intel"? Do you mean on an M1 mac but running an Intel Python?
it runs well on intel mac, but same issue like as #94 on M1 mac
I run example python code and send webcam frames to obs virtual cam by using your pyvirtualcam.
I have checked on skype app. very low framrate is detected,
@IDDD-Dennis @avinashsureka Could you let me know your macOS versions for both Intel and M1? I don't have an M1 myself, so it's going to be hard to debug this, but at least gathering enough info would be helpful.
@letmaik
M1 Mac macOS Big Sur 11.6
Intel Mac macOS Monterey 12.5
Updated M1 Mac to macOS Monterey 12.6 and still getting issues
@letmaik How are you? Couldn't you resolve yet?
I have a question.
I have compared your virtual_output.h with plugin-main.mm of obs-studio project.
Why do you use [NSRunLoop run]? objs doesn't use it.
is there any problem by this?
Best regards.
@letmaik I found the reason.
You used timestamp as mach_absolute_time()
It was working on intel mac because 1000 ticks = 1 microseconds.
But it was changed on m1.
https://eclecticlight.co/2020/11/27/inside-m1-macs-time-and-logs/
Please read this topic.
I hope it will be help to resolve this issue for you.
@avinashsureka Great that you found the issue! Might be worth checking the source code of OBS to see how they determine time for the frames.
For reference, this is the code that details some of the expectations on the timestamp, which indeed has to be nanoseconds:
https://github.com/obsproject/obs-studio/blob/1f72dad245907b6c85a069f8813ac96ca5f891c6/plugins/mac-virtualcam/src/dal-plugin/CMSampleBufferUtils.mm#L10
Wow, fantastic find there @avinashsureka ๐ ๐ ๐