On Sat, 7 Jun 2014, Luca Barbato wrote:

Certain hardware demuxer have specific restrictions for PCR periodicity.
---
doc/muxers.texi         | 5 +++++
libavformat/mpegtsenc.c | 5 ++++-
2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 2d1f53c..325bb9d 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -403,6 +403,11 @@ Set the service_id (default 0x0001) also known as program 
in DVB.
Set the first PID for PMT (default 0x1000, max 0x1f00).
@item -mpegts_start_pid @var{number}
Set the first PID for data packets (default 0x0100, max 0x0f00).
+@item -muxrate @var{number}
+Set a constant muxrate (default VBR).
+@item -pcr_period @var{numer}
+Override the default PCR retransmission time (default 20ms), ignored
+if variable muxrate is selected.
@end table

The recognized metadata settings in mpegts muxer are @code{service_provider}
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 8efd93e..2ace43f 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -79,6 +79,7 @@ typedef struct MpegTSWrite {

    int reemit_pat_pmt; // backward compatibility

+    int pcr_period;
#define MPEGTS_FLAG_REEMIT_PAT_PMT  0x01
#define MPEGTS_FLAG_AAC_LATM        0x02
    int flags;
@@ -113,6 +114,8 @@ static const AVOption options[] = {
    // backward compatibility
    { "resend_headers", "Reemit PAT/PMT before writing the next packet",
      offsetof(MpegTSWrite, reemit_pat_pmt), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 
INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
+    { "pcr_period", "PCR retransmission time",
+      offsetof(MpegTSWrite, pcr_period), AV_OPT_TYPE_INT, { .i64 = 
PCR_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
    { NULL },
};

@@ -594,7 +597,7 @@ static int mpegts_write_header(AVFormatContext *s)
    }

    if (ts->mux_rate > 1) {
-        service->pcr_packet_period = (ts->mux_rate * PCR_RETRANS_TIME) /
+        service->pcr_packet_period = (ts->mux_rate * ts->pcr_period) /
            (TS_PACKET_SIZE * 8 * 1000);
        ts->sdt_packet_period      = (ts->mux_rate * SDT_RETRANS_TIME) /
            (TS_PACKET_SIZE * 8 * 1000);
--
1.8.5.2 (Apple Git-48)

Looks good overall, but please split the documentation of the existing flag to a separate patch.

// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to