Commit Graph

528 Commits

Author SHA1 Message Date
wm4 022d4a2114 avformat/matroskaenc: do not write timebase as framerate
If the API user doesn't set avg_frame_rate, matroskaenc will write the
current timebase as "default duration" for the video track. This makes
no sense, because the "default duration" implies the framerate of the
video. Since the timebase is forced to 1/1000, this will make the
resulting file claim 1000fps.

Drop it and don't write the element. It's optional, so it's better not
to write it if the framerate is unknown.

Strangely does not require FATE changes.
2018-05-04 14:16:38 +02:00
Carl Eugen Hoyos d401ba6b3d lavf/matroskaenc: Force the minimum value for -reserve_index_space to 2.
Fixes an assertion failure:
Assertion size >= 2 failed at libavformat/matroskaenc.c:298
2018-02-12 22:50:52 +01:00
James Almer 5f67073b4c avformat/matroskaenc: add missing allocation failure checks for stream durations
Signed-off-by: James Almer <jamrial@gmail.com>
2017-11-28 01:23:23 -03:00
James Almer 9924f1bc34 avformat/matroskaenc: move some initialization checks to mkv_init
It's the correct place for them.

Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-11-27 23:24:34 -03:00
James Almer 9d464dc3fc avformat/matroskaenc: actually enforce the stream limit
Prevents out of array accesses. Adressess ticket #6873

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-11-27 13:39:55 -03:00
James Almer fd59207c1c Merge commit '827a05eaa9482e9ac2a17f7f2e42ead07c1d7574'
* commit '827a05eaa9482e9ac2a17f7f2e42ead07c1d7574':
  matroskaenc: add support for Spherical Video elements

See 58eb0f57f6. Merged for cosmetics
purposes.
Also includes changes from d32d59bc97

Merged-by: James Almer <jamrial@gmail.com>
2017-10-21 13:19:36 -03:00
James Almer 45121cbdda Merge commit '5d3953a5dcfd5f71391b7f34908517eb6f7e5146'
* commit '5d3953a5dcfd5f71391b7f34908517eb6f7e5146':
  matroskaenc: factor ts_offset into block timecode computation

Merged-by: James Almer <jamrial@gmail.com>
2017-10-02 15:26:56 -03:00
James Almer 27b7800ba9 avformat/matroskaenc: also write tags when output is WebM
WebM supports a subset of elements from the Tags master.
See https://www.webmproject.org/docs/container/#tagging

Reviewed-by: Ivan Janatra <janatra@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-08 20:02:43 -03:00
Aleksandr Slobodeniuk 0aa8fa963f avformat/riff.h : remove unused function parameter "const AVCodecTag *tags" of "void ff_put_bmp_header()"
Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-02 15:26:25 +02:00
James Almer 2ba896fef7 avformat/matroskaenc: also write chapters when output is WebM
WebM supports a subset of elements from the Chapters master.
See https://www.webmproject.org/docs/container/#chapters

Addresses ticket #6425

Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-06-02 20:44:53 -03:00
James Almer 7631f14bb3 avformat/matroskaenc: check packet side data for AAC extradata updates
This adapts and merges commit f4bf236338
from libav, originally skipped in 13a211e632
as it was not necessary back then.

Is's applied now in preparation for the following patches, where the
aac_adtstoasc bitstream filter will start to correctly propagate the new
extradata through packet side data.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-05-24 20:27:59 -03:00
James Almer 37cc1c1e91 avformat/matroskaenc: add support for writing Content Light Level elements
Signed-off-by: James Almer <jamrial@gmail.com>
2017-04-30 20:04:57 -03:00
James Almer a8b5f37501 avformat/matroskaenc: don't try to update flac extradata if live streaming 2017-04-08 15:44:53 -03:00
James Almer 4de591e6fb Merge commit '83548fe894cdb455cc127f754d09905b6d23c173'
* commit '83548fe894cdb455cc127f754d09905b6d23c173':
  lavf: fix usage of AVIOContext.seekable

Merged-by: James Almer <jamrial@gmail.com>
2017-03-21 17:02:30 -03:00
James Almer 827a05eaa9 matroskaenc: add support for Spherical Video elements
Signed-off-by: James Almer <jamrial@gmail.com>
Minor cosmetic changes by committer.
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2017-03-15 17:52:12 -04:00
James Almer 58eb0f57f6 avformat/matroskaenc: add support for Spherical Video elements
Reviewed-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-03-09 13:57:03 -03:00
Carl Eugen Hoyos 1638d956a3 lavf/matroska: Support QDMC. 2017-03-05 14:41:01 +01:00
Carl Eugen Hoyos 9ae762da7e lavf/matroska: Support codec ID V_FFV1 for demuxing.
Fixes ticket #6206.
2017-03-03 02:04:34 +01:00
James Almer 1ad60e4e70 avformat/matroskaenc: don't write DisplayUnit with value Unknown on WebM files
Value 4 (Unknown) is for the time being part of the Matroska spec but not
supported by WebM

