[FFmpeg-devel] movenc track_duration

Alfred E. Heggestad alfred.heggestad at gmail.com
Wed Jul 3 12:00:59 EEST 2019


Hi,

here is my attempt to fix this bug:

   https://trac.ffmpeg.org/ticket/7966




I am wondering if track_duration should include
the last duration or not.


I tried to include duration in the calculation
of track_duration here:


diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 46d314ff17..6cd209266d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5612,7 +5612,7 @@ static int mov_write_single_packet(AVFormatContext 
*s, AVPacket *pkt)
                  // sample in this track. This avoids relying on AVPacket
                  // duration, but only helps for this particular track, not
                  // for the other ones that are flushed at the same time.
-                trk->track_duration = pkt->dts - trk->start_dts;
+                trk->track_duration = pkt->dts - trk->start_dts + 
pkt->duration;
                  if (pkt->pts != AV_NOPTS_VALUE)
                      trk->end_pts = pkt->pts;
                  else


... but this adds a warning in the testprogram:
(same warning as the ticket)


./libavformat/tests/movenc
[mp4 @ 0x7f8ae0801200] track 1: codec frame size is not set
write_data len 36, time nopts, type header atom ftyp
write_data len 2397, time nopts, type header atom -
[mp4 @ 0x7f8ae0801200] Application provided duration: -512 / timestamp: 
15360 is out of range for mov/mp4 format
[mp4 @ 0x7f8ae0801200] pts has no value
write_data len 908, time 1033333, type sync atom moof
write_data len 110, time nopts, type trailer atom -
45218facb761a83f686e2363d4f971f4 3451 non-empty-moov
[mp4 @ 0x7f8ae0801200] track 1: codec frame size is not set
write_data len 36, time nopts, type header atom ftyp
write_data len 2729, time nopts, type header atom -
[mp4 @ 0x7f8ae0801200] Application provided duration: -512 / timestamp: 
14848 is out of range for mov/mp4 format
[mp4 @ 0x7f8ae0801200] pts has no value
write_data len 1028, time 1000000, type sync atom moof
write_data len 110, time nopts, type trailer atom -
cf7b45d08c99438d0d55dd2ec28f0fe5 3903 non-empty-moov-elst
[mp4 @ 0x7f8ae0801200] track 1: codec frame size is not set
write_data len 36, time nopts, type header atom ftyp
write_data len 2637, time nopts, type header atom -
[mp4 @ 0x7f8ae0801200] Application provided duration: -512 / timestamp: 
15360 is out of range for mov/mp4 format
[mp4 @ 0x7f8ae0801200] pts has no value
write_data len 1028, time 1033333, type sync atom moof
write_data len 110, time nopts, type trailer atom -
fea7eec4e4d6f0f72a38fe6ea49fac9a 3811 non-empty-moov-no-elst


so the bug can be easily provoked with this change.


in my humble opinion the check is too strict.




/alfred


More information about the ffmpeg-devel mailing list