]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mpegtsenc: add padding to m2ts streams
authorMarton Balint <cus@passwd.hu>
Sun, 10 Nov 2019 22:34:17 +0000 (23:34 +0100)
committerMarton Balint <cus@passwd.hu>
Tue, 3 Dec 2019 10:00:11 +0000 (11:00 +0100)
6144 byte alignment is needed.

Signed-off-by: Marton Balint <cus@passwd.hu>
libavformat/mpegtsenc.c

index 98e91ebf893e2e7ac80fd21727f38c8c4fde2304..e8dd8b7d5685fc9706248c293b649d803c63e102 100644 (file)
@@ -1774,6 +1774,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
 
 static void mpegts_write_flush(AVFormatContext *s)
 {
+    MpegTSWrite *ts = s->priv_data;
     int i;
 
     /* flush current packets */
@@ -1788,6 +1789,12 @@ static void mpegts_write_flush(AVFormatContext *s)
             ts_st->opus_queued_samples = 0;
         }
     }
+
+    if (ts->m2ts_mode) {
+        int packets = (avio_tell(s->pb) / (TS_PACKET_SIZE + 4)) % 32;
+        while (packets++ < 32)
+            mpegts_insert_null_packet(s);
+    }
 }
 
 static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)