Addresses ticket #6176
2017-02-21 21:15:51 -03:00
John Stebbins 5d3953a5dc matroskaenc: factor ts_offset into block timecode computation
ts_offset was added to cluster timecode, but then effectively subtracted
back off the block timecode

When setting initial_padding for an audio stream, the timestamps are
written incorrectly to the mkv file.  cluster timecode gets written
as pts0 + ts_offset which is correct, but then block timecode gets
written as pts - cluster timecode which expanded is
pts - (pts0 + ts_offset).  Adding cluster and block tc back together:
cluster + block = (pts0 + ts_offset) + (pts - (pts0 + ts_offset)) = pts
But the result should be pts + ts_offset since demux will subtract the
CodecDelay element from pts and set initial_padding to CodecDelay.
This patch gives the correct result.
2017-02-21 14:20:31 -07:00
James Almer dce863421b avformat/matroskaenc: don't reserve more bytes than needed for the Colour master size
Found-by: Aaron Colwell <acolwell@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-01-28 13:46:26 -03:00
Sasi Inguva e4a1d87ef8 lavf/matroskaenc.c: Free dyn bufs in mkv_free. Fixes memory leaks when muxing fails.
Signed-off-by: Sasi Inguva <isasi@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-01-27 22:16:37 +01:00
Rostislav Pehlivanov e7dec52d4d matroskaenc: remove unofficial compliance on color information
When support for this was added the details weren't yet finalized.
This is no longer the case.
Fixes writing of mkv/webm files with HDR.

Reported-by: Kagami Hiiragi <kagami@genshiken.org>
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Reviewed-by: James Almer <jamrial@gmail.com>
2017-01-15 17:49:21 +00:00
Carl Eugen Hoyos 935404923d Cosmetics: Reindent after last commit. 2017-01-14 06:07:06 +01:00
Carl Eugen Hoyos c723108e25 lavf/matroskaenc: Do not write two CodecID elements for rawvideo.
Fixes ticket #6068.
2017-01-14 06:06:05 +01:00
softworkz 20e8be0c20 avformat/matroskaenc: Regression fix for invalid MKV headers
The following three commits created a regression by writing initially
invalid mkv headers:

650e17d88b avformat/matroskaenc: write a
CRC32 element on Tags
3bcadf8227 avformat/matroskaenc: write a
CRC32 element on Info
ee888cfbe7 avformat/matroskaenc: postpone
writing the Tracks master

Symptoms:

- You can no longer playback a file that is still processed by ffmpeg,
e.g. VLC fails playback
- You can no longer stream a file to a client while if is still being
processed
- Various diagnosing tools show header errors or incomplete headers
(e.g. ffprobe, mediainfo, mkvalidator)

Note: The symptoms do not apply to completed files or ffmpeg runs that
were interrupted with 'q'

Cause:

The mentioned commits made changes in a way that some header elements
are only partially written in
mkv_write_header, leaving the header in an invalid state. Only in
mkv_write_trailer, these elements
are finished correctly, but that does only occur at the end of the
process.

Regression:

Before these commits were applied, mkv headers have always been valid,
even before completion of ffmpeg.
This has worked reliably over many versions of ffmpeg, to it was an
obvious regression.

Bugtracker:

This issue has been recorded as #5977 which is resolved by this patch

Patch:

The patch adds a new function 'end_ebml_master_crc32_preliminary' that
preliminarily finishes the ebml
element without destroying the buffer. The buffer can be used to update
the ebml element later during
mkv_write_trailer. But most important: mkv_write_header finishes with a
valid mkv header again.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-01-07 11:20:36 -03:00
James Almer 8c1342e631 avformat/matroskaenc: write updated STREAMINFO metadata for FLAC streams if available
FLAC streams originating from the FLAC encoder send updated and more
complete STREAMINFO metadata as part of the last packet, so write that
to CodecPrivate instead of the incomplete one available in extradata
during init.

Signed-off-by: James Almer <jamrial@gmail.com>
2016-11-20 19:31:32 -03:00
James Almer ee888cfbe7 avformat/matroskaenc: postpone writing the Tracks master
This will allow us to write updated stream information not available
during write_header().

Signed-off-by: James Almer <jamrial@gmail.com>
2016-11-20 19:31:32 -03:00
James Almer 98cae966c7 matroskaenc: write updated STREAMINFO metadata for FLAC streams if available
FLAC streams originating from the FLAC encoder send updated and more
complete STREAMINFO metadata as part of the last packet, so write that
to CodecPrivate instead of the incomplete one available in extradata
during init.

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-11-10 09:15:24 +01:00
James Almer f4bf236338 matroskaenc: fix muxing AAC streams when using aac_adtstoasc bsf
aac_adtstoasc makes the aac extradata available only after the first packet
is filtered, and as packet side data.

Assume extradata will be available as part of the first packet if
avpriv_mpeg4audio_get_config() fails the first time due to missing extradata
and reserve space for the OutputSampleRate element in the Tracks master.

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-11-10 09:01:18 +01:00
James Almer 5cb57131d3 avformat/matroskaenc: use display aspect ratio for DisplayWidth and DisplayHeight when possible
This avoids potential rounding errors and guarantees the source aspect
ratio is preserved.
Keep writing pixel values when Stereo 3D Mode is enabled and for WebM,
as the format doesn't support anything else.

