How to avoid unsupported frame rate errors?

I am on a Macbook and I am trying to read video from a camera using the ffmpeg library. Camera - 10 meter USB underwater camera. I use the C API through a D binding called ffmpeg-d. However, trying to open the input, I get the following:

[avfoundation @ 0x7fe0d2800000] Selected framerate (29.970030) is not supported by the device [avfoundation @ 0x7fe0d2800000] Supported modes: [avfoundation @ 0x7fe0d2800000] 160x120@ [30.000030 30.000030]fps [avfoundation @ 0x7fe0d2800000] 176x144@ [30.000030 30.000030]fps [avfoundation @ 0x7fe0d2800000] 320x240@ [30.000030 30.000030]fps [avfoundation @ 0x7fe0d2800000] 352x288@ [30.000030 30.000030]fps [avfoundation @ 0x7fe0d2800000] 640x480@ [30.000030 30.000030]fps 

So how can I avoid this problem? Will it set the frame rate manually? And if so, how can I do this?

Here is a very short program to replicate my problem.

 import std.stdio; import ffmpeg.libavdevice.avdevice; import ffmpeg.libavcodec.avcodec; import ffmpeg.libavformat.avformat; import ffmpeg.libavfilter.avfilter; import ffmpeg.libavutil.avutil; import ffmpeg.libavutil.mem; import ffmpeg.libavutil.pixfmt; import ffmpeg.libswscale.swscale; import std.string; void main() { av_register_all(); avdevice_register_all(); string cameraSource = "USB"; AVCodecContext* cameraCodecContext = null; AVFormatContext* cameraFormatContext = avformat_alloc_context(); AVCodec* cameraCodec = null; AVInputFormat* cameraFormat = av_find_input_format("avfoundation"); AVFrame* rawFrame = null, convertedFrame = null; if (avformat_open_input(&cameraFormatContext, cameraSource.toStringz, cameraFormat, null) != 0) return; } 
+5
source share
1 answer

I have no experience whatsoever with D or the libraries used, but I can point you in the right direction. You must pass AVDictionary** options to avformat_open_input

parameters Dictionary filled with parameters AVFormatContext and demuxer-private. Upon return, this parameter will be destroyed and replaced with a dict containing parameters that were not found. May be NULL.

It seems to me that the structure of this dictionary corresponds to the command line parameters to a large extent from 1 to 1, so you should add the value "30" under the key "frame rate".

+5
source

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


All Articles