* commit 'ee37620b6ae4783cda637408422044b2d14a688c':
movenc: Add a flag for indicating a discontinuous fragment
Conflicts:
libavformat/movenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
This allows setting the right fragment number if doing
random-access writing of fragments, and also allows reading the
current sequence number.
Signed-off-by: Martin Storsjö <martin@martin.st>
This allows creating a later mp4 fragment without sequentially
writing the earlier ones before (when called from a segmenter).
Normally when writing a fragmented mp4 file sequentially, the
first timestamps of a fragment are adjusted to match the
end of the previous fragment, to make sure the timestamp is the
same, even if it is calculated as the sum of previous fragment
durations. (And for the first packet in a file, the offset of
the first packet is written using an edit list.)
When writing an individual mp4 fragment discontinuously like this
(with potentially writing the earlier fragments separately later),
there's a risk of getting a gap in the timeline if the duration
field of the last packet in the previous fragment doesn't match up
with the start time of the next fragment.
Using this requires setting -avoid_negative_ts make_non_negative
(or -avoid_negative_ts 0).
Signed-off-by: Martin Storsjö <martin@martin.st>
* commit '40ed1cbf147d09fc0894bee160f0b6b6d9159fc5':
movenc: Allow writing a DASH sidx atom at the start of files
Conflicts:
libavformat/movenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '3847f3ab58b3b74604807394247bf68827258103':
movenc: Add tfra entries for all tracks in a moof
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '2ded57371abead879bcee56da5131e5fac0d17ef':
movenc: Add support for writing sidx atoms for DASH segments
Conflicts:
Changelog
libavformat/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '2d9d6afb8d2f284f5e620ecc19f643d5cd3facb8':
movenc: Factorize adding fragment info into a separate function
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '0f9eb9165bb7d7982fdedf64f6bcec856f1bedd6':
movenc: Include empty tracks in iods when writing fragmented mp4
Merged-by: Michael Niedermayer <michaelni@gmx.at>
This is mapped to the faststart flag (which in this case
perhaps should be called "shift and write index at the
start of the file"), which for fragmented files will
write a sidx index at the start.
When segmenting DASH into files, there's usually one sidx
at the start of each segment (although it's not clear to me
whether that actually is necessary). When storing all of it
in one file, the MPD doesn't necessarily need to describe
the individual segments, but the offsets of the fragments can be
fetched from one large sidx atom at the start of the file. This
allows creating files for the DASH ISO BMFF on-demand profile.
Signed-off-by: Martin Storsjö <martin@martin.st>
Previously only tfra entries were added for the first track in each moof.
The frag_info array used for tfra can also be used for writing
other kinds of fragment indexes, where it's more important to
include all tracks.
When the separate_moof option is enabled (as in ismv), we write
a separate moof for each track, so this doesn't make any difference
in that case.
Signed-off-by: Martin Storsjö <martin@martin.st>
A flag "dash" is added, which enables the necessary flags for
creating DASH compatible fragments.
When this is enabled, one sidx atom is written for each track
before every moof atom.
Signed-off-by: Martin Storsjö <martin@martin.st>
By calling this after writing the moof the first time (for
calculating the moof size), we can avoid intermediate storage
of tfrf_offset in MOVTrack.
Signed-off-by: Martin Storsjö <martin@martin.st>
When writing fragmented streams with an empty initial moov,
we won't have any samples in any tracks when writing the
moov atom, thus trust that any tracks that are added actually
will be present.
Signed-off-by: Martin Storsjö <martin@martin.st>
* commit '8cb7b7b461b52898765b38e3eff68c0ce88347f3':
movenc: Avoid leaking locally allocated data when returning on errors
Conflicts:
libavformat/movenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
This avoids a potential crash if writing a fragmented psp mp4
(which probably is only a hypothetical scenario).
Signed-off-by: Martin Storsjö <martin@martin.st>
* commit '1d8a0c1b43e58332a3a15c67d4adc161713cade8':
movenc: Allow to request not to use edit lists
Conflicts:
libavformat/movenc.c
See: 537ef8bebf
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Previously we wrote decoding timestamps here, while the specs
say it should be presentation timestamps.
Signed-off-by: Martin Storsjö <martin@martin.st>
When using the new first_trun flag instead of checking the track id,
we don't need to have a special case for the separate_moof flag
any longer.
This simplifies the complicated codepath ever so slightly.
Signed-off-by: Martin Storsjö <martin@martin.st>
In this case, shift tracks to start from zero instead (potentially
stretching the first sample in tracks that start later than the
first one).
Some software does not support edit lists at all, the adobe flash
player seems to be one of these. This results in AV sync errors when
edit lists are used to adjust AV sync.
Some players, such as QuickTime, don't respect the duration for
audio packets, so if an audio track starts later than the video
track and the first audio sample gets a duration longer than the
actual amount of data in it, the result will be out of sync.
Based on patches by Michael Niedermayer.
Signed-off-by: Martin Storsjö <martin@martin.st>
* commit '91e8d2eb1f7bf3af949008b106ec1ca037b88b0e':
lavf: use the format context strict_std_compliance instead of the codec one
Conflicts:
libavformat/mux.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'aae6b3b918b4133b8cc2d1631196c1d406d0351a':
movenc: Don't write any iso brands in ismv files
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'c55d1d382cd41345a79782ace41f9b43f45dca9a':
movenc: Don't write any tfdt atom for ismv files
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '00c67fe1d0bc7c2ce49daac9c80ea39d5a663b73':
movenc: Write a 0 duration in mdhd and tkhd for an empty initial moov
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'cf589faa5b7aed3bb38e08dcd00bd951e69686d1':
movenc: Add a flag for using default-base-is-moof in tfhd atoms
Conflicts:
libavformat/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
The tfdt atom shouldn't be needed in those cases, we already
write tfxd atoms for ismv anyway, which is roughly equivalent.
This avoids having to declare the iso6 brand for ismv files.
Signed-off-by: Martin Storsjö <martin@martin.st>
ISO/IEC 14496-12:2012/Cor 1:2013 is explicit about how this should be
handled. All zeros doesn't mean that the full file has got a zero
duration, only that the track samples described within the initial moov
have got zero duration. An all ones duration means an indeterminate
duration.
Keep writing a duration consisting of all ones for the ISM mode -
older windows media player versions won't play a file if this is
zero. (Newer windows media player versions play either version fine.)
Signed-off-by: Martin Storsjö <martin@martin.st>
* commit '600d5ee6b12bad144756b0772319bb04796bc528':
movenc: Signal iso6 in compatible_brands when using tfdt
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'b2b79eca6fae2466a53c5daa163a37e2474364fc':
movenc: Don't check the custom IO flag when using faststart
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '573b1de2d7f1db71030f91ecdded7d0bc071f6b6':
movenc: Don't use track_id to decide which track is the first in a moof
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Similarly to the omit_tfhd_offset flag added in e7bf085b, this
avoids writing absolute byte positions to the file, making them
more easily streamable.
This is a new feature from 14496-12:2012, so application support
isn't necessarily too widespread yet (support for it in libav was
added in 20f95f21f in July 2014).
Signed-off-by: Martin Storsjö <martin@martin.st>
The custom IO flag actually never is set for muxers, only for
demuxers, so the check was pointless (unless a user intentionally
would set the flag to signal using custom IO).
Signed-off-by: Martin Storsjö <martin@martin.st>
If one track doesn't have any samples within a moof, no traf/trun
is written for it. When the omit_tfhd_offset flag is set, none
of the tfhd atoms have any base_data_offset set, and the implicit
offset (end of previous track fragment data, or start of the moof
for the first trun) is used.
Signed-off-by: Martin Storsjö <martin@martin.st>
These allow getting the absolute start timestamp of a fragment
without reading preceding timestamps. This fixes sync between
tracks if starting from fragments in different streams that don't
align exactly.
This also is a prerequisite for producing DASH content.
Signed-off-by: Martin Storsjö <martin@martin.st>
E-AC-3 samples should contain 6 audio blocks, so concatenate syncframes
in order to achieve this.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'e44ee1eb8db7393e9d43207c2e1812720e292e6d':
movenc: Simplify code by using an existing local pointer
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'dad12ce452a9d69c0d9d53c375003947d5f1b02e':
movenc: Print a warning for an unhandled case of nonzero start dts with empty_moov
Conflicts:
libavformat/movenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'dbb472cb2f2f799295a12b4922a6a8be2cccfdee':
movenc: Write edit lists for fragmented files as well, if necessary
Conflicts:
libavformat/movenc.c
The default for writing EDTS for fragmented mp4 is left at disabled
this can be overridden via command line with -use_editlist
but EDTS + fragments still does not fully work, which is why it is
left disabled by default
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '95ee4e2ce774e0339632d067161596bf3dadfc72':
movenc: Add some comments explaining subtle details in writing the edit lists
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '72f801619a1ae91969fee9a7d72519422433c998':
movenc: Adjust edit lists to trim out parts of tracks with negative pts
Conflicts:
libavformat/movenc.c
See: 66b45d8f7a
See: 14fd34d73b
Merged-by: Michael Niedermayer <michaelni@gmx.at>
This is necessary to get the right timestamp offset for content
that starts with dts != 0.
This currently only helps when writing fragmented files with a non-empty
moov atom. When writing an empty moov atom, we don't have any packets
yet, so we don't know the starting dts for the tracks.
Signed-off-by: Martin Storsjö <martin@martin.st>
This makes sure that audio preroll for e.g. AAC is signaled correctly.
Previously we only wrote the edit list correctly if we had negative
dts but started with pts == 0 (e.g. for video with B-frames).
Signed-off-by: Martin Storsjö <martin@martin.st>
Support only one independent substream right now, and only syncframes
containing 6 blocks.
Fixes part of ticket #3074
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* commit '4d55e9de27894ddfb337b28cd7aa6d14a12666d2':
vc1: Split bits used in libavformat into a separate header
Conflicts:
libavformat/movenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
The messages regarding the recommended use of bitstream filters are somewhat different.
This also adds the ":v" stream specifier to "-bsf h264_mp4toannexb".
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'da9cc22d5bd5f59756c2037b02966376da2cf323':
movenc: add track title to tracks
Conflicts:
libavformat/movenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'f90729699db9ede2bef2b28000f1795dab1b8996':
mov: Do not group tracks if more than one is enabled per type
Conflicts:
libavformat/movenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '194be1f43ea391eb986732707435176e579265aa':
lavf: switch to AVStream.time_base as the hint for the muxer timebase
Conflicts:
doc/APIchanges
libavformat/filmstripenc.c
libavformat/movenc.c
libavformat/mxfenc.c
libavformat/oggenc.c
libavformat/swf.h
libavformat/version.h
tests/ref/lavf/mkv
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Previously, AVStream.codec.time_base was used for that purpose, which
was quite confusing for the callers. This change also opens the path for
removing AVStream.codec.
The change in the lavf-mkv test is due to the native timebase (1/1000)
being used instead of the default one (1/90000), so the packets are now
sent to the crc muxer in the same order in which they are demuxed
(previously some of them got reordered because of inexact timestamp
conversion).
* commit 'cf6977712c9e5abe6dc55289f6322ccbf10321a9':
movenc: write avg_frame_rate as the framerate, not the codec timebase
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '0ba5299a805e9ccaef1a757381fc2ada4d54b8a1':
movenc: use the "encoder" metadata tag to write stsd Compressorname
Conflicts:
libavformat/movenc.c
libavformat/movenc.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Use it instead of checking CODEC_FLAG_BITEXACT in the first stream's
codec context.
Using codec options inside lavf is fragile and can easily break when the
muxing codec context is not the encoding context.
Partially undoes commit 2c4e08d893:
riff: always generate a proper WAVEFORMATEX structure in
ff_put_wav_header
A new flag, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX, is added to force the
use of WAVEFORMATEX rather than PCMWAVEFORMAT even for PCM codecs.
This flag is used in the Matroska muxer (the cause of the original
change) and in the ASF muxer, because the specifications for
these formats indicate explicitly that WAVEFORMATEX should be used.
Muxers for other formats will return to the original behavior of writing
PCMWAVEFORMAT when writing a header for raw PCM.
In particular, this causes raw PCM in WAV to generate the canonical
44-byte header expected by some tools.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'cba4e6062a02d5bf684e13a770be88aa1fec717e':
More correct printf format specifiers
Conflicts:
libavcodec/h264_ps.c
libavcodec/h264_refs.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '1e9db41e2a2166be5671b088ef4ad06a40af459f':
movenc: Allow override of major brand in ftyp atom
Conflicts:
libavformat/movenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'b6c61fb83e876d404ac3b0b3657ebfcafdcd1926':
movenc: enable Annex B to MP4 conversion for HEVC tracks.
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '20b40a597cdd4969cf1147d7c7efee2b6232524b':
movenc: write hvcC tag for HEVC.
Conflicts:
libavformat/Makefile
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '565e0c6d866ce08d4b06427456d3d1f4fd856e9c':
movenc: allow override of "writing application" tag
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '1e142d5b4842dcb39fcb0e92e4aacbc9977bfa66':
movenc: Add a fallback fragmentation method for plain mp4 as well
Conflicts:
libavformat/movenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
F4V is Adobe's mp4/iso media variant, with the most significant
addition/change being supporting other flash codecs than just
aac/h264.
Signed-off-by: Martin Storsjö <martin@martin.st>
* commit 'f1eac2b8a0370b908cd691086d11f51342054730':
movenc: Use keyframes as default fragmentation point in ismv
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'a9553bbb336a7186c62b3b14a0499c1b6ba61ebd':
movenc: Set all implicit flags immediately in mov_write_header
Merged-by: Michael Niedermayer <michaelni@gmx.at>