summaryrefslogtreecommitdiff
path: root/libavformat/mpegtsenc.c
Commit message (Collapse)AuthorAgeFilesLines
* avformat/mpegtsenc: Avoid allocation of AVPacketAndreas Rheinhardt2021-11-271-5/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: Add AVStream parameter to check_bitstream() sigAndreas Rheinhardt2021-11-271-2/+2
| | | | | | | | | | 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-061-1/+2
| | | | | | | | | | | | | | | 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-061-5/+5
| | | | | | | | | | | | | | | 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-201-0/+3
| | | | | | | 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-201-0/+3
| | | | | | | | 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-191-0/+3
| | | | | | | | 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-101-0/+48
| | | | | | | | 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-201-7/+97
| | | | | | | | | | | | | 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-281-90/+90
| | | | | | | 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-281-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-281-25/+35
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: move is_dvb_subtitle/is_dvb_teletext initialization upwardsMarton Balint2021-04-281-10/+3
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: Constify all muxer/demuxersAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | 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-271-2/+2
| | | | | | | 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-051-9/+8
| | | | | | | 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-171-6/+13
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: use the buffer_size_t typedef where requiredJames Almer2021-03-101-2/+2
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mpegtsenc: check that not only first pts but also first dts is validLimin Wang2020-10-301-4/+4
| | | | | 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-301-4/+3
| | | | | | | 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-271-0/+6
| | | | | | | | | | | | | 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-271-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-161-3/+3
| | | | | | | | 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-261-18/+18
| | | | | 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-261-0/+4
| | | | | | | | | | 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-231-2/+82
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: use local variable store st->codecpar->codec_idLimin Wang2020-07-251-8/+9
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: reindent the last commitLimin Wang2020-07-251-10/+9
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: simplify code for condition checksLimin Wang2020-07-251-2/+4
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegts: add constants for MPEG-TS transport stream identifiersBrad Hards2020-06-091-8/+8
| | | | | Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: set stream_id correctly based on KLV profile selectedBrad Hards2020-05-311-0/+7
| | | | | | | Previously we always set STREAM_TYPE_PRIVATE_DATA, and that remains the default value. Signed-off-by: Marton Balint <cus@passwd.hu>
* lavf/mpegtsenc: misc style fixesJun Zhao2020-05-281-12/+12
| | | | | | commit 32aeba12755 missed coding style fix. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/mpegtsenc: cosmeticLimin Wang2020-05-271-63/+29
| | | | | | | Merge the short lines after the last commit Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: simplify code by using OFFSET() and ENC macrosLimin Wang2020-05-271-45/+47
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: Remove two duplicated fieldsAndriy Gelman2020-05-141-7/+3
| | | | | | | ts->{tsid,onid} stores the values of ts->{transport_stream_id,original_network_id} Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avformat/mpegtsenc: Don't use heap allocated array to store pidsAndriy Gelman2020-05-141-37/+14
| | | | | | | | | | A temporary heap array currently stores pids from all streams. It is used to make sure there are no duplicated pids. However, this array is not needed because the pids from past streams are stored in the MpegTSWriteStream structs. Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avformat/mpegtsenc: use av_log_once for data stream warningGyan Doshi2020-04-231-4/+11
|
* avformat/mpegtsenc: don't print warning for DVB text streamsGyan Doshi2020-04-221-0/+4
| | | | They can be demuxed by ffmpeg.
* avformat/mpegtsenc: use the correct stream_types and write HDMV descriptors ↵Marton Balint2020-04-211-1/+57
| | | | | | | | for m2ts Fixes ticket #2622. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: factorize determining stream_typeMarton Balint2020-04-211-68/+79
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: only allow one program in m2ts modeMarton Balint2020-04-211-1/+6
| | | | | | The standard does not allow more. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: use standard pids for m2tsMarton Balint2020-04-211-1/+43
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: warn users if codec isn't supportedGyan Doshi2019-12-231-0/+2
| | | | | | The MPEG-TS muxer will mux streams with unsupported codec id as a private data stream; this usually makes the stream not recognizable by ffmpeg and likely other tools.
* avformat: Forward errors where possibleAndreas Rheinhardt2019-12-121-1/+1
| | | | | | | | | | It is not uncommon to find code where the caller thinks to know better what the return value should be than the callee. E.g. something like "if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM);". This commit changes several instances of this to instead forward the actual error. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegtsenc: add padding to m2ts streamsMarton Balint2019-12-031-0/+7
| | | | | | 6144 byte alignment is needed. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: factorize writing packetMarton Balint2019-12-031-9/+6
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: move around setting m2ts_modeMarton Balint2019-12-031-8/+8
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: set priority flag for AC3 codecs if writing BluRayMarton Balint2019-12-031-0/+2
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: allow any sensible PID for elementary and PMT PIDsMarton Balint2019-12-031-5/+12
| | | | | | | | | | | | | This sets the range of the first automatically assigned PMT PID or elementary stream PID parameters to [0x20, 0x1ffa]. You can still assign manually a PID for a stream using AVStream->id in the wider [0x10, 0x1ffe] range as specified by ISO13818-1. But since DVB and ATSC both reserves some PIDs, let's not allow them to be automatically assigned. Also make sure that assigned PID numbers are valid and fix the error message for the previous PID collision checks. Signed-off-by: Marton Balint <cus@passwd.hu>
* lavf/mpegtsenc: fix logic check errorJun Zhao2019-11-041-1/+1
| | | | | | | | | fix the logic check error fix #6751 Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>