summaryrefslogtreecommitdiff
path: root/libavformat/mpegtsenc.c
Commit message (Collapse)AuthorAge
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-31
| | | | | | | | | | | There are lots of files that don't need it: The number of object files that actually need it went down from 2011 to 884 here. Keep it for external users in order to not cause breakages. Also improve the other headers a bit while just at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mux: Rename FF_FMT_ALLOW_FLUSH->FF_OFMT_FLAG_ALLOW_FLUSHAndreas Rheinhardt2024-03-22
| | | | | | | It better reflects that this is a muxer-only flag. Also document the flag. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mpegtsenc: correct bitstream checkGyan Doshi2024-03-16
| | | | | | | | | | | 8559cce3c3 made the bitstream check generic using a LUT. However, one of the comparisons which involves a bitwise AND and equality check is faulty due to operator precedence. First reported and analysed at https://github.com/streamlink/streamlink/issues/5876 Fixes #10908
* all: use designated initializers for AVOption.unitAnton Khirnov2024-02-14
| | | | | | | | | | | | | | | | | | | | | | | | Makes it robust against adding fields before it, which will be useful in following commits. Majority of the patch generated by the following Coccinelle script: @@ typedef AVOption; identifier arr_name; initializer list il; initializer list[8] il1; expression tail; @@ AVOption arr_name[] = { il, { il1, - tail + .unit = tail }, ... }; with some manual changes, as the script: * has trouble with options defined inside macros * sometimes does not handle options under an #else branch * sometimes swallows whitespace
* avformat/mpegts: add ts stream types for H266/VVCThomas Siedel2024-01-31
| | | | | | | | | | | | | | Add transport stream stream type 0x33 for vvc. Add STREAM_TYPE_VIDEO_VVC to MPEG-1/2 and MPEG-2 transport stream. Add basic transport stream support for TS mux/demux. Tested with: ffmpeg -i NovosobornayaSquare_1920x1080.mp4 -c:v libvvenc test.ts && ffmpeg -i test.ts -f null - ffmpeg -i NovosobornayaSquare_1920x1080.mp4 -c:v copy test.ts && ffmpeg -i test.ts -f md5 - Signed-off-by: Marton Balint <cus@passwd.hu> Signed-off-by: Thomas Siedel <thomas.ff@spin-digital.com> Co-Authored-By: Nuo Mi <nuomi2021@gmail.com>
* avformat/mpegtsenc: refact out h26x_prefix_audNuo Mi2024-01-31
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: refact, remove h264, hevc magic numbers for nal_typeNuo Mi2024-01-31
|
* avformat/mpegtsenc: refact, move h264, hevc startcode checking to ↵Nuo Mi2024-01-31
| | | | check_h26x_startcode
* avformat/mpegtsenc: refact mpegts_check_bitstream to loop up tableNuo Mi2024-01-31
| | | | | Signed-off-by: Marton Balint <cus@passwd.hu> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-20
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-22
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: Deprecate AVFMT_ALLOW_FLUSHAndreas Rheinhardt2023-10-03
| | | | | | | | | | | | | | | It is of no value to the user, because every muxer can always be flushed with a NULL packet. As its documentation shows ("If not set, the muxer will not receive a NULL packet in the write_packet function") it is actually an internal flag that has been publically exposed because there was no internal flags field for output formats for a long time. But now there is and so use it by replacing the public flag with a private one. Reviewed-by: James Almer <jamrial@gmail.com> Reviewed-by: Anton Khirnov <anton@khirnov.net> Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* definesAndreas Rheinhardt2023-09-07
| | | | | | | | | These defines are also used in other contexts than just AVCodecContext ones, e.g. in libavformat. Furthermore, given that these defines are public, the AV-prefix is the right one, so deprecate (and not just move) the FF-macros. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mpegts: add support for preserving SMPTE 2038 when transcoding ↵Devin Heitmueller2023-03-26
| | | | | | | | | | | | | | | | | MPEG-TS streams Add the appropriate descriptors to the MPEG-TS demux and mux to ensure that SMPTE 2038 VANC streams are properly preserved when using codec copy (including adding the appropriate PMT descriptors). The focus of this patch is TS input to TS output. A separate patch adds support for output of 2038 VANC over decklink SDI. Thanks to Marton Balint for feedback to preserve ABI compatibility. Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: Restrict "async" behavior to KLV async packetsDevin Heitmueller2023-03-16
| | | | | | | | | | | | | | The original code would strip off the PTS/DTS of any packets which had a stream ID of STREAM_ID_PRIVATE_STREAM_1. While the intent was to apply this to asynchronous KLV packets, it was being applied to any codec that had that same stream ID (including types such as SMPTE 2038). Add a clause to the if() statement to ensure it only gets applied if the codec actually is KLV. Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: re-emit extradata ahead of IDR pictures even if AUD is ↵John Coiner2023-02-19
| | | | | | | | | | | | | | | | | | already present Current mpegtsenc code only inserts SPS/PPS from extradata before IDR frames if AUD is also inserted. Unfortunately some encoders may preface a key frame with an AUD, but no SPS/PPS. In that case current code does not repeat the "extradata" and the resulting HLS stream may become noncompliant and unjoinable. Fix this by always inserting SPS/PPS and moving AUD to the beginning of the packet if it is already present. Fixes ticket #10148. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/avformat: Move AVOutputFormat internals out of public headerAndreas Rheinhardt2023-02-09
| | | | | | | | | | | | | | This commit does for AVOutputFormat what commit 20f972701806be20a77f808db332d9489343bb78 did for AVCodec: It adds a new type FFOutputFormat, moves all the internals of AVOutputFormat to it and adds a now reduced AVOutputFormat as first member. This does not affect/improve extensibility of both public or private fields for muxers (it is still a mess due to lavd). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avformat/mpegtsenc: add omit_rai flagZhao Zhili2022-10-08
| | | | | | | Add PCR at keyframe can be undesirable when -pcr_period is specified. Add an flag to disable this behavior. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avformat/internal: Don't include avcodec.hAndreas Rheinhardt2022-09-26
| | | | | | | | | | | | | | | The general demuxing API uses parsers and decoders. Therefore FFStream contains pointers to AVCodecContexts and AVCodecParserContext and lavf/internal.h includes lavc/avcodec.h. Yet actually only a few files files really use these; and it is best when this number stays small. Therefore this commit uses opaque structs in lavf/internal.h for these contexts and stops including avcodec.h. This also avoids including lavc/codec_desc.h implicitly. All other headers are implicitly included as now (mostly through codec.h). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/(mpeg|mpegts|mxf|sup)enc: Use const uint8_t* to access pkt dataAndreas Rheinhardt2022-07-04
| | | | | | | | | The packets muxers receive are not guaranteed to be writable, so they must not be modified. Ergo only access the packet's data via a const uint8_t*. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Move ff_stream_add_bitstream_filter to mux.cAndreas Rheinhardt2022-05-10
| | | | | | | It is muxing-only; in fact, it should be considered part of the core muxing code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* mpegtsenc: convert to new channel layout APIAnton Khirnov2022-03-15
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mpegtsenc: fix muxing pcm-blurayPaul B Mahol2022-03-06
|
* avcodec/internal.h: Move avpriv_find_start_code() to startcode.hAndreas Rheinhardt2022-02-08
| | | | | | | | This is by definition the appropriate place for it. Remove all the now unnecessary libavcodec/internal.h inclusions; also remove other unnecessary headers from the affected files. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mpegtsenc: Avoid allocation of AVPacketAndreas Rheinhardt2021-11-27
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: Add AVStream parameter to check_bitstream() sigAndreas Rheinhardt2021-11-27
| | | | | | | | | | For most check_bitstream() functions this just avoids having to dereference s->streams[pkt->stream_index] themselves; but for meta-muxers it will allow to forward the packet to stream with a different stream_index (belonging to a different AVFormatContext) without using a spare packet. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mpegtsenc: do not include adaptation field in teletext TS packetsAlex Shumsky2021-11-06
| | | | | | | | | | | | | | | From ETSI EN 300 472 V1.3.1 (2003-05) Specification for conveying ITU-R System B Teletext in DVB bitstreams: 4.1 Transport Stream (TS) packet format The standard TS packet syntax and semantics are followed, noting the following constraint: - adaptation_field_control only the values "01" and "10" are permitted. Some set top boxes (Motorola, Arris, Zyxel) refuse non-conforming packets. Signed-off-by: Alex Shumsky <alexthreed@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: fix first_pcr initial updateMaksym Veremeyenko2021-11-06
| | | | | | | | | | | | | | | Commit 6f36eb0da71d22aadf8f056f0966bd86656ea57e claim it fixes endless loop on package generation if muxrate specified and copyts used. But actually it does not work properly if -mpegts_copyts 1 is specified: ffmpeg -y -copyts -i loewe.ts -c:v libx264 -x264opts nal-hrd=cbr:force-cfr=1 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize 1000k -c:a mp2 -f mpegts -mpegts_copyts 1 -muxrate 4500k -vframes 1000 test.ts ffmpeg generate huge file until it reach zero-based pcr value equal to first dts. Attached patch fixes it. Reviewed-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: add AVSV format_identifier for AVS standardLimin Wang2021-10-20
| | | | | | | Listing of Registered Identifiers: https://smpte-ra.org/registered-mpeg-ts-ids Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegts: add support for stream_type 0xd4, which is AVS3Limin Wang2021-10-20
| | | | | | | | GB/T 17975.1 Information technology-Generic coding of moving pictures and associated audio information-Part 1:Systems Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegts: add support for stream_type 0xd2, which is AVS2Limin Wang2021-10-19
| | | | | | | | GB/T 17975.1 Information technology-Generic coding of moving pictures and associated audio information-Part 1:Systems Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: enable muxing of ARIB captionszheng qian2021-06-10
| | | | | | | | Writes a general ARIB stream identifier descriptor, as well as a data component descriptor which also includes a pre-defined additional_arib_caption_info structure. Signed-off-by: zheng qian <xqq@xqq.im>
* avformat/mpegtsenc: add NIT supportUbaldo Porcheddu2021-05-20
| | | | | | | | | | | | | With some minor changes by Marton Balint: - removed trailing whitespace - fixed network_descriptors_length - fixed reserved_future_use flag in the start of the section - removed unused program variable - emit first NIT after PAT - some other cosmetics Signed-off-by: Ubaldo Porcheddu <ubaldo@eja.it> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: Fix indentation inside if-clause in mpegts_write_pes()zheng qian2021-04-28
| | | | | | | Fix indentation caused by the added stream_id check. Signed-off-by: zheng qian <xqq@xqq.im> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: Fix mpegts_write_pes() for private_stream_2 and other typeszheng qian2021-04-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to the PES packet definition defined in Table 2-17 of ISO_IEC_13818-1 specification, some fields like PTS/DTS or pes_extension could only appears if the stream_id meets the condition: if (stream_id != 0xBC && // program_stream_map stream_id != 0xBE && // padding_stream stream_id != 0xBF && // private_stream_2 stream_id != 0xF0 && // ECM stream_id != 0xF1 && // EMM stream_id != 0xFF && // program_stream_directory stream_id != 0xF2 && // DSMCC_stream stream_id != 0xF8) // ITU-T Rec. H.222.1 type E stream And the following stream_id types don't have fields like PTS/DTS: else if ( stream_id == program_stream_map || stream_id == private_stream_2 || stream_id == ECM || stream_id == EMM || stream_id == program_stream_directory || stream_id == DSMCC_stream || stream_id == ITU-T Rec. H.222.1 type E stream ) { for (i = 0; i < PES_packet_length; i++) { PES_packet_data_byte } } Current implementation skipped the check of stream_id causing some kind of streams like private_stream_2 to be incorrectly written with actually a private_stream_1-like PES header with PTS/DTS field. For example, Japan DTV transmits news and alerts through ARIB superimpose that utilizes private_stream_2 still could not be remuxed correctly for now. This patch set fixes the remuxing for private_stream_2 and other stream_id types. Signed-off-by: zheng qian <xqq@xqq.im> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: factorize determining pes stream idMarton Balint2021-04-28
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: move is_dvb_subtitle/is_dvb_teletext initialization upwardsMarton Balint2021-04-28
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: Constify all muxer/demuxersAndreas Rheinhardt2021-04-27
| | | | | | | This is possible now that the next-API is gone. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/buffer: Switch AVBuffer API to size_tAndreas Rheinhardt2021-04-27
| | | | | | | Announced in 14040a1d913794d9a3fd6406a6d8c2f0e37e0062. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mpegtsenc: Preserve disposition in the absence of languageAndreas Rheinhardt2021-04-05
| | | | | | | Implements ticket #9113. Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mpegtsenc: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: use the buffer_size_t typedef where requiredJames Almer2021-03-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mpegtsenc: check that not only first pts but also first dts is validLimin Wang2020-10-30
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: first_pts_check -> first_pts_checkedLimin Wang2020-10-30
| | | | | | | change to first_pts_checked and reverse the logic. Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: make first_pcr sync with the first valid dtsLimin Wang2020-10-27
| | | | | | | | | | | | | now first_pts assume dts will start from zero, if it's not true(copyts is enable), too many null packet will be inserted for cbr output. Please test with below command, you'll get huge test.ts without the patch: ./ffmpeg -y -copyts -i ../fate-suite/mpegts/loewe.ts -c:v libx264 -x264opts \ nal-hrd=cbr:force-cfr=1 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize \ 1000k -c:a mp2 -muxrate 4500k -vframes 1000 test.ts Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: use total_size instead of avio_tell()Limin Wang2020-10-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | avio_tell() fails to get the amount of data written so far when the underlying IO context is flushed to segments. Please test with below command: $ ./ffmpeg -f lavfi -i testsrc=duration=100:size=vga -c:v libx264 -x264opts \ nal-hrd=cbr:force-cfr=1 -b:v 500k -minrate 500k -maxrate 500k -bufsize 500k \ -f hls -hls_time 10 -hls_ts_options "muxrate=2000000" test%d.ts $ du -h test*.ts Before: 2.4M test00.ts 4.8M test11.ts 7.2M test22.ts 9.6M test33.ts 12M test44.ts ... After apply the patch: 2.4M test00.ts 2.4M test11.ts 2.4M test22.ts 2.4M test33.ts 2.4M test44.ts ... Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegts: replace magic descriptor_tag values with definesBrad Hards2020-10-16
| | | | | | | | This takes the used values from ISO/IEC 13818-1 Table 2-45 and adds them to the mpegts.h header. No functional changes. Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: reindent the codeLimin Wang2020-08-26
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: add registration descriptor for AC-3 and EAC3Limin Wang2020-08-26
| | | | | | | | | | Some DVB and ATSC captures are using the official MPEG2 registration descriptor in addition to using the correct stream type and the AC-3_audio_stream_descriptor/AC3_descriptor. So let's add it even if it is not strictly needed for DVB/ATSC. Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: support DVB 6A descriptor for AC-3Limin Wang2020-08-23
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>