[FFmpeg-cvslog] avformat/mpegtsenc: add padding to m2ts streams

Marton Balint git at videolan.org
Tue Dec 3 12:10:11 EET 2019


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sun Nov 10 23:34:17 2019 +0100| [1e0ea369456b93dcf6d2ecc2bce45e1b33c2baca] | committer: Marton Balint

avformat/mpegtsenc: add padding to m2ts streams

6144 byte alignment is needed.

Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1e0ea369456b93dcf6d2ecc2bce45e1b33c2baca
---

 libavformat/mpegtsenc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 98e91ebf89..e8dd8b7d56 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -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)



More information about the ffmpeg-cvslog mailing list