Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webcam with FFmpeg on Mac: Selected framerate (29.970030) is not supported by the device

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.

like image 648
Galaxy Avatar asked Jul 21 '16 08:07

Galaxy


1 Answers

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:

  • FFmpeg avfoundation documentation
  • FFmpeg Wiki: Capture Desktop / Webcam with avfoundation
like image 56
llogan Avatar answered Jan 01 '23 21:01

llogan