This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment 开发者_开发问答to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this questionHow 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.
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:
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.
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.
精彩评论