ffmpeg -f avfoundation -list_devices true -i ''
複製代碼
AVFoundation video devices:
[0] FaceTime HD Camera
[1] Capture screen 0
[2] Capture screen 1
AVFoundation audio devices:
[0] Built-in Microphone
複製代碼
ffmpeg -h demuxer=avfoundation
複製代碼
AVFoundation indev AVOptions:
-list_devices <boolean> .D........ list available devices (default false) -pixel_format <pix_fmt> .D........ set pixel format (default yuv420p) -framerate <video_rate> .D........ set frame rate (default "ntsc") -video_size <image_size> .D........ set video size 複製代碼
# 使用0號視頻設備
ffmpeg -f avfoundation -video_size 1280x720 -i 0 out.yuv
複製代碼
Selected framerate (29.970030) is not supported by the device 複製代碼
ffmpeg -f avfoundation -video_size 1280x720 -framerate 30 -i 0 out.yuv
複製代碼
而後你會看到如下提示信息。markdown
Selected pixel format (yuv420p) is not supported by the input device.
Supported pixel formats:
uyvy422
yuyv422
nv12
0rgb
bgr0
Overriding selected pixel format to use uyvy422 instead.
複製代碼
與此同時,也成功開始採集攝像頭的視頻數據了。ide
Input #0, avfoundation, from '0':
Stream #0:0: Video: rawvideo, uyvy422, 1280x720
Output #0, rawvideo, to 'out.yuv':
Stream #0:0: Video: rawvideo, uyvy422, 1280x720, 30 fps
複製代碼
ffplay -video_size 1280x720 -pixel_format uyvy422 -framerate 30 out.yuv
複製代碼