]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/avienc.c
Merge commit '4fd7e63c87226584e60200b82630a6057c0a6663'
[ffmpeg] / libavformat / avienc.c
index 35f4d02d3184a19cfc9beea7f01507445ebc27ed..944c1548a9d91ae6a657ea990d317657dd652a1a 100644 (file)
@@ -67,6 +67,8 @@ typedef struct  {
     int entry;
     int max_size;
 
+    int64_t last_dts;
+
     AVIIndex indexes;
 } AVIStream;
 
@@ -614,6 +616,9 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
     if ((ret = write_skip_frames(s, stream_index, pkt->dts)) < 0)
         return ret;
 
+    if (pkt->dts != AV_NOPTS_VALUE)
+        avist->last_dts = pkt->dts + pkt->duration;
+
     avist->packet_count++;
 
     // Make sure to put an OpenDML chunk when the file size exceeds the limits
@@ -677,6 +682,11 @@ static int avi_write_trailer(AVFormatContext *s)
     int i, j, n, nb_frames;
     int64_t file_size;
 
+    for (i = 0; i < s->nb_streams; i++) {
+        AVIStream *avist = s->streams[i]->priv_data;
+        write_skip_frames(s, i, avist->last_dts);
+    }
+
     if (pb->seekable) {
         if (avi->riff_id == 1) {
             ff_end_tag(pb, avi->movi_list);