There was a very strange problem on Mac when I tried to access the webcam using FFmpeg. For example:
ffmpeg -f avfoundation -i "1" -framerate 60 -vcodec libx264 -preset veryfast -f flv rtmp://localhost:1935/hls/test
No matter what framerate I set, the error was always the same.
[avfoundation @ 0x7ff831800000] Selected framerate (29.970030) is not supported by the device
[avfoundation @ 0x7ff831800000] Supported modes:
[avfoundation @ 0x7ff831800000] 320x240@[120.101366 120.101366]fps
[avfoundation @ 0x7ff831800000] 640x480@[120.101366 120.101366]fps
[avfoundation @ 0x7ff831800000] 800x600@[60.000240 60.000240]fps
[avfoundation @ 0x7ff831800000] 1024x768@[30.000030 30.000030]fps
[avfoundation @ 0x7ff831800000] 1280x720@[60.000240 60.000240]fps
[avfoundation @ 0x7ff831800000] 1280x1024@[30.000030 30.000030]fps
[avfoundation @ 0x7ff831800000] 1920x1080@[30.000030 30.000030]fps
[avfoundation @ 0x7ff831800000] 320x240@[30.000030 30.000030]fps
[avfoundation @ 0x7ff831800000] 640x480@[30.000030 30.000030]fps
[avfoundation @ 0x7ff831800000] 800x600@[20.000000 20.000000]fps
[avfoundation @ 0x7ff831800000] 1024x768@[6.000002 6.000002]fps
1: Input/output error
I've searched for this problem for many days but still can't find any solution. I'm very confused now.
I hope someone using Mac could try the similar command to access the webcam in order to see if this is a common problem.
You're setting -framerate
as an output option instead of an input option. Option location matters, so move it before the -i
and it will apply to the input instead:
ffmpeg -f avfoundation -framerate 60 -i default output.mp4
You also need to use a -framerate
that is supported by your device, so arbitrary values may not be accepted. Refer to the output of ffmpeg -f avfoundation -i <your device name>
.
Also see:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With