This fixes ticket #5743, implementing the suggestion from ticket #5903.

Signed-off-by: James Almer <jamrial@gmail.com>
2016-11-02 17:08:38 -03:00
James Almer bab6b60675 avformat/matroskaenc: support writing Chroma Location elements
Signed-off-by: James Almer <jamrial@gmail.com>
2016-11-02 17:07:04 -03:00
Rodger Combs 1a958f4eb0
lavf/matroskaenc: don't try to modify the header when live-streaming 2016-11-02 01:16:26 -05:00
Rodger Combs be28ce210d
lavf/matroskaenc: fix uninitialized read 2016-11-02 01:16:26 -05:00
Adriano Pallavicino 6089c44a2a Fix build warnings due to misleading indentation
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-11-01 17:44:10 +01:00
James Almer eabbc64728 avformat/matroskaenc: fix cue relative position values when CRC32 is enabled
The dynamic buffer does not contain the CRC32 element so calls to avio_tell()
don't take it into account. This resulted in CueRelativePosition values being
six bytes short.
This is a regression since 6724525a15

Instead of adding yet another custom check for CRC32 to fix a size or an offset,
remove the existing ones and reserve the six bytes in the dynamic buffer.

Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-26 16:28:59 -03:00
James Almer cc71fa319f avformat/matroskaenc: write DisplayWidth and DisplayHeight elements only if they differ from PixelWidth and PixelHeight
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-22 15:00:15 -03:00
James Almer 90826031a2 avformat/matroskaenc: write a DisplayUnit element when aspect ratio is unknown
We don't currently support values 1 (centimeters), 2 (inches) or 3 (DAR),
only the default value 0 (pixels) which doesn't need to be written.

The fate refs are updated as unknown SAR is now signaled in the output
files with the addition of the new element.

Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-15 20:48:03 -03:00
James Almer 8063978bfc avformat/matroskaenc: don't write a FlagInterlaced element if it would write the default value
The spec says:
"Mandatory elements with a default value may be left out of the file. In the absence
of a mandatory element, the element's default value is used."

Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-11 19:49:19 -03:00
Carl Eugen Hoyos 5781256c01 lavf/matroskaenc: Always write V_QUICKTIME extradata.
Fixes ticket #5872.
2016-10-11 10:07:18 +02:00
James Almer c44eae157f avformat/matroskaenc: fix targets for attachment tags
Attachment tags were being written targeting non-existent streams in the
output file.
Also filter filename and mimetype entries, as they are standard elements
in the Attachment master.

Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-10 23:18:36 -03:00
James Almer c45ba265fc avformat/matroskaenc: fix Tags master on seekable output if there are tags after the last stream duration
The dynamic AVIOContext would get closed pointing to the wrong position
in the buffer.
This is a regression since 650e17d88b.

Reviewed-by: Dave Rice <dave@dericed.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-07 16:46:45 -03:00
Michael Niedermayer 572f16e100 avformat/matroskaenc: Fix () error
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-07 14:56:53 +02:00
James Almer 711bfb33df avformat/matroskaenc: add an option to disable writting CRC32 elements
Also add missing Changelog entry.

Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-06 18:42:10 -03:00
James Almer 3bcadf8227 avformat/matroskaenc: write a CRC32 element on Info
Finishes implementing ticket #4347

Tested-by: Dave Rice <dave@dericed.com>
Tested-by: Jerome Martinez <jerome@mediaarea.net>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-06 17:16:12 -03:00
James Almer 650e17d88b avformat/matroskaenc: write a CRC32 element on Tags
Implements part of ticket #4347

Tested-by: Dave Rice <dave@dericed.com>
Tested-by: Jerome Martinez <jerome@mediaarea.net>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-06 17:13:59 -03:00
James Almer 4687240d52 avformat/matroskaenc: write a CRC32 element on Attachments
Implements part of ticket #4347

Tested-by: Dave Rice <dave@dericed.com>
Tested-by: Jerome Martinez <jerome@mediaarea.net>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-06 17:10:51 -03:00
James Almer eccefece61 avformat/matroskaenc: write a CRC32 element on Chapters
Implements part of ticket #4347

Tested-by: Dave Rice <dave@dericed.com>
Tested-by: Jerome Martinez <jerome@mediaarea.net>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-06 17:08:14 -03:00
James Almer 87ce2595de avformat/matroskaenc: write a CRC32 element on Tracks
Implements part of ticket #4347

Tested-by: Dave Rice <dave@dericed.com>
Tested-by: Jerome Martinez <jerome@mediaarea.net>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-06 17:05:03 -03:00
James Almer 79248795d4 avformat/matroskaenc: write a CRC32 element on Cues
Implements part of ticket #4347

Tested-by: Dave Rice <dave@dericed.com>
Tested-by: Jerome Martinez <jerome@mediaarea.net>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-06 17:01:20 -03:00