<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-text-flowed" style="font-family: -moz-fixed;
font-size: 12px;" lang="x-unicode">
<br>
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.
<br>
<br>
The only two workarounds I've found is
<br>
<br>
1. write an actual discardable/empty packet at the end of the file
(adding AV_PKT_FLAG_DISCARD and proper pts to it).
<br>
2. buffer at least one packet, and flush it on close
<br>
<br>
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?
<br>
<br>
</div>
</body>
</html>