[Libav-user] How to handle video muxing to file when real frame rate varies from the specified frame rate

Nuno Santos nuno.santos at imaginando.pt
Thu Sep 9 13:34:39 EEST 2021


Hi,

I’m still finding the solution to this problem.

I have tried to summarise the problem the best way I could in a stack overflow question, with code snippets:

https://stackoverflow.com/questions/69109263/how-to-compensate-frame-rate-underrun-while-muxing-video-to-mp4-container-with-l <https://stackoverflow.com/questions/69109263/how-to-compensate-frame-rate-underrun-while-muxing-video-to-mp4-container-with-l>

Lib-av is definitively a complex topic with a lot of background knowledge and history that we can’t simply catch up in a snap. 

Thanks for your help and comprehension

Best regards,

Nuno

> On 5 Sep 2021, at 19:55, Nuno Santos <nuno.santos at imaginando.pt> wrote:
> 
> Alex,
> 
> Thanks for your reply. 
> 
> I’m still puzzled how to do this.
> 
> I’ve just tried to do this in the get_video_frame of muxing.c example
> 
> ost->frame->pkt_dts = av_rescale_q(timestamp, AVRational{1, 1000}, ost->st->time_base);
> ost->frame->pts = ost->frame->pkt_dts;
> 
> But the program crashes even more quickly:
> 
> [mp4 @ 0x7fc9a6242600] pts (817920) < dts (841472) in stream 0
> 
> 
> There is another place in the muxing.c example that uses a rescale function, av_packet_rescale_ts actually, on the write_frame function. But this function is used for both video and audio frames writing. Since the problem with frame producing is only for video, I would say that the rescale must be on the video side only, so it kind makes sense doing this adjustment on the get_video_frame function.
> 
> Any tips? 
> 
> Thanks!
> 
> Regards,
> 
> Nuno
> 
>> On 2 Sep 2021, at 22:06, Alexandr Kasyan <a.kasyan at ntechlab.com> wrote:
>> 
>> Nuno, 
>> 
>> I was too wordy. Assign dts, make dts = pts, they come together in the case.
>> Is it getting better or do you still need a better way to calculate pts?
>> 
>> Regards, Alex
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/libav-user
>> 
>> To unsubscribe, visit link above, or email
>> libav-user-request at ffmpeg.org with subject "unsubscribe".
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20210909/8e4c9aa8/attachment.htm>


More information about the Libav-user mailing list