[FFmpeg-devel] [PATCH] mpegts pat and sdt period should respect user options

Tomas Hulata tomas.hulata at netbox.cz
Thu Jun 6 00:13:20 EEST 2019


When mux_rate (CBR) is defined, pat/sdt period setting is now respected. 
In case of VBR, leave it as it was.

---
  libavformat/mpegtsenc.c | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..5ad1f813e0 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -999,10 +999,18 @@ static int mpegts_init(AVFormatContext *s)
      ts->last_sdt_ts = AV_NOPTS_VALUE;
      // The user specified a period, use only it
      if (ts->pat_period < INT_MAX/2) {
-        ts->pat_packet_period = INT_MAX;
+        if (ts->mux_rate > 1)
+            ts->pat_packet_period = (int64_t)ts->mux_rate * 
ts->pat_period /
+                                    (TS_PACKET_SIZE * 8);
+        else
+            ts->pat_packet_period = INT_MAX;
      }
      if (ts->sdt_period < INT_MAX/2) {
-        ts->sdt_packet_period = INT_MAX;
+        if (ts->mux_rate > 1)
+            ts->sdt_packet_period = (int64_t)ts->mux_rate * 
ts->sdt_period /
+                                    (TS_PACKET_SIZE * 8);
+        else
+            ts->sdt_packet_period = INT_MAX;
      }

      // output a PCR as soon as possible
-- 
2.19.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4185 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190605/d35e18c1/attachment.bin>


More information about the ffmpeg-devel mailing list