From: Burkhard P. <pl...@ip...> - 2012-11-21 10:19:18
|
Hi, Am 20.11.2012 18:11, schrieb Joseph Artsimovich: > It doesn't look like it's going to work. When I set the following: > > codec->avctx->time_base.num = 1; > codec->avctx->time_base.den = lqt_video_time_scale(file, track); > codec->avctx->ticks_per_frame = lqt_frame_duration(file, track, NULL); > > avcodec_open2() then fails with "MPEG1/2 does not support 600/1 fps". It > doesn't even look at ticks_per_frame. Ahh ok, now I remember it wasn't that easy. And of course framerate isn't only used for rate control, it's also be written to the MPEG sequence header :) ticks_per_frame is a field in some MPEG4 header so I'd guess it's used mainly by CODEC_ID_MPEG4. > It also lools like even if you remove that check, 1/600 ratio would get > written to MPEG bitstream. No it won't, because MPEG-1/2 has no way to way to store arbitrary framerates. > In fact that's the whole point of > ticks_per_frame, to be able to put 1/50 to MPEG bitstream for 50i > content. So, this behaviour is by design. > > The solution I am thinking about is doing what my previous patch did, > but only for XDCAM. This will make it impossible to generate > variable-duration XDCAM frames, but I don't expect anyone to ever need that. I would make it depend on the codec_id because it also applied to IMX. For CODEC_ID_MPEG2VIDEO (and probably others) set time_base to the framerate like you did earlier, and increase PTS by one for each frame. Just found this snippet in my other libavcodec frontend: static void set_framerate(ffmpeg_video_stream_t * st) { if(st->format.framerate_mode == GAVL_FRAMERATE_CONSTANT) { st->stream->codec->time_base.den = st->format.timescale; st->stream->codec->time_base.num = st->format.frame_duration; } else { st->stream->codec->time_base.den = st->format.timescale; st->stream->codec->time_base.num = 1; } } Burkhard |