Commit Graph

20991 Commits

Author SHA1 Message Date
Marton Balint d48fb904fa avformat/mxfdec: remove check for NULL MXFTrack in mxf_set_pts
It cannot happen for video streams.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-08 23:20:27 +02:00
Marton Balint 5d3f78383e avformat/mxfdec: only disallow seek on metadata streams
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-08 23:20:27 +02:00
Marton Balint f9e77586cb avformat/mxfdec: recognize SMPTE 436 VBI data
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-08 23:20:27 +02:00
Marton Balint 183db8a80b avformat/mxfdec: use MXFCodecUL struct to store essence description for data_essence_container_uls
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-08 23:20:27 +02:00
Sasi Inguva fe6c4f0c47 lavf/mov.c: Set st->start_time for video streams explicitly.
If start_time is not set, ffmpeg takes the duration from the global
movie instead of the per stream duration.
Signed-off-by: Sasi Inguva <isasi@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-06-06 01:53:30 +02:00
Sasi Inguva 318d0fcbfe lavf/mov.c: Fix timestamps to be strictly monotonic for video also.
We already do this for audio, but it should be done for video too.
If we don't, seeking back to the start of the file, for example, can
become quite broken, since the first N packets will have repeating
and nonmonotonic PTS, yet they need to be decoded even if they are
to be discarded.

Signed-off-by: Sasi Inguva <isasi@isasi.mtv.corp.google.com>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2018-06-05 16:00:19 +01:00
Jacob Trimble 9827bb88e7 libavformat/mov: Fix heap buffer overflow.
Found by Chrome's ClusterFuzz: https://crbug.com/847060

Signed-off-by: Jacob Trimble <modmaker@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-06-02 01:55:12 +02:00
Marton Balint 1616b1be5a avformat/mxfdec: add some missing picture_essence_container_uls
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-05-30 23:02:59 +02:00
Marton Balint e7498792b6 avformat/mxfdec: use int math for sample count calculation
This also changes the rounding to nearest.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-05-30 23:02:59 +02:00
Marton Balint f932e49aab avformat/mxfdec: fix klv_decode_ber_length return value usage
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-05-30 23:02:59 +02:00
Alex Converse ea0010bf9c flvenc: Fix sequence header update timestamps 2018-05-29 22:14:13 -07:00
Alex Converse 4d3dd167df flvenc: Factorize timestamp writing
The code is trivial but the semantics in the spec are ambiguous. This
should help keep parts of the muxer interpreting them consistently.
2018-05-29 22:14:12 -07:00
Vishwanath Dixit 5717cd80dc avformat/movenc: creating producer reference time (PRFT) box
The producer reference time box supplies relative wall-clock times
at which movie fragments, or files containing movie fragments
(such as segments) were produced.
The box is mainly useful in live streaming use cases. A media player
can parse the box and utilize the time fields to measure and improve
the latency during real time playout.
2018-05-29 09:32:11 +05:30
Vishwanath Dixit f09635f2a2 avformat/utils: function to get the formatted ntp time
This utility function creates 64-bit NTP time format as per the RFC
5905.
A simple explaination of 64-bit NTP time format is here
http://www.beaglesoft.com/Manual/page53.htm
2018-05-29 09:31:29 +05:30
Jan Ekström 26892c7615 lavf/libssh: translate a read of 0 to EOF
Yet another case of forgotten 0 =! EOF translation.

While the documentation for this specific synchronous read
function does not mention it, the documentation for
`sftp_async_read` documents it, as well as looking at the
implementation of this function leads one to find
`if (handle->eof) { return 0; }`.

Reported by stnutt on IRC.
2018-05-28 20:33:50 +03:00
Karthick Jeyapal ebf85d3190 avformat/dashenc: Added a warning for incorrect segment name extension
Applicable only to webm output format.
By default all the segment filenames end with .m4s extension.
When someone chooses webm output format, we recommend they also override the relevant segment name options to end with .webm extension. This patch will issue a warning for he same
2018-05-28 10:52:07 +05:30
Karthick Jeyapal 2efdbf7367 avformat/dashenc: Added option for Segment file format
Right now segment file format is chosen to be either mp4 or webm based on the codec format.
This patch makes that choice configurable by the user, instead of being decided by the muxer.

Also with this change per-stream choice segment file format(based on codec type) is not possible.
All the output audio and video streams should be in the same file format.
2018-05-28 10:52:01 +05:30
Michael Niedermayer df3d962d2e libavformat/mxfenc: Add some () to attempt to workaround build issue on osx
fixes ticket7209

