summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-16 01:54:56 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-18 22:19:19 +0200
commita9c1545a33c5268fe35605da5163df722b5eedc1 (patch)
treeff514fab97fa65bd143a8162220e5a7b88a8e6da
parente3e4f1752c1c635454b0b17d91048d72606e40fa (diff)
avformat/mpegtsenc: support storing PAT/PMT per frame
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--doc/muxers.texi2
-rw-r--r--libavformat/mpegtsenc.c9
2 files changed, 11 insertions, 0 deletions
diff --git a/doc/muxers.texi b/doc/muxers.texi
index d75d7dee6b..4c2826c0f0 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -810,6 +810,8 @@ Option mpegts_flags may take a set of such flags:
Reemit PAT/PMT before writing the next packet.
@item latm
Use LATM packetization for AAC.
+@item pat_pmt_at_frames
+Reemit PAT and PMT at each video frame.
@end table
@subsection Example
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index c74389a70e..6d589f33c0 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -98,6 +98,7 @@ typedef struct MpegTSWrite {
int pcr_period;
#define MPEGTS_FLAG_REEMIT_PAT_PMT 0x01
#define MPEGTS_FLAG_AAC_LATM 0x02
+#define MPEGTS_FLAG_PAT_PMT_AT_FRAMES 0x04
int flags;
int copyts;
int tables_version;
@@ -971,6 +972,11 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
int force_pat = st->codec->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key;
+ av_assert0(ts_st->payload != buf || st->codec->codec_type != AVMEDIA_TYPE_VIDEO);
+ if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ force_pat = 1;
+ }
+
is_start = 1;
while (payload_size > 0) {
retransmit_si_info(s, force_pat);
@@ -1505,6 +1511,9 @@ static const AVOption options[] = {
{ "latm", "Use LATM packetization for AAC",
0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_AAC_LATM }, 0, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
+ { "pat_pmt_at_frames", "Reemit PAT and PMT at each video frame",
+ 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_PAT_PMT_AT_FRAMES}, 0, INT_MAX,
+ AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
// backward compatibility
{ "resend_headers", "Reemit PAT/PMT before writing the next packet",
offsetof(MpegTSWrite, reemit_pat_pmt), AV_OPT_TYPE_INT,