Question or issue on macOS:
How do I access my default video camera on my mac? I know on Linux it is /dev/video0 but my Mac does not have that. I’m trying to capture my webcam into ffmpeg
ffmpeg -i /dev/video0
But it won’t work because /dev/video0 doesn’t exist.
How to solve this problem?
Solution no. 1:
You can achieve this by using VLC’s qtcapture (QTKit
) or avcapture (AVFoundation
) module introduced with VLC 2.0.0 and
Try this via command line – Note: you still need to hit play i guess:
QTCapture (using the QTKit
Framework)
VLC.app/Contents/MacOS/VLC -vvv qtcapture://
AVCapture (using the AVFoundation
Framework)
VLC.app/Contents/MacOS/VLC -vvv avcapture://
You can also control this via GUI: VLC -> File -> Open Capture Device…
Also if you really want to have control over things you can look into AVFoundation
Framework or the older QTKit
Framework to access your camera (video/audio devices) programmatically.
If you have trouble finding devices try to debug it by finding out if the device is actually recognized by VLC. The verbose output through the terminal or the Log View in GUI mode should show you which devices are actually available:
Solution no. 2:
here’s the documentation for macOS:
OS X users can use the avfoundation and qtkit input devices for
grabbing integrated iSight cameras as well as cameras connected via
USB or FireWire:
AVFoundation is available on Mac OS X 10.7 (Lion) and later. Since
then, Apple recommends AVFoundation for stream grabbing on OS X and
iOS devices. QTKit is available on Mac OS X 10.4 (Tiger) and later.
QTKit has been marked deprecated since OS X 10.7 (Lion) and may not be
available on future releases.
here’s an example using linux, but it can be done with the above link just as easily with macos.
Solution no. 3:
My impression is that it’s hard to impossible. Apple locked it down quite a bit. There’s the nearly unfindable iSightCapture which apparently only works when run directly on the command line (used to work fine in scripts before 10.4, but Apple blocked that), and I think it only takes images, not video.
Considering someone wrote that, it should be possible to access it programmatically, but iSightCapture is not open source, and I haven’t been able to find how to do it myself. Though I admit I gave up pretty quickly once I realized it’s clearly not a standard webcam.