Tested-by: Jim DeLaHunt <from.ffmpeg-dev@jdlh.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-27 21:38:33 +02:00
Marton Balint 2b05981312 avformat/mxf: fix NTSC 59.94 samples per frame layout
FFmbc uses this.
bmx uses this.
XAVC MXF Mapping and Operating Points prefers this.
Basic rounding rules also yields these numbers.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-05-27 19:55:09 +02:00
Carl Eugen Hoyos 42b4351333 lavf/img2dec: Auto-detect xwd images. 2018-05-25 20:06:34 +02:00
Steven Liu 50df4c958b avformat/hlsenc: support http method for hls fmp4
fix ticket: 7160

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2018-05-24 11:55:58 +08:00
Steven Liu 04b6060616 avformat/dashdec: replace user-agent to user_agent for deprecate warning message 2018-05-24 11:49:04 +08:00
Colin NG 93fc96e199 avformat/dashdec: Fix for ticket 7149 (Segfault when decoding dash streams)
simplify the code to check common init section
2018-05-24 11:49:00 +08:00
Colin NG 9aee574dd0 avformat/dashdec: Fix for ticket 7149 (Segfault when decoding dash streams)
Add NULL pointer check for init_section
2018-05-24 11:48:39 +08:00
Michael Niedermayer fe84f70819 avformat/mov: replace a value error by clipping into valid range in mov_read_stsc()
Fixes: #7165

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-22 21:05:45 +02:00
Michael Niedermayer 919e37377a avformat/bintext: Reduce detection for random .bin files as it more likely is not a multimedia related file
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-22 21:05:45 +02:00
Thomas Volkert c24d247e2c libavformat: add mbedTLS based TLS
Signed-off-by: James Almer <jamrial@gmail.com>
2018-05-21 19:43:04 -03:00
Aman Gupta 70d25268c2 avformat/mpegts: fix memory leak with merge_pmt_versions=1
Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-21 12:16:06 -07:00
Aman Gupta 64680fff3b avformat/mpegts: rename variable to clarify meaning
Both stream_id and stream_identifier are used in this file,
and have different meanings. The latter comes from the
stream_identifier_descriptor.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-21 12:13:14 -07:00
Michael Niedermayer 2c2d689c56 avformat/mov: Only fail for STCO/STSC contradictions if both exist
Fixes regression with playback of GF9720Repeal20the20Eighth20with20Helen20Linehan.m4a
See: crbug 822666

Found-by: "Mattias Wadman <mattias.wadman@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-21 01:50:21 +02:00
Michael Niedermayer 56e76bd057 avformat/mov: Break out early if chunk_count is 0 in mov_build_index()
Without this some operations might overflow (undefined behavior)
even though the index adding loop would never execute

No testcase known

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-21 01:38:56 +02:00
Michael Niedermayer cadf7a7f39 avformat/mp3dec: require 90% of a file to be mp3 if only 1 mp3 frame is found in sequence
This eliminates several low score detections of non mp3 files

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-20 13:17:36 +02:00
Michael Niedermayer 81b3e7c9c3 avformat/mp3dec: Require 50% of the file to be mp3 frames in the maxframes>200 probing test
This corrects several misdetections of large files

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-20 13:17:36 +02:00
Michael Niedermayer 60d1792779 avformat/mp3dec: Require probing data to be 50% mp3 frames for low score probing to succeed
This massively reduces the detection of random data as low score mp3
It may improve security by making it harder to read non multimedia data

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-20 13:17:36 +02:00
Aman Gupta 16b4f97b72 avformat/mpegts: add merge_pmt_versions option
This new optional flag makes it easier to deal with mpegts
samples where the PMT is updated and elementary streams move
to different PIDs in the middle of playback.

Previously, new AVStreams were created per PID, and it was up
to the user to figure out which streams had migrated to a new PID
(by iterating over the list of AVProgram and making guesses), and
switch seamlessly to the new AVStream during playback.

Transcoding or remuxing these streams with ffmpeg on the CLI was
also quite painful, and the user would need to extract each set
of PIDs into a separate file and then stitch them back together.

With this new option, the mpegts demuxer will automatically detect
PMT changes and feed data from the new PID to the original AVStream
that was created for the orignal PID. For mpegts samples with
stream_identifier_descriptor available, the unique ID is used to
merge PIDs together. If the stream id is not available, the demuxer
attempts to map PIDs based on their position within the PMT.

With this change, I am able to playback and transcode/remux these
two samples which previously caused issues:

    https://tmm1.s3.amazonaws.com/pmt-version-change.ts
    https://kuroko.fushizen.eu/videos/pid_switch_sample.ts

I also have another longer sample in which the PMT changes
repeatedly and ES streams move to different pids three times
during playback:

    https://tmm1.s3.amazonaws.com/multiple-pmt-change.ts

