[Libav-user] Transcoding example produces incorrect FPS
Tuukka Pasanen
pasanen.tuukka at gmail.com
Sat Jul 11 20:22:34 EEST 2020
Hello,
Thanks this seems to solve problem. I didn't find this discussion with
search engine. Nice explanation why number 512.
Ok I was assuming this was problem as I faced this with writing audio
but when I debugged with ffmpeg.c this problem and it didn't set
packet.duration and neither did transcoding.c but I assume it's been set
just before writing to disk.
I update transcoding.c and try to make PR with it so nobody else
shouldn't back head against wall with this.
Sincerely,
Tuukka
Vassilis kirjoitti 11.7.2020 klo 19.25:
> Hello,
>
> 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 *
> format_context->streams[stream_index]->avg_frame_rate.den;
>
> /* mux encoded frame */
> ret = av_interleaved_write_frame(format_context, output_packet);
>
> Hope this helps!
> Vas
>
> On Fri, Jul 10, 2020 at 9:19 PM Tuukka Pasanen
> <pasanen.tuukka at gmail.com <mailto:pasanen.tuukka at gmail.com>> wrote:
>
> 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 <mailto: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
> <mailto:libav-user-request at ffmpeg.org> with subject "unsubscribe".
>
>
> _______________________________________________
> 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/716aa92c/attachment.html>
More information about the Libav-user
mailing list