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

Submitted by Tomas Hulata on June 5, 2019, 9:13 p.m.

Details

Message ID 222fb2aa-bbab-8d28-14f0-9570ebc62b5b@netbox.cz
State New
Headers show

Commit Message

Tomas Hulata June 5, 2019, 9:13 p.m.
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(-)


      // output a PCR as soon as possible

Comments

Michael Niedermayer June 6, 2019, 9:58 p.m.
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

[...]

Patch hide | download patch | download mbox

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;
      }