mpegtsenc: Add an AVOption for forcing a new PAT/PMT/SDT to be written
When segmenting the output from the mpegts muxer, one can now set this option when cutting to a new segment, to make sure the next segment starts with PAT/PMT/SDT. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
@@ -76,6 +76,8 @@ typedef struct MpegTSWrite {
|
|||||||
|
|
||||||
int pmt_start_pid;
|
int pmt_start_pid;
|
||||||
int start_pid;
|
int start_pid;
|
||||||
|
|
||||||
|
int reemit_pat_pmt;
|
||||||
} MpegTSWrite;
|
} MpegTSWrite;
|
||||||
|
|
||||||
/* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */
|
/* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */
|
||||||
@@ -96,6 +98,8 @@ static const AVOption options[] = {
|
|||||||
{ "muxrate", NULL, offsetof(MpegTSWrite, mux_rate), AV_OPT_TYPE_INT, {1}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
|
{ "muxrate", NULL, offsetof(MpegTSWrite, mux_rate), AV_OPT_TYPE_INT, {1}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
|
||||||
{ "pes_payload_size", "Minimum PES packet payload in bytes",
|
{ "pes_payload_size", "Minimum PES packet payload in bytes",
|
||||||
offsetof(MpegTSWrite, pes_payload_size), AV_OPT_TYPE_INT, {DEFAULT_PES_PAYLOAD_SIZE}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
|
offsetof(MpegTSWrite, pes_payload_size), AV_OPT_TYPE_INT, {DEFAULT_PES_PAYLOAD_SIZE}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
|
||||||
|
{ "resend_headers", "Reemit PAT/PMT before writing the next packet",
|
||||||
|
offsetof(MpegTSWrite, reemit_pat_pmt), AV_OPT_TYPE_INT, {0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -939,6 +943,12 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
const uint64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE)*2;
|
const uint64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE)*2;
|
||||||
int64_t dts = AV_NOPTS_VALUE, pts = AV_NOPTS_VALUE;
|
int64_t dts = AV_NOPTS_VALUE, pts = AV_NOPTS_VALUE;
|
||||||
|
|
||||||
|
if (ts->reemit_pat_pmt) {
|
||||||
|
ts->pat_packet_count = ts->pat_packet_period - 1;
|
||||||
|
ts->sdt_packet_count = ts->sdt_packet_period - 1;
|
||||||
|
ts->reemit_pat_pmt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (pkt->pts != AV_NOPTS_VALUE)
|
if (pkt->pts != AV_NOPTS_VALUE)
|
||||||
pts = pkt->pts + delay;
|
pts = pkt->pts + delay;
|
||||||
if (pkt->dts != AV_NOPTS_VALUE)
|
if (pkt->dts != AV_NOPTS_VALUE)
|
||||||
|
|||||||
Reference in New Issue
Block a user