1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

356 Commits

Author SHA1 Message Date
Brad Hards
fb819697f6 avformat/mpegts: add constants for MPEG-TS transport stream identifiers
Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-06-09 01:01:28 +02:00
Brad Hards
b8d6d9376c avformat/mpegtsenc: set stream_id correctly based on KLV profile selected
Previously we always set STREAM_TYPE_PRIVATE_DATA, and that remains
the default value.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-31 18:43:02 +02:00
Jun Zhao
ab42db9bed lavf/mpegtsenc: misc style fixes
commit 32aeba1275 missed coding style fix.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-05-28 15:56:21 +08:00
Limin Wang
0cc2d09e17 avformat/mpegtsenc: cosmetic
Merge the short lines after the last commit

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-27 21:14:27 +08:00
Limin Wang
f1035b99fa avformat/mpegtsenc: simplify code by using OFFSET() and ENC macros
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-27 21:14:26 +08:00
Andriy Gelman
0776cb7083 avformat/mpegtsenc: Remove two duplicated fields
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>
2020-05-14 09:53:59 -04:00
Andriy Gelman
1dd0def976 avformat/mpegtsenc: Don't use heap allocated array to store pids
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>
2020-05-14 09:53:55 -04:00
Gyan Doshi
fc8a239e9d avformat/mpegtsenc: use av_log_once for data stream warning 2020-04-23 11:31:35 +05:30
Gyan Doshi
68d9c0be89 avformat/mpegtsenc: don't print warning for DVB text streams
They can be demuxed by ffmpeg.
2020-04-22 16:07:04 +05:30
Marton Balint
7f2649bb46 avformat/mpegtsenc: use the correct stream_types and write HDMV descriptors for m2ts
Fixes ticket #2622.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-21 21:28:42 +02:00
Marton Balint
3958244c91 avformat/mpegtsenc: factorize determining stream_type
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-21 21:28:29 +02:00
Marton Balint
bcc19933af avformat/mpegtsenc: only allow one program in m2ts mode
The standard does not allow more.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-21 21:28:29 +02:00
Marton Balint
422f0a6136 avformat/mpegtsenc: use standard pids for m2ts
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-21 21:28:29 +02:00
Gyan Doshi
f0b3b55002 avformat/mpegtsenc: warn users if codec isn't supported
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.
2019-12-23 21:06:37 +05:30
Andreas Rheinhardt
c1e439d7e9 avformat: Forward errors where possible
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>
2019-12-12 19:25:33 +01:00
Marton Balint
1e0ea36945 avformat/mpegtsenc: add padding to m2ts streams
6144 byte alignment is needed.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-12-03 11:00:11 +01:00
Marton Balint
998906a0a4 avformat/mpegtsenc: factorize writing packet
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-12-03 11:00:11 +01:00
Marton Balint
db63db3977 avformat/mpegtsenc: move around setting m2ts_mode
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-12-03 11:00:11 +01:00
Marton Balint
565dc3e451 avformat/mpegtsenc: set priority flag for AC3 codecs if writing BluRay
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-12-03 11:00:11 +01:00
Marton Balint
f5b83d5419 avformat/mpegtsenc: allow any sensible PID for elementary and PMT PIDs
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>
2019-12-03 11:00:10 +01:00
Jun Zhao
8f7a043609 lavf/mpegtsenc: fix logic check error
fix the logic check error

fix #6751

Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-11-04 10:22:11 +08:00
Marton Balint
f4eb7d84a7 avformat/mpegtsenc: fix flushing of audio packets
7d097a0fc5 had the same purpose as
3700f655c5 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✌️0' \
  -map '0✌️1' \
  -map '0🅰️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>
2019-09-02 21:44:25 +02:00
Marton Balint
2fb550893f avformat/mpegtsenc: get rid of packet counting for sdt/pat/pmt
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>
2019-08-23 22:49:01 +02:00
Marton Balint
5c119bf189 avformat/mpegtsenc: move some code around and simplify a bit
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>
2019-08-23 22:49:01 +02:00
Marton Balint
8bf732cda6 avformat/mpegtsenc: add support for setting PCR interval for VBR streams
Also document the algorithm for the default PCR interval.

