Stream webcams from Mac using FFmpeg

I want to transfer my webcam from a Mac using FFmpeg.

First, I tested 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 

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 to transfer 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 transfer this webcam. However, when I used the Facetime camera instead of this webcam, everything was fine. I have been looking for this problem for several days, but still cannot fix it. Does anyone have any experience with webcam and FFmpeg on Mac?

+4
source share
2 answers

'- frame frequency

you may have an attempt

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

+3
source

I had the same problem with streaming a Logitech C920 webcam, where the streaming of the built-in FaceTime camera is beautiful.

I found that decreasing the frame rate stopped the error message you reported. Here is the command I used to operate my webcam (where the same command with a frame rate of 30 does not work).

 ffmpeg -f avfoundation -framerate 10 -pixel_format yuyv422 -i "0" out.avi 

From the video formats supported by your webcam, it looks like the following command may work. Although, since I do not have the same webcam, this may not solve your problem.

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

Hope this helps you find a solution.

0
source

Source: https://habr.com/ru/post/1260939/


All Articles