[Libav-user] Using 0 for AVPacket.duration
Alex Agranovsky
alex at sighthound.com
Wed Aug 7 20:06:45 EEST 2024
Running into a problem when using AVPacket.duration value of 0, and
writing to MP4/MOV with av_write_frame(). Overall, the approach works.
However there's a problem with the last packet written to the file,
which ends up with AV_PKT_FLAG_DISCARD added by the muxer. This doesn't
seem to happen when writing to other formats (verified .mkv/.ts work as
expected), so it seems like MOV mux having some trouble with figuring
out last packet's duration, and prefers to just chuck it.
The only two workarounds I've found is
1. write an actual discardable/empty packet at the end of the file
(adding AV_PKT_FLAG_DISCARD and proper pts to it).
2. buffer at least one packet, and flush it on close
The first solution seems dirty (and we did run into some consumers that
have problems with input having D-flagged packets), the second solution
would require more code restructuring than desirable. Is there no other
way to indicate last packet's duration to MOV mux when writing the
trailer/closing the file?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20240807/246080fa/attachment.htm>
More information about the Libav-user
mailing list