本文介绍了来自Mac的网络摄像头使用FFmpeg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



首先我使用检查支持的设备ffmpeg -f avfoundation -list_devices true - i



输出:

  [AVFoundation输入设备@ 0x7fdf1bd03000] AVFoundation视频设备:
[AVFoundation输入设备@ 0x7fdf1bd03000] [0] USB 2.0 Camera#2
[AVFoundation输入设备@ 0x7fdf1bd03000] [1] FaceTime高清摄像机
[AVFoundation输入设备@ 0x7fdf1bd03000] [2]捕获屏幕0
[AVFoundation输入设备@ 0x7fdf1bd03000] [3]捕获屏幕1
[AVFoundation输入设备@ 0x7fdf1bd03000] AVFoundation音频设备:
[AVFoundation input device @ 0x7fdf1bd03000] [0]内置麦克风

设备[0]是我想使用的网络摄像头。






然后我尝试使用捕获网络摄像头ffmpeg -f avfoundation -i0out.mpg



输出:

  [AV基础@ 0x7fe7f3810600]设备不支持选择的帧率(29.970030)
[avfoundation @ 0x7fe7f3810600]支持的模式:
[avfoundation @ 0x7fe7f3810600] 320x240 @ [120.101366 120.101366] fps
[avfoundation @ 0x7fe7f3810600] 640x480 @ [120.101366 120.101366] fps
[avfoundation @ 0x7fe7f3810600] 800x600 @ [60.000240 60.000240] fps
[avfoundation @ 0x7fe7f3810600] 1024x768 @ [30.000030 30.000030] fps
[avfoundation @ 0x7fe7f3810600] 1280x720 @ [60.000240 60.000240] fps
[avfoundation @ 0x7fe7f3810600] 1280x1024 @ [30.000030 30.000030] fps
[avfoundation @ 0x7fe7f3810600] 1920x1080 @ [30.000030 30.000030] fps
[avfoundation @ 0x7fe7f3810600] 320x240 @ [30.000030 30.000030] fps
[avfoundation @ 0x7fe7f3810600] 640x480 @ [30.000030 30.000030] fps
[avfoundation @ 0x7fe7f3810600] 800x600 @ [20.000000 20.000000] fps
[avfoundation @ 0x7fe7f3810600] 1024x768 @ [6.000002 6.000002] fps
0:输入/输出错误






之后,我尝试使用从Mac发送此网络摄像头ffmpeg -f avfoundation -framerate 30 -i0-f mpeg1video -b 200k -r 30 -vf scale = 1920:1080 http://127.0.0.1:8082/



输出:

  [avfoundation @ 0x7f8515012800]发生错误:传递的activeVideoMinFrameDuration不受设备支持。使用-activeFormat.videoSupportedFrameRateRanges来发现有效的range.0:输入/输出错误






我无法捕获或传送此网络摄像头。然而,当我使用Facetime相机而不是这个网络摄像头时,一切都OK。我一直在寻找这个问题几天,但仍然无法解决它。有没有人在Mac上有网络摄像头和FFmpeg的经验?

解决方案

'需要帧速率



您可以尝试




ffmpeg -f avfoundation -framerate 30 -i0目标pal-vcd ./test.mpg


I want to stream my webcam from Mac using FFmpeg.

First I checked the supported devices using ffmpeg -f avfoundation -list_devices true -i ""

Output:

[AVFoundation input device @ 0x7fdf1bd03000] AVFoundation video devices:
[AVFoundation input device @ 0x7fdf1bd03000] [0] USB 2.0 Camera #2
[AVFoundation input device @ 0x7fdf1bd03000] [1] FaceTime HD Camera
[AVFoundation input device @ 0x7fdf1bd03000] [2] Capture screen 0
[AVFoundation input device @ 0x7fdf1bd03000] [3] Capture screen 1
[AVFoundation input device @ 0x7fdf1bd03000] AVFoundation audio devices:
[AVFoundation input device @ 0x7fdf1bd03000] [0] Built-in Microphone

The device[0] is the webcam I want to use.


Then I tried to capture the webcam using ffmpeg -f avfoundation -i "0" out.mpg

Output:

[avfoundation @ 0x7fe7f3810600] Selected framerate (29.970030) is not supported by the device
[avfoundation @ 0x7fe7f3810600] Supported modes:
[avfoundation @ 0x7fe7f3810600]   320x240@[120.101366 120.101366]fps
[avfoundation @ 0x7fe7f3810600]   640x480@[120.101366 120.101366]fps
[avfoundation @ 0x7fe7f3810600]   800x600@[60.000240 60.000240]fps
[avfoundation @ 0x7fe7f3810600]   1024x768@[30.000030 30.000030]fps
[avfoundation @ 0x7fe7f3810600]   1280x720@[60.000240 60.000240]fps
[avfoundation @ 0x7fe7f3810600]   1280x1024@[30.000030 30.000030]fps
[avfoundation @ 0x7fe7f3810600]   1920x1080@[30.000030 30.000030]fps
[avfoundation @ 0x7fe7f3810600]   320x240@[30.000030 30.000030]fps
[avfoundation @ 0x7fe7f3810600]   640x480@[30.000030 30.000030]fps
[avfoundation @ 0x7fe7f3810600]   800x600@[20.000000 20.000000]fps
[avfoundation @ 0x7fe7f3810600]   1024x768@[6.000002 6.000002]fps
0: Input/output error


After that, I tried stream this webcam from my Mac using ffmpeg -f avfoundation -framerate 30 -i "0" -f mpeg1video -b 200k -r 30 -vf scale=1920:1080 http://127.0.0.1:8082/

Output:

[avfoundation @ 0x7f8515012800] An error occurred: The activeVideoMinFrameDuration passed is not supported by the device.  Use -activeFormat.videoSupportedFrameRateRanges to discover valid ranges.0: Input/output error


I cannot capture or stream this webcam. However when I used the Facetime camera instead of this webcam, everything was OK. I've been searching for this problem for a few days, but still cannot fix it. Does anyone have experience with webcam and FFmpeg on Mac?

解决方案

'-framerate' is needed

you can have a try

ffmpeg -f avfoundation -framerate 30 -i "0" -target pal-vcd ./test.mpg

这篇关于来自Mac的网络摄像头使用FFmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 22:12