diff mbox

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

Message ID 024f530c-0067-8248-9cc1-68ecf0129603@netbox.cz
State New
Headers show

Commit Message

Tomas Hulata Aug. 1, 2019, 8:38 p.m. UTC
Hi, sorry for delay, I wasn't tracking response, let's try it as 
attachment.

Thx

On 6/6/19 11:58 PM, Michael Niedermayer wrote:
> On Wed, Jun 05, 2019 at 11:13:20PM +0200, Tomas Hulata wrote:
>> 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;
> git doesnt like this patch
> Applying: mpegts pat and sdt period should respect user options
> error: corrupt patch at line 10
>
> [...]
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox

Patch

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..d2706b7d80 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