47#define PCR_TIME_BASE 27000000
51#define DVB_PRIVATE_NETWORK_START 0xff01
117#define MPEGTS_FLAG_REEMIT_PAT_PMT 0x01
118#define MPEGTS_FLAG_AAC_LATM 0x02
119#define MPEGTS_FLAG_PAT_PMT_AT_FRAMES 0x04
120#define MPEGTS_FLAG_SYSTEM_B 0x08
121#define MPEGTS_FLAG_DISCONT 0x10
122#define MPEGTS_FLAG_NIT 0x20
123#define MPEGTS_FLAG_OMIT_RAI 0x40
144#define DEFAULT_PES_HEADER_FREQ 16
145#define DEFAULT_PES_PAYLOAD_SIZE ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170)
149#define SECTION_LENGTH 1020
156 const unsigned char *buf_ptr;
158 int first,
b, len1,
left;
163 buf[
len - 4] = (crc >> 24) & 0xff;
164 buf[
len - 3] = (crc >> 16) & 0xff;
165 buf[
len - 2] = (crc >> 8) & 0xff;
166 buf[
len - 1] = crc & 0xff;
171 first = buf == buf_ptr;
179 s->cc = (
s->cc + 1) & 0xf;
181 if (
s->discontinuity) {
185 s->discontinuity = 0;
192 memcpy(q, buf_ptr, len1);
199 s->write_packet(
s, packet);
216 int version,
int sec_num,
int last_sec_num,
217 uint8_t *buf,
int len)
219 uint8_t section[1024], *q;
220 unsigned int tot_len;
224 tot_len = 3 + 5 +
len + 4;
245#define DEFAULT_PROVIDER_NAME "FFmpeg"
246#define DEFAULT_SERVICE_NAME "Service"
249#define SDT_RETRANS_TIME 500
250#define PAT_RETRANS_TIME 100
251#define PCR_RETRANS_TIME 20
252#define NIT_RETRANS_TIME 500
302static void putbuf(uint8_t **q_ptr,
const uint8_t *buf,
size_t len)
304 memcpy(*q_ptr, buf,
len);
311 uint8_t stream_identifier;
312 uint16_t data_component_id;
317 stream_identifier = 0x30;
318 data_component_id = 0x0008;
321 stream_identifier = 0x87;
322 data_component_id = 0x0012;
326 "Unset/unknown ARIB caption profile %d utilized!\n",
334 *q++ = stream_identifier;
339 put16(&q, data_component_id);
461 "Stream %d, codec %s, is muxed as a private data stream "
462 "and may not be recognized upon reading.\n", st->
index,
517 "Stream %d, codec %s, is muxed as a private data stream "
518 "and may not be recognized upon reading.\n", st->
index,
531 int val, stream_type,
i, err = 0;
536 program_info_length_ptr = q;
549 val = 0xf000 | (q - program_info_length_ptr - 2);
550 program_info_length_ptr[0] =
val >> 8;
551 program_info_length_ptr[1] =
val;
553 for (
i = 0;
i <
s->nb_streams;
i++) {
557 const char default_language[] =
"und";
558 const char *language = lang && strlen(lang->
value) >= 3 ? lang->
value : default_language;
561 if (
s->nb_programs) {
647 static const uint8_t coupled_stream_counts[9] = {
648 1, 0, 1, 1, 2, 2, 2, 3, 3
650 static const uint8_t channel_map_a[8][8] = {
657 {0, 4, 1, 2, 3, 5, 6},
658 {0, 6, 1, 2, 3, 4, 5, 7},
660 static const uint8_t channel_map_b[8][8] = {
667 {0, 1, 2, 3, 4, 5, 6},
668 {0, 1, 2, 3, 4, 5, 6, 7},
690 }
else if (ch <= 2) {
700 if (language != default_language ||
704 const char *p, *next;
711 for (p = next = language; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
716 next = strchr(p,
',');
717 if (strlen(p) != 3 && (!next || next != p + 3))
743 int extradata_copied = 0;
748 while (strlen(language) >= 3) {
749 if (
sizeof(
data) - (q -
data) < 8) {
757 if (*language !=
'\0')
772 (subtitling_type & 0xF0) == 0x10)
773 subtitling_type = 0x20 | (subtitling_type & 0x0F);
774 *q++ = subtitling_type;
776 extradata_copied += 5;
786 extradata_copied += 4;
795 *len_ptr = q - len_ptr - 1;
797 uint8_t *len_ptr =
NULL;
798 int extradata_copied = 0;
804 while (strlen(language) >= 3 && q -
data <
sizeof(
data) - 6) {
809 if (*language !=
'\0')
814 extradata_copied += 2;
826 *len_ptr = q - len_ptr - 1;
876 const char *
tag =
"ID3 ";
889 val = 0xf000 | (q - desc_length_ptr - 2);
890 desc_length_ptr[0] =
val >> 8;
891 desc_length_ptr[1] =
val;
896 "The PMT section cannot fit stream %d and all following streams.\n"
897 "Try reducing the number of languages in the audio streams "
898 "or the total number of streams.\n",
i);
910 int i, running_status, free_ca_mode,
val;
919 desc_list_len_ptr = q;
931 desc_len_ptr[0] = q - desc_len_ptr - 1;
934 val = (running_status << 13) | (free_ca_mode << 12) |
935 (q - desc_list_len_ptr - 2);
936 desc_list_len_ptr[0] =
val >> 8;
937 desc_list_len_ptr[1] =
val;
977 put16(&desc_len_ptr, 0xf000 | q - (desc_len_ptr + 2));
978 put16(&loop_len_ptr, 0xf000 | q - (loop_len_ptr + 2));
993 str_len = strlen(str);
994 if (str[0] && (
unsigned)str[0] >= 0x20) {
995 const uint8_t *q = str;
996 int has_multibyte = 0;
1000 has_multibyte |= (
code > 127);
1002 if (has_multibyte) {
1005 buf[0] = str_len + 1;
1007 memcpy(&buf[2], str, str_len);
1016 memcpy(&buf[1], str, str_len);
1031 uint32_t tp_extra_header = pcr % 0x3fffffff;
1032 tp_extra_header =
AV_RB32(&tp_extra_header);
1033 avio_write(
s->pb, (
unsigned char *) &tp_extra_header,
1034 sizeof(tp_extra_header));
1053 char default_service_name[32];
1054 const char *service_name;
1055 const char *provider_name;
1061 service_name = title ? title->
value : default_service_name;
1085 service->
pmt.
cc = 15;
1152 }
else if (pcr_st) {
1166 const char *provider_name;
1185 if (
s->nb_programs > 1) {
1191 if (
s->max_delay < 0)
1205 if (!
s->nb_programs) {
1210 for (
i = 0;
i <
s->nb_programs;
i++) {
1240 for (
i = 0;
i <
s->nb_streams;
i++) {
1291 ts_st->
pid = st->
id;
1293 if (ts_st->
pid >= 0x1FFF) {
1295 "Invalid stream id %d, must be less than 8191\n", st->
id);
1309 for (j = 0; j <
i; j++) {
1311 if (ts_st_prev->
pid == ts_st->
pid) {
1351 for (
i = 0;
i <
s->nb_stream_groups;
i++) {
1405 "sdt every %"PRId64
" ms, pat/pmt every %"PRId64
" ms",
1453 *buf++ = pcr_high >> 25;
1454 *buf++ = pcr_high >> 17;
1455 *buf++ = pcr_high >> 9;
1456 *buf++ = pcr_high >> 1;
1457 *buf++ = pcr_high << 7 | pcr_low >> 8 | 0x7e;
1488 *q++ = (pid >> 8) & 0x1f;
1490 *q++ = 0x20 | (cc & 0xf);
1516 val = fourbits << 4 | (((
pts >> 30) & 0x07) << 1) | 1;
1518 val = (((
pts >> 15) & 0x7fff) << 1) | 1;
1521 val = (((
pts) & 0x7fff) << 1) | 1;
1532 if ((
pkt[3] & 0x20) == 0) {
1595 const uint8_t *payload,
int payload_size,
1602 int val, is_start,
len, header_len, write_pcr,
flags;
1603 int afc_len, stuffing_len;
1624 while (payload_size > 0) {
1650 for (
int i = 0;
i <
s->nb_streams;
i++) {
1653 int st2_index =
i < st->
index ?
i : (
i + 1 ==
s->nb_streams ? st->
index :
i + 1);
1681 }
else if (write_pcr) {
1712 ts_st->
cc = (ts_st->
cc + 1) & 0xf;
1713 *q++ = 0x10 | ts_st->
cc;
1721 !is_dvb_teletext ) {
1738 int pes_extension = 0;
1739 int pes_header_stuffing_bytes = 0;
1791 if (is_dvb_teletext) {
1792 pes_header_stuffing_bytes = 0x24 - header_len;
1795 len = payload_size + header_len + 3;
1797 if (is_dvb_subtitle) {
1842 if (is_dvb_subtitle) {
1849 if (is_dvb_teletext) {
1851 q += pes_header_stuffing_bytes;
1861 header_len = q - buf;
1864 if (
len > payload_size)
1867 if (stuffing_len > 0) {
1869 if (buf[3] & 0x20) {
1871 afc_len = buf[4] + 1;
1872 memmove(buf + 4 + afc_len + stuffing_len,
1874 header_len - (4 + afc_len));
1875 buf[4] += stuffing_len;
1879 memmove(buf + 4 + stuffing_len, buf + 4, header_len - 4);
1881 buf[4] = stuffing_len - 1;
1882 if (stuffing_len >= 2) {
1889 if (is_dvb_subtitle && payload_size ==
len) {
1897 payload_size -=
len;
1908 "no startcode found, use the video bitstream filter '%s_mp4toannexb' to fix it "
1909 "('-bsf:v %s_mp4toannexb' option with ffmpeg)\n", codec, codec, codec);
1931 static const int durations[32] = {
1932 480, 960, 1920, 2880,
1933 480, 960, 1920, 2880,
1934 480, 960, 1920, 2880,
1942 int toc, frame_duration, nframes,
duration;
1949 frame_duration = durations[toc >> 3];
1963 nframes =
pkt->data[1] & 63;
1967 duration = nframes * frame_duration;
1970 "Opus packet duration > 120 ms, invalid");
1978 const uint8_t *extra_data,
const int extra_size,
AVPacket *
pkt,
int *
size)
1983 if (
pkt->size > INT_MAX - sz - aud_size - extra_size)
1989 memcpy(
data + sz,
aud, aud_size);
1991 memcpy(
data + sz + aud_size, extra_data, extra_size);
1992 memcpy(
data + sz + aud_size + extra_size,
pkt->data,
pkt->size);
1993 *
size =
pkt->size + sz + aud_size + extra_size;
1997#define H264_NAL_TYPE(state) (state & 0x1f)
1998#define HEVC_NAL_TYPE(state) ((state & 0x7e) >> 1)
1999#define VVC_NAL_TYPE(state) ((state >> 11) & 0x1f)
2004 const uint8_t *buf =
pkt->data;
2011 int opus_samples = 0;
2018 stream_id = stream_id_p[0];
2039 const uint8_t *p = buf, *buf_end = p +
size;
2040 const uint8_t *found_aud =
NULL, *found_aud_end =
NULL;
2042 uint32_t
state = -1;
2062 found_aud_end = p + 1;
2063 if (found_aud < buf)
2065 if (buf_end < found_aud_end)
2066 found_aud_end = buf_end;
2068 }
while (p < buf_end
2071 && (extradd > 0 || !found_aud));
2077 const uint8_t
aud[] = {
2085 }
else if (extradd != 0) {
2091 if (
pkt->size > INT_MAX - 1 - extradd)
2093 new_pkt_size =
pkt->size + 1 + extradd;
2098 bytestream2_put_byte(&pb, 0x00);
2105 size = new_pkt_size;
2108 if (
pkt->size < 2) {
2112 if ((
AV_RB16(
pkt->data) & 0xfff0) != 0xfff0) {
2118 "and extradata missing\n");
2141 const uint8_t *p = buf, *buf_end = p +
size;
2142 uint32_t
state = -1;
2158 }
while (p < buf_end && nal_type != HEVC_NAL_AUD && nal_type >=
HEVC_NAL_VPS);
2163 const uint8_t
aud[] = {
2174 const uint8_t *p = buf, *buf_end = p +
size;
2175 uint32_t
state = -1;
2176 uint32_t nal_type = -1;
2192 }
while (p < buf_end && nal_type != VVC_AUD_NUT && nal_type >=
VVC_OPI_NUT);
2197 const uint8_t
aud[] = {
2207 if (
pkt->size < 2) {
2215 size_t side_data_size;
2217 int ctrl_header_size;
2218 int trim_start = 0, trim_end = 0;
2226 if (side_data && side_data_size >= 10) {
2231 if (
pkt->size > INT_MAX - 7 -
pkt->size / 255)
2233 ctrl_header_size =
pkt->size + 2 +
pkt->size / 255 + 1;
2235 ctrl_header_size += 2;
2237 ctrl_header_size += 2;
2267 trim_end =
FFMIN(trim_end, opus_samples - trim_start);
2274 size = ctrl_header_size;
2284 uint8_t number_of_channels_flag;
2285 uint8_t service_type_flag;
2286 uint8_t full_service_flag = 1;
2289 dvb_ac3_desc =
av_mallocz(
sizeof(*dvb_ac3_desc));
2290 if (!dvb_ac3_desc) {
2298 number_of_channels_flag = 1;
2301 number_of_channels_flag = 0;
2305 number_of_channels_flag = 3;
2307 number_of_channels_flag = 2;
2314 number_of_channels_flag = 4;
2317 number_of_channels_flag = 7;
2321 if (service_type_flag == 1 || service_type_flag == 4 ||
2322 (service_type_flag == 7 && !number_of_channels_flag))
2323 full_service_flag = 0;
2327 ((service_type_flag & 0x7) << 3) |
2328 (number_of_channels_flag & 0x7);
2385 for (
i = 0;
i <
s->nb_streams;
i++) {
2399 while (packets++ < 32)
2428 for (
i = 0;
i <
s->nb_streams;
i++) {
2452 const struct Entry {
2454 const char *bsf_name;
2465 const struct Entry *e =
list +
i;
2476#define OFFSET(x) offsetof(MpegTSWrite, x)
2477#define ENC AV_OPT_FLAG_ENCODING_PARAM
2479 {
"mpegts_transport_stream_id",
"Set transport_stream_id field.",
2481 {
"mpegts_original_network_id",
"Set original_network_id field.",
2483 {
"mpegts_service_id",
"Set service_id field.",
2485 {
"mpegts_service_type",
"Set service_type field.",
2487 {
"digital_tv",
"Digital Television.",
2489 {
"digital_radio",
"Digital Radio.",
2491 {
"teletext",
"Teletext.",
2493 {
"advanced_codec_digital_radio",
"Advanced Codec Digital Radio.",
2495 {
"mpeg2_digital_hdtv",
"MPEG2 Digital HDTV.",
2497 {
"advanced_codec_digital_sdtv",
"Advanced Codec Digital SDTV.",
2499 {
"advanced_codec_digital_hdtv",
"Advanced Codec Digital HDTV.",
2501 {
"hevc_digital_hdtv",
"HEVC Digital Television Service.",
2503 {
"mpegts_pmt_start_pid",
"Set the first pid of the PMT.",
2505 {
"mpegts_start_pid",
"Set the first pid.",
2509 {
"pes_payload_size",
"Minimum PES packet payload in bytes",
2512 {
"resend_headers",
"Reemit PAT/PMT before writing the next packet",
2514 {
"latm",
"Use LATM packetization for AAC",
2516 {
"pat_pmt_at_frames",
"Reemit PAT and PMT at each video frame",
2518 {
"system_b",
"Conform to System B (DVB) instead of System A (ATSC)",
2520 {
"initial_discontinuity",
"Mark initial packets as discontinuous",
2522 {
"nit",
"Enable NIT transmission",
2524 {
"omit_rai",
"Disable writing of random access indicator",
2527 {
"tables_version",
"set PAT, PMT, SDT and NIT version",
OFFSET(tables_version),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 31,
ENC },
2528 {
"omit_video_pes_length",
"Omit the PES packet length for video packets",
2530 {
"pcr_period",
"PCR retransmission time in milliseconds",
2532 {
"mpegts_pcr_pid",
"Set a separate PCR PID (-1 means PCR on video PID)",
2534 {
"pat_period",
"PAT/PMT retransmission time limit in seconds",
2536 {
"sdt_period",
"SDT retransmission time limit in seconds",
2538 {
"nit_period",
"NIT retransmission time limit in seconds",
2544 .class_name =
"MPEGTS muxer",
2553 .p.mime_type =
"video/MP2T",
2554 .p.extensions =
"ts,m2t,m2ts,mts",
int avpriv_ac3_parse_header(AC3HeaderInfo **phdr, const uint8_t *buf, size_t size)
static double val(void *priv, double ch)
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
static av_always_inline int bytestream2_tell_p(const PutByteContext *p)
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, const uint8_t *src, unsigned int size)
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int FUNC aud(CodedBitstreamContext *ctx, RWContext *rw, H264RawAUD *current)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
Public header for CRC hash function implementation.
Misc types and constants that do not belong anywhere else.
#define AV_PROFILE_ARIB_PROFILE_A
#define AV_PROFILE_ARIB_PROFILE_C
#define FF_COMPLIANCE_NORMAL
#define AV_PROFILE_KLVA_SYNC
static unsigned int nb_streams
static const uint8_t frame_size[4]
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
AVCodecID
Identify the syntax and semantics of the bitstream.
@ AV_CODEC_ID_HDMV_PGS_SUBTITLE
@ AV_CODEC_ID_DVB_SUBTITLE
@ AV_CODEC_ID_HDMV_TEXT_SUBTITLE
@ AV_CODEC_ID_ARIB_CAPTION
@ AV_CODEC_ID_DVB_TELETEXT
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
@ AV_PKT_DATA_SKIP_SAMPLES
Recommends skipping the specified number of samples.
@ AV_PKT_DATA_MPEGTS_STREAM_ID
MPEGTS stream ID as uint8_t, this is required to pass the stream ID information from the demuxer to t...
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
av_warn_unused_result int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
const AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AV_ROUND_UP
Round toward +infinity.
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
Add the pointer to an element to a dynamic array.
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE
Internal time base represented as integer.
#define LIBAVUTIL_VERSION_INT
H.264 common definitions.
int ff_lcvec_parse_config_record(LCEVCDecoderConfigurationRecord *lvcc, const uint8_t *buf, int size, void *logctx)
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
static const uint16_t mask[17]
#define MKTAG(a, b, c, d)
Memory handling functions.
#define STREAM_TYPE_VIDEO_MPEG4
#define STREAM_TYPE_VIDEO_CAVS
#define STREAM_TYPE_AUDIO_MPEG2
#define STREAM_TYPE_VIDEO_HEVC
#define STREAM_TYPE_VIDEO_VVC
#define STREAM_TYPE_PRIVATE_DATA
#define STREAM_TYPE_AUDIO_AAC
#define STREAM_TYPE_VIDEO_H264
#define STREAM_TYPE_AUDIO_MPEG1
#define STREAM_TYPE_VIDEO_MPEG2
#define STREAM_ID_PRIVATE_STREAM_2
#define STREAM_TYPE_VIDEO_AVS3
#define STREAM_TYPE_VIDEO_DIRAC
#define STREAM_ID_PADDING_STREAM
#define DVB_EXTENSION_DESCRIPTOR
#define STREAM_TYPE_BLURAY_SUBTITLE_TEXT
#define M2TS_PGSSUB_START_PID
#define STREAM_TYPE_VIDEO_VC1
#define STREAM_TYPE_ATSC_AUDIO_AC3
#define STREAM_TYPE_BLURAY_AUDIO_EAC3
#define STREAM_ID_METADATA_STREAM
#define STREAM_TYPE_BLURAY_SUBTITLE_PGS
#define NETWORK_NAME_DESCRIPTOR
#define SUBTITLING_DESCRIPTOR
#define M2TS_AUDIO_START_PID
#define STREAM_ID_EMM_STREAM
#define STREAM_TYPE_BLURAY_AUDIO_TRUEHD
#define LCEVC_LINKAGE_DESCRIPTOR
#define STREAM_TYPE_BLURAY_AUDIO_DTS
#define STREAM_TYPE_AUDIO_AAC_LATM
#define ISO_639_LANGUAGE_DESCRIPTOR
#define STREAM_IDENTIFIER_DESCRIPTOR
#define TELETEXT_DESCRIPTOR
#define STREAM_TYPE_VIDEO_LCEVC
#define LCEVC_VIDEO_DESCRIPTOR
#define STREAM_TYPE_VIDEO_AVS2
#define STREAM_TYPE_ATSC_AUDIO_EAC3
#define REGISTRATION_DESCRIPTOR
#define SERVICE_DESCRIPTOR
#define STREAM_TYPE_BLURAY_AUDIO_PCM_BLURAY
#define STREAM_ID_PROGRAM_STREAM_DIRECTORY
#define STREAM_TYPE_BLURAY_AUDIO_AC3
#define STREAM_ID_DSMCC_STREAM
#define STREAM_ID_EXTENDED_STREAM_ID
#define ENHANCED_AC3_DESCRIPTOR
#define DATA_COMPONENT_DESCRIPTOR
#define STREAM_ID_PROGRAM_STREAM_MAP
#define STREAM_ID_ECM_STREAM
#define METADATA_DESCRIPTOR
#define STREAM_ID_PRIVATE_STREAM_1
#define STREAM_ID_TYPE_E_STREAM
#define STREAM_ID_VIDEO_STREAM_0
#define STREAM_TYPE_BLURAY_AUDIO_DTS_HD
#define SYSTEM_CLOCK_FREQUENCY_DIVISOR
#define EXTENSION_DESCRIPTOR
#define STREAM_TYPE_METADATA
#define SERVICE_LIST_DESCRIPTOR
#define STREAM_ID_AUDIO_STREAM_0
static const AVClass mpegts_muxer_class
#define MPEGTS_FLAG_OMIT_RAI
static int opus_get_packet_samples(AVFormatContext *s, AVPacket *pkt)
static void mpegts_write_nit(AVFormatContext *s)
static void enable_pcr_generation_for_stream(AVFormatContext *s, AVStream *pcr_st)
static int get_pes_stream_id(AVFormatContext *s, AVStream *st, int stream_id, int *async)
#define HEVC_NAL_TYPE(state)
static void mpegts_deinit(AVFormatContext *s)
static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
static int mpegts_write_section1(MpegTSSection *s, int tid, int id, int version, int sec_num, int last_sec_num, uint8_t *buf, int len)
static void write_pts(uint8_t *q, int fourbits, int64_t pts)
#define H264_NAL_TYPE(state)
static void extend_af(uint8_t *pkt, int size)
static void mpegts_insert_pcr_only(AVFormatContext *s, AVStream *st)
static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
static void write_packet(AVFormatContext *s, const uint8_t *packet)
static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
static void select_pcr_streams(AVFormatContext *s)
static void mpegts_write_flush(AVFormatContext *s)
static int put_arib_caption_descriptor(AVFormatContext *s, uint8_t **q_ptr, AVCodecParameters *codecpar)
#define MPEGTS_FLAG_REEMIT_PAT_PMT
static void put_registration_descriptor(uint8_t **q_ptr, uint32_t tag)
static void mpegts_write_pes(AVFormatContext *s, AVStream *st, const uint8_t *payload, int payload_size, int64_t pts, int64_t dts, int key, int stream_id)
int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt)
Check presence of H264 startcode.
static void putbuf(uint8_t **q_ptr, const uint8_t *buf, size_t len)
#define DEFAULT_PES_PAYLOAD_SIZE
static void put16(uint8_t **q_ptr, int val)
static int64_t get_pcr(const MpegTSWrite *ts)
static int get_dvb_stream_type(AVFormatContext *s, AVStream *st)
static void mpegts_write_sdt(AVFormatContext *s)
#define MPEGTS_FLAG_AAC_LATM
static int mpegts_write_end(AVFormatContext *s)
#define DVB_PRIVATE_NETWORK_START
static int check_h26x_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt, const char *codec)
static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len)
static void mpegts_insert_pcr_only_pid(AVFormatContext *s, int pid, int cc, int discontinuity)
static void set_af_flag(uint8_t *pkt, int flag)
#define MPEGTS_FLAG_DISCONT
#define MPEGTS_FLAG_PAT_PMT_AT_FRAMES
#define DEFAULT_PROVIDER_NAME
static int mpegts_check_bitstream(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
static void mpegts_write_pat(AVFormatContext *s)
static int mpegts_init(AVFormatContext *s)
static MpegTSService * mpegts_add_service(AVFormatContext *s, int sid, const AVDictionary *metadata, AVProgram *program)
static uint8_t * h26x_prefix_aud(const uint8_t *aud, const int aud_size, const uint8_t *extra_data, const int extra_size, AVPacket *pkt, int *size)
static int encode_str8(uint8_t *buf, const char *str)
static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
#define MPEGTS_FLAG_SYSTEM_B
#define DEFAULT_SERVICE_NAME
static int get_m2ts_stream_type(AVFormatContext *s, AVStream *st)
#define VVC_NAL_TYPE(state)
static void mpegts_insert_null_packet(AVFormatContext *s)
static void retransmit_si_info(AVFormatContext *s, int force_pat, int force_sdt, int force_nit, int64_t pcr)
@ MPEGTS_SERVICE_TYPE_DIGITAL_RADIO
@ MPEGTS_SERVICE_TYPE_HEVC_DIGITAL_HDTV
@ MPEGTS_SERVICE_TYPE_TELETEXT
@ MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_RADIO
@ MPEGTS_SERVICE_TYPE_DIGITAL_TV
@ MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_HDTV
@ MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_SDTV
@ MPEGTS_SERVICE_TYPE_MPEG2_DIGITAL_HDTV
static uint8_t * get_ts_payload_start(uint8_t *pkt)
static int write_pcr_bits(uint8_t *buf, int64_t pcr)
#define FF_OFMT_FLAG_ALLOW_FLUSH
This flag indicates that the muxer stores data internally and supports flushing it.
#define FF_ARRAY_ELEMS(a)
Accelerated start code search function for start codes common to MPEG-1/2/4 video,...
const uint8_t * avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
This struct describes the properties of an encoded stream.
int extradata_size
Size of the extradata content in bytes.
AVChannelLayout ch_layout
The channel layout and number of channels.
enum AVMediaType codec_type
General type of the encoded data.
int profile
Codec-specific bitstream restrictions that the stream conforms to.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
int initial_padding
Number of padding audio samples at the start.
AVIOContext * pb
I/O context.
const struct AVOutputFormat * oformat
The output container format.
AVStream ** streams
A list of all streams in the file.
This structure stores compressed data.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
New fields can be added to the end with minor version bumps.
unsigned int nb_stream_indexes
unsigned int * stream_index
unsigned int el_index
Index of the enhancement layer stream in AVStreamGroup.
unsigned int nb_entries
Number of elements in AVStreamGroup.entries.
enum AVStreamGroupParamsType type
Group type.
AVStreamGroupEntry ** entries
A list of streams or child groups in the group.
union AVStreamGroup::@313244315204024013007202273061153315146016101155 params
Group type-specific parameters.
int64_t id
Group type-specific group ID.
struct AVStreamGroupLayeredVideo * layered_video
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t nb_frames
number of frames in this stream if known or 0
int id
Format-specific stream ID.
int index
stream index in AVFormatContext
AVRational avg_frame_rate
Average framerate.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
uint8_t component_type_flag
AVPacket * pkt
Used to hold temporary packets for the generic demuxing code.
uint8_t field_type_bit_flag
uint8_t picture_type_bit_flag
uint8_t processed_planes_type_flag
void(* write_packet)(struct MpegTSSection *s, const uint8_t *packet)
uint8_t provider_name[256]
int opus_pending_trim_start
AVStreamGroup ** stream_groups
int first_timestamp_checked
first pts/dts check needed
DVBAC3Descriptor * dvb_ac3_desc
int omit_video_pes_length
int pcr_pid
user-specified separate PCR PID (-1 = use video PID)
int64_t pcr_stream_last_pcr
last PCR sent on the dedicated PID
int mux_rate
set to 1 when VBR
MpegTSService ** services
uint8_t provider_name[256]
int64_t pcr_stream_pcr_period
PCR period for the dedicated stream.
#define OPUS_TIMESTAMP_RATE
The clock of Opus: packet lengths, pre-skip and trimming count samples at 48 kHz whatever the sample ...
static struct @232240247175332074307271266321204261331170211232 state