[Libav-user] Transcoding example produces incorrect FPS

Vassilis bpantazhs at gmail.com
Sat Jul 11 19:25:42 EEST 2020


This seems like an issue I faced with my own attempt at transcoding video
and a fix was suggested by a member of this mailing list (thanks James).
You need to set the AVPacket duration field, otherwise this issue is
present. This would mean adding something in the lines of the
following line of code before your av_interleaved_write_frame is called:

// for example, if 25 FPS, and time_base is 12800, then packet.duration =
12800 / 25 = 512
output_packet.duration =
format_context->streams[stream_index]->time_base.den /
format_context->streams[stream_index]->time_base.num /
format_context->streams[stream_index]->avg_frame_rate.num *

 /* mux encoded frame */
    ret = av_interleaved_write_frame(format_context, output_packet);

Hope this helps!

On Fri, Jul 10, 2020 at 9:19 PM Tuukka Pasanen <pasanen.tuukka at gmail.com>

> Hello,
> I noticed that example code 'doc/examples/transcoding.c' produces in
> correct FPS if it's used with MP4 container. Encoded video type doesn't
> seem to be the case as I tested H264 and MPEG4 and both were nearly
> identical.
> With sort videos it's not much just something like 21,85 fps with 24 fps
> video but longer ones can be something like 0.05 fps.
> That it what ffprobe dump and when you play them they are really lagging
> as they go so slow. Packets seems to be correct and it neither wise not
> broken.
> I don't know if this just feature or is this as bug. With ffmpeg same
> source file produces correct file with correct fps.
> Sincerely,
> Tuukka
> _______________________________________________
> 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/20200711/298c2096/attachment.html>

More information about the Libav-user mailing list