Fixes ticket #8061.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-08-23 22:49:01 +02:00
Marton Balint
6f499ae390 avformat/mpegtsenc: rename pcr_period variable to pcr_period_ms
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-08-23 22:49:01 +02:00
Marton Balint
5974463767 avformat/mpegtsenc: remove deprecated resend_headers option
Deprecated since 2014.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-08-14 23:25:28 +02:00
Marton Balint
88ac76be79 avformat/mpegtsenc: fix PCR generation intervals
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>
2019-08-14 23:24:11 +02:00
Marton Balint
a4d984ad33 avformat/mpegtsenc: use increasing numbers in default service names
Maybe we should use service ID instead of increasing numbers?

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-08-14 22:50:11 +02:00
Marton Balint
9de40bf624 avformat/mpegtsenc: remove section_write_packet forward declaration
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-08-14 22:50:11 +02:00
Marton Balint
47ea654bd8 avformat/mpegtsenc: factorize setting up services
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-08-14 22:50:11 +02:00
Marton Balint
d770e0f401 avformat/mpegtsenc: fix incorrect PCR selection with multiple programs
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✌️0' \
  -map '0✌️1' \
  -map '0🅰️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>
2019-08-14 22:50:11 +02:00
Marton Balint
837f2c9798 avformat/mpegtsenc: write format_identifier HEVC for HEVC streams
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>
2019-03-01 22:30:13 +01:00
Marton Balint
fe36dcbff2 avformat/mpegtsenc: factorize writing registration_descriptor
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-03-01 22:30:13 +01:00
Marton Balint
5adc4a98b3 avformat/mpegtsenc: add support for service and provider names with utf8 encoding
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-02-21 21:29:06 +01:00
Artyom Lebedev
6b1c4ce8cf Fix bug in mpegts muxer which affects KLV async stream generation.
Fixes ticket #7597.

Signed-off-by: Peter Ross <pross@xvid.org>
2018-12-08 11:06:10 +11:00
Aman Gupta
6f50be8760 avformat/mpegtsenc: set AVFMT_NODIMENSIONS
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>
2018-05-12 11:48:39 -07:00
Marton Balint
18ac642359 avformat: migrate to AVFormatContext->url
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-01-28 23:06:43 +01:00
Derek Buitenhuis
fde9013ab4 mpegtsenc: Don't pass NULL to memcpy
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2017-07-06 21:28:20 -04:00
Clément Bœsch
549045254c Fix all -Wformat warnings raised by DJGPP 2017-03-29 14:49:29 +02:00
Lou Logan
e7282674a5 lavf/mpegtsenc: clarify pcr_period unit of measurement
pcr_period is in milliseconds.

Signed-off-by: Lou Logan <lou@lrcd.com>
2017-03-16 11:35:41 -08:00
Michael Niedermayer
b05d8e7184 libavformat/mpegtsenc: support hevc with missing in stream headers like h.264
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-01-17 20:36:34 +01:00
Stefano Sabatini
755472124f lavf/mpegtsenc: write metadata descriptor for timed ID3 packets
This is required since some programs are not able to correctly recognize
the metadata. See H.222, 2.6.58 Metadata pointer descriptor.

putstr8() is modified in order to allow to skip writing the string
length.
2016-11-06 12:36:51 +01:00
Stefano Sabatini
9ccdf04bd0 lavf/mpegtsenc: move putstr8 definition up
This allows to use the function in a future commit.
2016-11-06 12:36:43 +01:00
Michael Niedermayer
a566c952f9 avformat/mpegtsenc: Add option to mark stream begin as discontinuous
This avoids continuity check failures in concatenated streams

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-11-02 16:34:01 +01:00
Rodger Combs
14fe54bbfb
lavf/mpegtsenc: fix autobsf when the first NAL is 0x1<XX> bytes 2016-10-04 01:20:20 -05:00
Sylvain Laurent
58776ccbdb lavf/mpegtsenc: Set min PID for data pkt to 0x0010.
Fixes ticket #1673.
2016-09-28 17:29:11 +02:00
Stefano Sabatini
156b5bb9bf lavf/mpegtsenc: add special case for handling timed ID3 packets
Set the stream_id to 0xbd (private_stream_id_1). Tools seem to assume
that value, and this is consistent with MPEG TS specification (ITU-T
H.222.0 section 2.12.3).
2016-07-29 08:47:41 +02:00
Clément Bœsch
c0ff42bf64 Merge commit '393596f9d51134d6e45d81ae129223f4faea1232'
* commit '393596f9d51134d6e45d81ae129223f4faea1232':
  mpegtsenc: stop impersonating ses in sdt

This commit also includes the needed FATE updates later spotted by
Martin Storsjö and fixed in 34effe816f on
Libav side.

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-23 08:17:31 +02:00
Clément Bœsch
8ef57a0d61 Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb':
  cosmetics: Fix spelling mistakes

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +02:00