Demuxing this sample with the new option shows several new log
messages as the PMT changes are handled:

    [mpegts] detected PMT change (program=1, version=3/6, pcr_pid=0xf98/0xfb7)
    [mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xfb7
    [mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xfb8
    [mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xfb9
    [mpegts] detected PMT change (program=1, version=6/3, pcr_pid=0xfb7/0xf98)
    [mpegts] detected PMT change (program=1, version=3/4, pcr_pid=0xf98/0xf9b)
    [mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xf9b
    [mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xf9c
    [mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xf9d
    [mpegts] detected PMT change (program=1, version=4/5, pcr_pid=0xf9b/0xfa9)
    [mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xfa9
    [mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xfaa
    [mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xfab
    [mpegts] detected PMT change (program=1, version=5/6, pcr_pid=0xfa9/0xfb7)

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-18 19:00:29 -07:00
Aman Gupta 24579bf537 avformat/mpegts: keep track of PMT details in AVProgram/AVStream
With these fields, the user has enough information to
detect PMT changes and switch to new streams when the PMT
is updated with new ES pids.

To do so, the user would monitor the AVProgram they're interested
in for changes to pmt_version. If the version changes, they would
iterate over the program's streams to find new streams added with
the updated version number.

If new versions of streams are found, then the user would first try
to replace existing streams where stream_identifier matched.
If stream_identifier is not available, then the user would compare
pmt_stream_idx instead to replace the stream that was previously
at the same position within the PMT.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-18 19:00:29 -07:00
Aman Gupta 2b2f2f65f3 avformat: add fields to AVProgram/AVStream for PMT change tracking
These fields will allow the mpegts demuxer to expose details about
the PMT/program which created the AVProgram and its AVStreams.

In mpegts, a PMT which advertises streams has a version number
which can be incremented at any time. When the version changes,
the pids which correspond to each of it's streams can also change.

Since ffmpeg creates a new AVStream per pid by default, an API user
needs the ability to (a) detect when the PMT changed, and (b) tell
which AVStream were added to replace earlier streams.

This has been a long-standing issue with ffmpeg's handling of mpegts
streams with PMT changes, and I found two related patches in the wild
that attempt to solve the same problem:

The first is in MythTV's ffmpeg fork, where they added a
void (*streams_changed)(void*); to AVFormatContext and call it from
their fork of the mpegts demuxer whenever the PMT changes.

The second was proposed by XBMC in
https://ffmpeg.org/pipermail/ffmpeg-devel/2012-December/135036.html,
where they created a new AVMEDIA_TYPE_DATA stream with id=0 and
attempted to send packets to it whenever the PMT changed.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-18 19:00:29 -07:00
Aman Gupta e24d768a76 avformat/mpegts: add skip_unknown_pmt option
Some filtered mpegts streams may erroneously include PMTs for
programs that are not advertised in the PAT. This confuses ffmpeg
and most players because multiple audio/video streams are created
and it is unclear which ones actually contain data.

See for example https://tmm1.s3.amazonaws.com/unknown-pmts.ts

In this sample, the PAT advertises exactly one program. But the
pid it points to for the program's PMT contains PMTs for other
programs as well. This is because the broadcaster decided to
re-use the same pid for multiple program PMTs.

The hardware that filtered the original multi-program stream
into a single-program stream did so by rewriting the PAT to
contain only the program that was requested. But since it just
passed through the PMT pid referenced in the PAT, multiple PMTs
are still present for the other programs.

Before:

    Input #0, mpegts, from 'unknown-pmts.ts':
      Duration: 00:00:10.11, start: 80741.189700, bitrate: 9655 kb/s
      Program 4
        Stream #0:2[0x41]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 11063 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
        Stream #0:3[0x44](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
        Stream #0:4[0x45](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 128 kb/s
      No Program
        Stream #0:0[0x31]: Video: mpeg2video ([2][0][0][0] / 0x0002), none(tv), 90k tbr, 90k tbn, 90k tbc
        Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 0 channels, fltp
        Stream #0:5[0x51]: Video: mpeg2video ([2][0][0][0] / 0x0002), none, 90k tbr, 90k tbn
        Stream #0:6[0x54](eng): Audio: ac3 (AC-3 / 0x332D4341), 0 channels

With skip_unknown_pmt=1:

    Input #0, mpegts, from 'unknown-pmts.ts':
      Duration: 00:00:10.11, start: 80741.189700, bitrate: 9655 kb/s
      Program 4
        Stream #0:0[0x41]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 11063 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
        Stream #0:1[0x44](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
        Stream #0:2[0x45](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 128 kb/s

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-18 12:04:57 -07:00
Aman Gupta 5dfeb7f081 avformat/mpegts: tag video streams with still images
Parses the video_stream_descriptor (H.222 2.6.2) to look
for the still_picture_flag. This is exposed to the user
via a new AV_DISPOSITION_STILL_IMAGE.

See for example https://tmm1.s3.amazonaws.com/music-choice.ts,
whose video stream only updates every ~6 seconds.

Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-17 12:03:22 -07:00
Aman Gupta 2734f8d63a avformat: add skip_estimate_duration_from_pts
For seekable mpegts streams, duration is calculated from
pts by seeking to the end of the file for a pts and subtracting
the initial pts to compute a duration.

This can be expensive in terms of added latency during
probe, especially when streaming over a network. This new
option lets you skip the duration calculation, which is useful
when you don't care about the value and want to save some overhead.

This patch is particularly useful when dealing with live mpegts
streams. Normally such streams are not seekable, so durations
are not calculated. However in my case I am dealing with a seekable
live mpegts stream (networked access to a .ts file which is still
being appended to).

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-17 11:33:01 -07:00
Aman Gupta 673d8cfd51 avformat/hls: fix seeking around EVENT playlist after media sequence changes
The seek functions use first_timestamp, so keep that up to date as
old segments drop off the playlist.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-16 10:19:34 -07:00
Marton Balint 2dbe936bf7 avformat/webm_chunk: always use a static buffer for get_chunk_filename
My conversation from AVFormatContext->filename to AVFormatContext->url was
wrong in this case because get_chunk_filename uses filename as an output
buffer, and not as an input buffer.

Fixes ticket #7188.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-05-15 22:18:58 +02:00
Aman Gupta 64bf915cd8 avformat/mpegts: fix incorrect indentation
Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-15 11:47:30 -07:00
Vishwanath Dixit e3518821c9 avformat/dashenc: configuring container format options 2018-05-15 11:13:36 +05:30
Aman Gupta 42a03e7700 avformat/mpegts: initialize section_buf to fix valgrind test failure
http://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-valgrind&time=20180513001958

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-14 10:26:13 -07:00
Aman Gupta 7db022e67b avformat/mpegts: reindent after last change
Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-12 11:50:16 -07:00
Aman Gupta 9152c1e495 avformat/mpegts: parse sections with multiple tables
Fixes PMT parsing in some mpegts streams which contain
multiple tables within the PMT pid. Previously, the parser
assumed only one table was present in each packet, and discarded
the rest of the section data after attempting to parse the first
table.

A similar issue was documented in the BeyondTV software[1], which
helped me diagnose the same bug in the ffmpeg mpegts demuxer. I also
tried DVBInspector, libdvbpsi's dvbinfo, and tstools' tsinfo to
help debug. The former two properly read PMTs with multiple tables,
whereas the last has the same bug as ffmpeg.

I've created a minimal sample[2] which contains the combined PMT.
Here's what ffmpeg probe shows before and after this patch:

Before:

    Input #0, mpegts, from 'combined-pmt-tids.ts':
      Duration: 00:00:01.08, start: 4932.966167, bitrate: 741 kb/s
      Program 1
      No Program
        Stream #0:0[0xf9d]: Audio: ac3, 48000 Hz, mono, fltp, 96 kb/s
        Stream #0:1[0xf9b]: Audio: mp3, 0 channels, fltp
        Stream #0:2[0xf9c]: Unknown: none

After:

    Input #0, mpegts, from 'combined-pmt-tids.ts':
      Duration: 00:00:01.11, start: 4932.966167, bitrate: 718 kb/s
      Program 1
        Stream #0:0[0xf9b]: Video: mpeg2video ([2][0][0][0] / 0x0002), none(tv, top first), 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
        Stream #0:1[0xf9c](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
        Stream #0:2[0xf9d](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, mono, fltp, 96 kb/s

With the patch, the PMT is parsed correctly so the streams are
created in the correct order, are associated with "Program 1",
and their codecs are set correctly.

[1] http://forums.snapstream.com/vb/showpost.php?p=343816&postcount=201
[2] https://s3.amazonaws.com/tmm1/combined-pmt-tids.ts

Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-12 11:50:00 -07:00
Aman Gupta 18074b309f avformat/hlsenc: set AVFMT_NODIMENSIONS
Same as previous commit but for mpegts inside HLS.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-12 11:48:46 -07: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
Michael Niedermayer 10ca419dd8 avformat/mxfenc: Set color siting to 0 for D10-MXF
SMPTE 386M (D-10) lists 4 as value to be used
SMPTE 377-1-2009 says
    "The definitions of 00h (coSiting) and 04h (Rec 601) are equivalent. The value of 04h is deprecated. New
     MXF encoders shall use the value of 00h instead."

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-12 01:08:01 +02:00