[FFmpeg-cvslog] avformat/mpegtsenc: Add sdt_period, similar to pat_period
Michael Niedermayer
git at videolan.org
Sat Jul 18 23:34:02 CEST 2015
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sat Jul 18 23:25:07 2015 +0200| [b5e716ae1322eb018c95988617a0f216e6bc2b30] | committer: Michael Niedermayer
avformat/mpegtsenc: Add sdt_period, similar to pat_period
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b5e716ae1322eb018c95988617a0f216e6bc2b30
---
doc/muxers.texi | 2 ++
libavformat/mpegtsenc.c | 16 +++++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/doc/muxers.texi b/doc/muxers.texi
index f6574eb..8e3eb4b 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -761,6 +761,8 @@ Override the default PCR retransmission time (default 20ms), ignored
if variable muxrate is selected.
@item pat_period @var{number}
Maximal time in seconds between PAT/PMT tables.
+ at item sdt_period @var{number}
+Maximal time in seconds between SDT tables.
@item -pes_payload_size @var{number}
Set minimum PES packet payload in bytes.
@item -mpegts_flags @var{flags}
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index cec77a5..45bab1c 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -103,7 +103,9 @@ typedef struct MpegTSWrite {
int copyts;
int tables_version;
float pat_period;
+ float sdt_period;
int64_t last_pat_ts;
+ int64_t last_sdt_ts;
int omit_video_pes_length;
} MpegTSWrite;
@@ -787,10 +789,14 @@ static int mpegts_write_header(AVFormatContext *s)
}
ts->last_pat_ts = AV_NOPTS_VALUE;
+ 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->sdt_period < INT_MAX/2) {
+ ts->sdt_packet_period = INT_MAX;
+ }
// output a PCR as soon as possible
service->pcr_packet_count = service->pcr_packet_period;
@@ -847,8 +853,13 @@ static void retransmit_si_info(AVFormatContext *s, int force_pat, int64_t dts)
MpegTSWrite *ts = s->priv_data;
int i;
- if (++ts->sdt_packet_count == ts->sdt_packet_period) {
+ if (++ts->sdt_packet_count == ts->sdt_packet_period ||
+ (dts != AV_NOPTS_VALUE && ts->last_sdt_ts == AV_NOPTS_VALUE) ||
+ (dts != AV_NOPTS_VALUE && dts - ts->last_sdt_ts >= ts->sdt_period*90000.0)
+ ) {
ts->sdt_packet_count = 0;
+ if (dts != AV_NOPTS_VALUE)
+ ts->last_sdt_ts = FFMAX(dts, ts->last_sdt_ts);
mpegts_write_sdt(s);
}
if (++ts->pat_packet_count == ts->pat_packet_period ||
@@ -1546,6 +1557,9 @@ static const AVOption options[] = {
{ "pat_period", "PAT/PMT retransmission time limit in seconds",
offsetof(MpegTSWrite, pat_period), AV_OPT_TYPE_FLOAT,
{ .dbl = INT_MAX }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+ { "sdt_period", "SDT retransmission time limit in seconds",
+ offsetof(MpegTSWrite, sdt_period), AV_OPT_TYPE_FLOAT,
+ { .dbl = INT_MAX }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ NULL },
};
More information about the ffmpeg-cvslog
mailing list