-diff -urN a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
---- a/libavformat/mpegtsenc.c 2017-04-12 19:55:55.000000000 -0600
-+++ b/libavformat/mpegtsenc.c 2017-04-16 16:40:18.488361991 -0600
+diff -ur a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
+--- a/libavformat/mpegtsenc.c 2017-12-10 14:35:10.000000000 -0700
++++ b/libavformat/mpegtsenc.c 2017-12-18 10:54:14.260167666 -0700
service->provider_name = av_strdup(provider_name);
service->name = av_strdup(name);
if (!service->provider_name || !service->name)
service->provider_name = av_strdup(provider_name);
service->name = av_strdup(name);
if (!service->provider_name || !service->name)
tp_extra_header = AV_RB32(&tp_extra_header);
avio_write(s->pb, (unsigned char *) &tp_extra_header,
sizeof(tp_extra_header));
tp_extra_header = AV_RB32(&tp_extra_header);
avio_write(s->pb, (unsigned char *) &tp_extra_header,
sizeof(tp_extra_header));
MpegTSService *service;
AVStream *st, *pcr_st = NULL;
AVDictionaryEntry *title, *provider;
MpegTSService *service;
AVStream *st, *pcr_st = NULL;
AVDictionaryEntry *title, *provider;
// round up to a whole number of TS packets
ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14;
// round up to a whole number of TS packets
ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14;
ts_st->discontinuity = ts->flags & MPEGTS_FLAG_DISCONT;
/* update PCR pid by using the first video stream */
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
ts_st->discontinuity = ts->flags & MPEGTS_FLAG_DISCONT;
/* update PCR pid by using the first video stream */
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
mpegts_write_pat(s);
for (i = 0; i < ts->nb_services; i++)
mpegts_write_pmt(s, ts->services[i]);
mpegts_write_pat(s);
for (i = 0; i < ts->nb_services; i++)
mpegts_write_pmt(s, ts->services[i]);
*q++ = 0x20 | ts_st->cc; /* Adaptation only */
/* Continuity Count field does not increment (see 13818-1 section 2.4.3.3) */
*q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */
*q++ = 0x20 | ts_st->cc; /* Adaptation only */
/* Continuity Count field does not increment (see 13818-1 section 2.4.3.3) */
*q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */
uint8_t *q;
int val, is_start, len, header_len, write_pcr, is_dvb_subtitle, is_dvb_teletext, flags;
int afc_len, stuffing_len;
uint8_t *q;
int val, is_start, len, header_len, write_pcr, is_dvb_subtitle, is_dvb_teletext, flags;
int afc_len, stuffing_len;
int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key;
av_assert0(ts_st->payload != buf || st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO);
int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key;
av_assert0(ts_st->payload != buf || st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO);
AVStream *st2 = s->streams[i];
MpegTSWriteStream *ts_st2 = st2->priv_data;
if ( ts_st2->payload_size
AVStream *st2 = s->streams[i];
MpegTSWriteStream *ts_st2 = st2->priv_data;
if ( ts_st2->payload_size
mpegts_write_pes(s, st2, ts_st2->payload, ts_st2->payload_size,
ts_st2->payload_pts, ts_st2->payload_dts,
ts_st2->payload_flags & AV_PKT_FLAG_KEY, stream_id);
mpegts_write_pes(s, st2, ts_st2->payload, ts_st2->payload_size,
ts_st2->payload_pts, ts_st2->payload_dts,
ts_st2->payload_flags & AV_PKT_FLAG_KEY, stream_id);
{ "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT,
{ .i64 = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM },
{ "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT,
{ .i64 = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM },
{ "muxrate", NULL,
offsetof(MpegTSWrite, mux_rate), AV_OPT_TYPE_INT,
{ .i64 = 1 }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ "muxrate", NULL,
offsetof(MpegTSWrite, mux_rate), AV_OPT_TYPE_INT,
{ .i64 = 1 }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ "omit_video_pes_length", "Omit the PES packet length for video packets",
offsetof(MpegTSWrite, omit_video_pes_length), AV_OPT_TYPE_BOOL,
{ .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
{ "omit_video_pes_length", "Omit the PES packet length for video packets",
offsetof(MpegTSWrite, omit_video_pes_length), AV_OPT_TYPE_BOOL,
{ .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },