summaryrefslogtreecommitdiff
path: root/libavformat/mpegtsenc.c
Commit message (Collapse)AuthorAge
* 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>
* avformat/mpegtsenc: use local variable store st->codecpar->codec_idLimin Wang2020-07-25
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: reindent the last commitLimin Wang2020-07-25
| | | | | 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-25
| | | | | 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-09
| | | | | 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-31
| | | | | | | 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-28
| | | | | | commit 32aeba12755 missed coding style fix. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/mpegtsenc: cosmeticLimin Wang2020-05-27
| | | | | | | 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-27
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: Remove two duplicated fieldsAndriy Gelman2020-05-14
| | | | | | | 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-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-23
|
* avformat/mpegtsenc: don't print warning for DVB text streamsGyan Doshi2020-04-22
| | | | They can be demuxed by ffmpeg.
* avformat/mpegtsenc: use the correct stream_types and write HDMV descriptors ↵Marton Balint2020-04-21
| | | | | | | | for m2ts Fixes ticket #2622. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: factorize determining stream_typeMarton Balint2020-04-21
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: only allow one program in m2ts modeMarton Balint2020-04-21
| | | | | | The standard does not allow more. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: use standard pids for m2tsMarton Balint2020-04-21
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: warn users if codec isn't supportedGyan Doshi2019-12-23
| | | | | | 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-12
| | | | | | | | | | 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-03
| | | | | | 6144 byte alignment is needed. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: factorize writing packetMarton Balint2019-12-03
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: move around setting m2ts_modeMarton Balint2019-12-03
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: set priority flag for AC3 codecs if writing BluRayMarton Balint2019-12-03
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: allow any sensible PID for elementary and PMT PIDsMarton Balint2019-12-03
| | | | | | | | | | | | | 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-04
| | | | | | | | | fix the logic check error fix #6751 Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/mpegtsenc: fix flushing of audio packetsMarton Balint2019-09-02
| | | | | | | | | | | | | | | | | | | | | | | | 7d097a0fc57f0fa8385962a539c657c2f40b5ed0 had the same purpose as 3700f655c55e2001b57215210b957b169d66b50f but the former is much simpler, so let's remove the latter. Unfortunately both checks were wrong, because in order to make sure DTS > PCR we have to give us some headroom, so instead of using a dts_difference < max_delay check let's use a dts_difference < max_delay/2 check. Fixes DTS < PCR errors with this command line: ./ffmpeg -loglevel verbose -y -f lavfi -i \ "testsrc=s=64x64:d=20,split=2[out0][tmp1];[tmp1]vflip[out1];sine=d=20,asetnsamples=1000[out2]" \ -flags +bitexact -fflags +bitexact -sws_flags +accurate_rnd+bitexact \ -codec:v libx264 -codec:a mp2 -b:a 32k -pix_fmt yuv420p \ -map '0:v:0' \ -map '0:v:1' \ -map '0:a:0' \ -muxrate 800000 \ -program st=0:st=2 -program st=1:st=2 -program st=2 -program st=0 -f mpegts out1.ts Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: get rid of packet counting for sdt/pat/pmtMarton Balint2019-08-23
| | | | | | | | | | | | | The packet counting based approach caused excessive sdt/pat/pmt for VBR, so let's use a timestamp based approach instead similar to how we emit PCRs. SDT/PAT/PMT period should be consistent for both VBR and CBR from now on. Also change the type of sdt_period and pat_period to AV_OPT_TYPE_DURATION so no floating point math is necessary. Fixes ticket #3714. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: move some code around and simplify a bitMarton Balint2019-08-23
| | | | | | | PCR does not need to be recalcualted for CBR when inserting a NULL or PCR only packet. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: add support for setting PCR interval for VBR streamsMarton Balint2019-08-23
| | | | | | | | Also document the algorithm for the default PCR interval. Fixes ticket #8061. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: rename pcr_period variable to pcr_period_msMarton Balint2019-08-23
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: remove deprecated resend_headers optionMarton Balint2019-08-14
| | | | | | Deprecated since 2014. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: fix PCR generation intervalsMarton Balint2019-08-14
| | | | | | | | | | | | | | | | | | | | | | | | PCR generation was based on counting packets for both CBR and VBR streams. Couting packets might have worked for CBR streams (when muxrate was specified) but it only took into account the packets of a service (or the packets of the PCR stream lately), so even that was problematic for multi program streams. The new code works on actual timestamps for both CBR and VBR streams. For VBR streams the behaviour of the old code is simulated by selecting a PCR interval which is the highest multiple of the frame duration but still less than 100 ms. It should be trivial to add support for setting the PCR interval for VBR streams as well in a later patch. The accuracy of PCR packets for CBR streams was greatly improved by preemtively sending them at PCR intervals even if sending the payload of another stream is in progress. This may fix these tickets: - #5750 - #7524 Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: use increasing numbers in default service namesMarton Balint2019-08-14
| | | | | | Maybe we should use service ID instead of increasing numbers? Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: remove section_write_packet forward declarationMarton Balint2019-08-14
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: factorize setting up servicesMarton Balint2019-08-14
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: fix incorrect PCR selection with multiple programsMarton Balint2019-08-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MPEG-TS muxer had a serious bug related to the use of multiple programs: in that case, the PCR pid selection was incomplete for all services except one. This patch solves this problem and selects a stream to become PCR for each service, preferably the video stream. This patch also moves pcr calculation attributes to MpegTSWriteStream from MpegTSService. PCR is a per-stream and not per-service thing, so it was misleading to refer to it as something that is per-service. Also remove *service from MpegTSWriteStream because a stream can belong to multiple services so it was misleading to select one for each stream. You can check the result with this example command: ./ffmpeg -loglevel verbose -y -f lavfi -i \ "testsrc=s=64x64:d=10,split=2[out0][tmp1];[tmp1]vflip[out1];sine=d=10,asetnsamples=1152[out2]" \ -flags +bitexact -fflags +bitexact -sws_flags +accurate_rnd+bitexact \ -codec:v libx264 -codec:a mp2 -pix_fmt yuv420p \ -map '0:v:0' \ -map '0:v:1' \ -map '0:a:0' \ -program st=0:st=2 -program st=1:st=2 -program st=2 -program st=0 -f mpegts out.ts You should now see this: [mpegts @ 0x37505c0] service 1 using PCR in pid=256 [mpegts @ 0x37505c0] service 2 using PCR in pid=257 [mpegts @ 0x37505c0] service 3 using PCR in pid=258 [mpegts @ 0x37505c0] service 4 using PCR in pid=256 Fixes ticket #8039. v2: a video is stream is preferred if there are no programs, just like before the patch. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: write format_identifier HEVC for HEVC streamsMarton Balint2019-03-01
| | | | | | | | | | | | | This improves compatibility with some consumer (LG WebOS) TVs which apparently search a HEVC descriptor (which our mpegts muxer can't generate) or a format identifier. Since the HEVC format identifier is not registered (but used in the wild), it is not written if strict_std_compliance is higher than normal. This fixes the issue in ticket #7744. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: factorize writing registration_descriptorMarton Balint2019-03-01
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegtsenc: add support for service and provider names with utf8 ↵Marton Balint2019-02-21
| | | | | | encoding Signed-off-by: Marton Balint <cus@passwd.hu>
* Fix bug in mpegts muxer which affects KLV async stream generation.Artyom Lebedev2018-12-08
| | | | | | Fixes ticket #7597. Signed-off-by: Peter Ross <pross@xvid.org>
* avformat/mpegtsenc: set AVFMT_NODIMENSIONSAman Gupta2018-05-12
| | | | | | | | | This allows remuxing streams from one mpegts container to another, without requiring avformat_find_stream_info() (or using `ffmpeg -probesize 32` on the cli). Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>