Commit Graph

696 Commits

Author SHA1 Message Date
Andreas Rheinhardt
4e6df068b5 avformat/matroskaenc: Don't waste bytes in EBML Header
Up until now the EBML Header length field has been written with eight
bytes, although the EBML Header is always so small that only one byte
is needed for it. This patch saves seven bytes for every Matroska/Webm
file.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08 13:02:29 -03:00
Andreas Rheinhardt
5d7d0fcd70 avformat/matroskaenc: Slightly improve size bounds for cues
The upper bounds currently used for determining the size of a CuePoint's
length field can be improved somewhat; as a result, a CuePoint
containing three CueTrackPositions will now only need a size field
with one byte length.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08 13:02:28 -03:00
Andreas Rheinhardt
8b7964f8f8 avformat/matroskaenc: Fix BlockGroup size calculation
The earlier code included the size of the BlockGroup's length field and
the EBML ID in the calculation of the size for the payload and ignored
the size of the  duration's length field. This meant that Blockgroups
corresponding to packets with size 2^(7n) - 17 - n - i, i = 0,..., n - 1,
n = 1,..., 8 (i.e. 110, 16364, 16365, 2097130..2097132, ...) were written
with length fields that are unnecessarily long.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08 13:02:28 -03:00
Andreas Rheinhardt
4ebeab15b0 avformat/matroskaenc: Fix relative timestamp check
At this point, ts already includes the ts_offset so that the relative
time written with the cluster is already given by ts - mkv->cluster_pts.
It is this number that needs to fit into an int16_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08 13:02:28 -03:00
Tristan Matthews
1ec777dcdd avformat/matroskaenc: fix leak on error
Signed-off-by: James Almer <jamrial@gmail.com>
2019-04-09 10:49:05 -03:00
Jun Zhao
0a347ff422 lavf/matroskaenc: Fix memory leak after write trailer
Fix memory leak after write trailer for #7827, only store a audio
packet whose buffer has size greater than zero in cur_audio_pkt.

Audio packets with size zero, but with side-data currently lead to
memleaks, in the Matroska muxer, because they are not properly freed:

They are currently put into an AVPacket in the MatroskaMuxContext to
ensure that the necessary audio is always available for a new cluster,
but are only written and freed when their size is > 0.

As the only use we have for such packets consists in updating the
CodecPrivate it makes no sense to store these packets at all and this
is how this commit solves the memleak.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-04-09 09:16:07 +08:00
Carl Eugen Hoyos
715186456c lavf/matroskaenc: Allow dvdsub remuxing from some containers.
Fixes ticket #7783.
2019-03-10 20:45:45 +01:00
Paul B Mahol
c0fb6f963f avformat/vorbiscomment: add support for writing chapters
Fixes #7532.
2018-12-18 19:45:59 +01:00
Sigga Regina
dcbd89e000 avformat/matroskaenc: reserve free space for metadata on request
Signed-off-by: James Almer <jamrial@gmail.com>
2018-10-01 14:52:35 -03:00
James Almer
819e4e7979 avformat/matroskaenc: reindent after the previous commit
Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-26 15:17:14 -03:00
James Almer
8439656503 avformat/matroskaenc: refactor checks for allowed codecs in WebM
Use the new ff_webm_codec_tags[] array for this purpose.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-26 15:17:14 -03:00
James Almer
794079e815 avformat/matroskaenc: implement AVOutputFormat.query_codec for webm
Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-26 15:17:13 -03:00
James Almer
14ac62f9af avformat/matroskaenc: remove unnecessary additional codec tags
They are listed in riff.c already.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-26 15:17:13 -03:00
James Almer
a068594248 Revert "avformat/matroskaenc: write CodecPrivate in WebM"
This reverts commit 4755b6e6d1.

This change was not necessary. CodecPrivate was being written to WebM
for codecs like AV1 already.
2018-09-21 18:22:37 -03:00
James Almer
4755b6e6d1 avformat/matroskaenc: write CodecPrivate in WebM
This is now needed for AV1.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-21 16:57:32 -03:00
Kagami Hiiragi
cbe5c7ef38 lavf/matroska: Allow AV1 in WebM
Nothing prevents it to work except this check. AV1 is already supported
by Matroska muxer and aomenc produces WebM/AV1 files as well.

Signed-off-by: Kagami Hiiragi <kagami@genshiken.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-21 12:20:48 -03:00
James Almer
de1b44c206 avformat/matroskaenc: handle AV1 extradata in packet side data
This is a temporary workaround for transcoding scenarious using libaom-av1
encoder, which currently can't propagate extradata during initialization.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-08-18 23:32:44 -03:00
James Almer
2de5209d91 avformat/matroskaenc: filter and reorder AV1 OBUs
Make sure to not write forbidden OBUs to CodecPrivate, and do the same with
unnecessary OBUs for packets.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-08-02 12:41:55 -03:00
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
James Almer
3b189fae73 avformat/matroskaenc: write a CRC32 element on SeekHead
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 16:59:09 -03:00
James Almer
6724525a15 avformat/matroskaenc: write a CRC32 element on each Cluster
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 16:54:07 -03:00
James Almer
4e3bdf729a avformat/matroskaenc: always use a dynamic buffer when writting clusters
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 16:30:56 -03:00
James Almer
d41aeea8a6 avformat/matroskaenc: print debug message with cluster offsets only if the output is seekable
Printing the dynamic buffer offset is useless.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-06 16:30:56 -03:00
James Almer
9b8ac526f6 avformat/matroskaenc: don't write an empty Colour master element
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-06 13:49:10 -03:00
James Almer
b33369b612 avformat/matroskaenc: don't reserve space for stream duration tags if the output is not seekable
The durations are never written in that situation.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-04 21:19:58 -03:00
James Almer
3cc9d6d382 avformat/matroska: write FlagInterlaced element in WebM
It's listed as supported in both https://www.webmproject.org/docs/container/
and https://matroska.org/technical/specs/index.html

Reviewed-by: Dave Rice <dave@dericed.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-04 19:42:55 -03:00
Anton Khirnov
83548fe894 lavf: fix usage of AVIOContext.seekable
It is supposed to be a flag. The only currently defined value is
AVIO_SEEKABLE_NORMAL, but other ones may be added in the future.
However all the current lavf code treats this field as a bool (mainly
for historical reasons).
Change all those cases to properly check for AVIO_SEEKABLE_NORMAL.
2016-09-30 16:54:33 +02:00
Rodger Combs
843e72ea55
lavf/matroskaenc: use mkv_check_tag_name consistently
Previously, we used a different list of checks when deciding whether to
write a set of tags at all than we did when deciding whether to write an
individual tag in the set. This resulted in sometimes writing an empty
tag master and seekhead. Now we use mkv_check_tag_name everywhere, so
if a dictionary is entirely composed of tags we skip, we don't write a
tag master at all.

This affected the test file, since "language" was on one list but not
the other, so we were writing an empty tag master there. The test hash
is updated to reflect that change.
2016-09-06 17:25:37 -05:00
Rodger Combs
3829a02738
lavf/matroskaenc: skip writing "duration" tags 2016-09-06 17:25:36 -05:00
Rodger Combs
6ede4e93ca
lavf/matroskaenc: move skipped metadata keys to separate function 2016-09-06 17:25:36 -05:00
Michael Bradshaw
c9ae8be5a8 avformat/matroskaenc: fix Voids with size < 10
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-31 16:59:49 +02:00
softworkz
70c1647a35 avformat/matroskaenc: Write duration early during mkv_write_header (Rev #3)
Rev #2: Fixes doubled header writing, checked FATE running without errors
Rev #3: Fixed coding style

This commit addresses the following scenario:

we are using ffmpeg to transcode or remux mkv (or something else) to mkv. The result is being streamed on-the-fly to an HTML5 client (streaming starts while ffmpeg is still running). The problem here is that the client is unable to detect the duration because the duration is only written to the mkv at the end of the transcoding/remoxing process. In matroskaenc.c, the duration is only written during mkv_write_trailer but not during mkv_write_header.

The approach:

FFMPEG is currently putting quite some effort to estimate the durations of source streams, but in many cases the source stream durations are still left at 0 and these durations are nowhere mapped to or used for output streams. As much as I would have liked to deduct or estimate output durations based on input stream durations - I realized that this is a hard task (as Nicolas already mentioned in a previous conversation). It would involve changes to the duration calculation/estimation/deduction for input streams and propagating these durations to output streams or the output context in a correct way.
So I looked for a simple and small solution with better chances to get accepted. In webmdashenc.c I found that a duration is written during write_header and this duration is taken from the streams' metadata, so I decided for a similar approach.

And here's what it does:

At first it is checking the duration of the AVFormatContext. In typical cases this value is not set, but: It is set in cases where the user has specified a recording_time or an end_time via the -t or -to parameters.
Then it is looking for a DURATION metadata field in the metadata of the output context (AVFormatContext::metadata). This would only exist in case the user has explicitly specified a metadata DURATION value from the command line.
Then it is iterating all streams looking for a "DURATION" metadata (this works unless the option "-map_metadata -1" has been specified) and determines the maximum value.
The precendence is as follows: 1. Use duration of AVFormatContext - 2. Use explicitly specified metadata duration value - 3. Use maximum (mapped) metadata duration over all streams.

To test this:

1. With explicit recording time:
ffmpeg -i file:"src.mkv" -loglevel debug -t 01:38:36.000 -y "dest.mkv"

2. Take duration from metadata specified via command line parameters:
ffmpeg -i file:"src.mkv" -loglevel debug -map_metadata -1 -metadata Duration="01:14:33.00" -y "dest.mkv"

3. Take duration from mapped input metadata:
ffmpeg -i file:"src.mkv" -loglevel debug -y "dest.mkv"

Regression risk:

Very low IMO because it only affects the header while ffmpeg is still running. When ffmpeg completes the process, the duration is rewritten to the header with the usual value (same like without this commit).

Signed-off-by: SoftWorkz <softworkz@hotmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-28 02:06:55 +02:00
James Almer
be04c4aa00 avformt/matroskaenc: undo an accidental revert by commit 5d48e4ea
Commit 5d48e4eafa accidentally reverted changes
made to matroskaenc by commit 989a614b70.

Signed-off-by: James Almer <jamrial@gmail.com>
2016-07-26 15:22:32 -03:00
James Almer
1582e306a4 avformat/avlanguage: make av_convert_lang_to() internal
The header was never installed and the function is only used in libavformat

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-07-19 21:43:14 -03:00
Matthieu Bouron
dc62016c4b Merge commit '71852a1ba89abc8749e309d9d662c49d47e19531'
* commit '71852a1ba89abc8749e309d9d662c49d47e19531':
  matroskaenc: Provide output bytestream markers

Merged-by: Matthieu Bouron <matthieu.bouron@stupeflix.com>
2016-06-23 17:57:34 +02:00
Clément Bœsch
5d48e4eafa Merge commit 'a6a750c7ef240b72ce01e9653343a0ddf247d196'
* commit 'a6a750c7ef240b72ce01e9653343a0ddf247d196':
  tests: Move all test programs to a subdirectory

Merged-by: Clément Bœsch <clement@stupeflix.com>
2016-06-22 13:44:34 +02:00
Michael Bradshaw
989a614b70 libavformat/matroskaenc: omit segment UID for webm
SegmentUID is not a supported element in WebM. See:
http://www.webmproject.org/docs/container/#SegmentUID

Reviewed-by: Dave Rice <dave@dericed.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-22 12:12:46 +02:00
Michael Niedermayer
566be4f9e8 avformat/matroskaenc: reindent after last commit
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-22 03:22:16 +02:00
Michael Niedermayer
2062d51275 avformat/matroskaenc: wrap par->format use as sample format under codec_type == AVMEDIA_TYPE_AUDI
Fixes CID1361946

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-22 03:22:09 +02:00
Martin Storsjö
71852a1ba8 matroskaenc: Provide output bytestream markers
Signed-off-by: Martin Storsjö <martin@martin.st>
2016-05-18 10:36:58 +03:00
Derek Buitenhuis
ee865e9780 Merge commit 'e3453fd44480d903338c663238bf280215dd9a07'
* commit 'e3453fd44480d903338c663238bf280215dd9a07':
  matroska: Write the field order information

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-05-08 23:25:58 +01:00
Michael Niedermayer
c4fad02779 avformat/matroskaenc: Undo bits_per_coded_sample change as bits_per_raw_sample is available again
Reminded-by: James Almer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-16 02:01:10 +02:00
Derek Buitenhuis
6f69f7a8bf Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
  lavf: replace AVStream.codec with AVStream.codecpar

This has been a HUGE effort from:
    - Derek Buitenhuis <derek.buitenhuis@gmail.com>
    - Hendrik Leppkes <h.leppkes@gmail.com>
    - wm4 <nfxjfg@googlemail.com>
    - Clément Bœsch <clement@stupeflix.com>
    - James Almer <jamrial@gmail.com>
    - Michael Niedermayer <michael@niedermayer.cc>
    - Rostislav Pehlivanov <atomnuker@gmail.com>

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-10 20:59:55 +01:00
Luca Barbato
e3453fd444 matroska: Write the field order information
And bump the document version to 4.
2016-04-03 19:36:57 +02:00
Neil Birkbeck
e7e5c5e6c4 lavf/matroskaenc.c: add early support for colour elements
Adding early support for a subset of the proposed colour elements
according to the latest version of spec:
https://mailarchive.ietf.org/arch/search/?email_list=cellar&gbt=1&index=hIKLhMdgTMTEwUTeA4ct38h0tmE

Like matroskadec, I've left out elements for pix_fmt related things
 as there still seems to be some discussion around these.

The new elements are exposed under strict experimental mode.

Signed-off-by: Neil Birkbeck <neil.birkbeck@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-21 00:10:18 +01:00
Hendrik Leppkes
c43d485811 matroskaenc: set the actual PCM bitdepth in the header
The actual bitdepth can be different to the storage format (ie. sample format).
Fixes the stored bitdepth for 24-bit formats like FLAC.
2016-03-16 12:52:35 +01:00
Ronald S. Bultje
2e6636aa87 vp9: add superframe merging bitstream filter.
Fixes ticket 4313.
2016-03-11 11:19:14 -05:00
Anton Khirnov
9200514ad8 lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.

In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.

There are multiple important problems with this approach:
    - the fields in AVCodecContext are in general one of
        * stream parameters
        * codec options
        * codec state
      However, it's not clear which ones are which. It is consequently
      unclear which fields are a demuxer allowed to set or a muxer allowed to
      read. This leads to erratic behaviour depending on whether decoding or
      encoding is being performed or not (and whether it uses the AVStream
      embedded codec context).
    - various synchronization issues arising from the fact that the same
      context is used by several different APIs (muxers/demuxers,
      parsers, bitstream filters and encoders/decoders) simultaneously, with
      there being no clear rules for who can modify what and the different
      processes being typically delayed with respect to each other.
    - avformat_find_stream_info() making it necessary to support opening
      and closing a single codec context multiple times, thus
      complicating the semantics of freeing various allocated objects in the
      codec context.

Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2016-02-23 17:01:58 +01:00
Marton Balint
66e85a180a avformat/matroskaenc: use ff_parse_creation_time_metadata
Also increase precision to microsecs, and avoid writing creation_time as a
simple tag metadata item.

Signed-off-by: Marton Balint <cus@passwd.hu>
2016-02-14 01:51:14 +01:00
Carl Eugen Hoyos
c3c22bee63 lavf/matroskaenc: Assume 48kHz sample rate for Opus initial padding.
Analyzed by Timothy B. Terriberry in Mozilla bug 1227153.
Fixes ticket #5121.
2016-01-05 21:34:35 +01:00
Rodger Combs
b287d7ea17 lavf/matroskaenc: add automatic bitstream filtering 2015-12-28 08:40:37 -06:00
Michael Niedermayer
e6971db12b avformat/matroskaenc: Check codecdelay before use
Fixes CID1238790

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-09 16:18:14 +01:00
Clément Bœsch
43ecec0f03 avformat: use AV_OPT_TYPE_BOOL in a bunch of places 2015-12-04 15:43:33 +01:00
Hendrik Leppkes
87a6f532b4 Merge commit '9b56d5c11488656254e9aed8d964ef2b7c2ff5e6'
* commit '9b56d5c11488656254e9aed8d964ef2b7c2ff5e6':
  avpacket: Deprecate av_dup_packet

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-29 14:16:44 +01:00
Hendrik Leppkes
7f5af80ba4 Merge commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457'
* commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457':
  avpacket: Replace av_free_packet with av_packet_unref

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-27 14:28:56 +01:00
Luca Barbato
9b56d5c114 avpacket: Deprecate av_dup_packet
As documented, `av_dup_packet` is broken by design, `av_packet_ref`
matches the AVFrame ref-counted API and can be safely used instead.
2015-10-26 18:00:55 +01:00
Luca Barbato
ce70f28a17 avpacket: Replace av_free_packet with av_packet_unref
`av_packet_unref` matches the AVFrame ref-counted API and can be used as
a drop in replacement.

Deprecate `av_free_packet`.
2015-10-26 18:00:55 +01:00
Hendrik Leppkes
4064d688e7 Merge commit 'f56a08559334b7eb6b3fedbc0cc741887f6067ae'
* commit 'f56a08559334b7eb6b3fedbc0cc741887f6067ae':
  matroskaenc: Don't write a track language tag

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-05 11:12:12 +02:00
John Stebbins
f56a085593 matroskaenc: Don't write a track language tag
"language" is not an offical matroska tag.
Track languages are specified with the MATROSKA_ID_TRACKLANGUAGE ebml.
Writing the tag overrides the ebml specified language during playback with
libav and some other players.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2015-10-03 13:44:35 +02:00
Hendrik Leppkes
b01891a9f0 Merge commit '948f3c19a8bd069768ca411212aaf8c1ed96b10d'
* commit '948f3c19a8bd069768ca411212aaf8c1ed96b10d':
  lavc: Make AVPacket.duration int64, and deprecate convergence_duration

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-29 15:22:52 +02:00
wm4
948f3c19a8 lavc: Make AVPacket.duration int64, and deprecate convergence_duration
Note that convergence_duration had another meaning, one which was in
practice never used. The only real use for it was a 64 bit replacement
for the duration field. It's better just to make duration 64 bits, and
to get rid of it.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-09-29 14:33:00 +02:00
Hendrik Leppkes
f5258a7d16 Merge commit 'e176639bcbf4b580edb462a6b0650e53cd5e3c04'
* commit 'e176639bcbf4b580edb462a6b0650e53cd5e3c04':
  webm: Explicitly select libvpx, libopus and libvorbis encoders

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-08-27 09:53:07 +02:00
Timothy Gu
0c6a92a447 matroskaenc: Fix indentation
Found-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-08-25 16:03:49 -07:00
Luca Barbato
e176639bcb webm: Explicitly select libvpx, libopus and libvorbis encoders
And update the preference for the newer codecs now that the libraries
seem stable and widespread enough.

Bug-Id: 695
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-08-25 19:47:43 +02:00
Neil Birkbeck
3dabebc272 libavformat/matroskaenc.c: fix small memory leaks on error
Fixing small leaks that can occur when mkv_write_tracks fails in mkv_write_header
(e.g., if video track has unknown codec). Also changing mkv_write_seekhead to take
the MatroskaMuxContext to avoid having dangling pointers.

Signed-off-by: Neil Birkbeck <neil.birkbeck@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-19 13:17:21 +02:00
Michael Niedermayer
ace8376653 avformat/matroskaenc: Avoid "for (int i" syntax for better compatibility
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-06 01:15:08 +02:00
Sasi Inguva
31852540d4 libavformat/matroska: Write stream durations in metadata, in the format of mkvmerge.
Compute individual stream durations in matroska muxer.
Write them as string tags in the same format as mkvmerge tool does.

Signed-off-by: Sasi Inguva <isasi@google.com>
2015-08-05 22:29:23 +02:00
Carl Eugen Hoyos
6253f511e0 Cosmetics: Reindent after last commit. 2015-07-09 19:52:06 +02:00
Carl Eugen Hoyos
da46370e94 lavf/matroskaenc: Do not needlessly allocate memory for cuepoints.
Fixes ticket #4690.
2015-07-09 19:49:37 +02:00
Michael Niedermayer
dac7b27802 Merge commit 'b14086ca38efa1a86cb0f0c6aa147b05f698877b'
* commit 'b14086ca38efa1a86cb0f0c6aa147b05f698877b':
  mkv: Correctly report the latest packet had been flushed

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-09 18:30:24 +02:00
Luca Barbato
b14086ca38 mkv: Correctly report the latest packet had been flushed
Bug-Id: 865
CC: libav-stable@libav.org
2015-06-09 14:27:54 +02:00
Vignesh Venkatasubramanian
7be0f48a32 lavf/matroskaenc: Write Block Keyframe correctly
Per matroska Block Structure [1], for keyframes 0th bit of the flag
should not be set (unlike SimpleBlocks). For Blocks, keyframes is
inferred by the absence of ReferenceBlock element (as done by
matroskadec). This CL writes the flag correctly and inserts the
ReferenceBlock element for non-keyframes. The timestamp inserted is
that of the immediately preceding frame (which is true for VP8 and VP9
- the only 2 codecs using the matroska block element as of now). It
also considers all non-video frames (audio, subtitles, metadata) to
be keyframes.

[1] http://www.matroska.org/technical/specs/index.html#block_structure

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-05 02:48:04 +02:00
Michael Niedermayer
cf86fd0069 avformat/matroskaenc: Avoid floats in default duration calculation
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-26 20:42:05 +02:00
Carl Eugen Hoyos
8f6b919d99 lavf/mkv: Only skip prores header if the packet is large enough.
Fixes a possible endless loop.
2015-05-21 00:43:38 +02:00
Michael Niedermayer
66f26b3e8e avformat/matroskaenc: Check ff_vorbiscomment_length in put_flac_codecpriv()
Its currently guaranteed to be smaller but its safer to check anyway

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-11 15:56:16 +02:00
Michael Niedermayer
9d4fdfe24c avformat/matroskaenc: Use avoid_negative_ts_use_pts if no stream writes dts
This reduces the number of cases where timestamps need to be shifted

Fixes Ticket4487

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-05 13:17:25 +02:00
wm4
c4d37cd9ef matroskadec: export cover art correctly
Generally, libavformat exports cover art pictures as video streams with
1 packet and AV_DISPOSITION_ATTACHED_PIC set. Only matroskadec exported
it as attachment with codec_id set to AV_CODEC_ID_MJPEG.

Obviously, this should be consistent, so change the Matroska demuxer to
export a AV_DISPOSITION_ATTACHED_PIC pseudo video stream.

Matroska muxing is probably incorrect too. I know that it can create
broken files with an audio track and just 1 video frame when e.g.
remuxing mp3 with APIC to mkv. But for now this commit does not change
anything about muxing, and also continues to write attachments with
AV_CODEC_ID_MJPEG should the muxer application have special knowledge
that the Matroska is broken in this way.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2015-04-08 12:36:53 +02:00
Vignesh Venkatasubramanian
6fd300ac6c lavf: Add support for WebM Live Muxing
This patch adds support for WebM Live Muxing by adding a new WebM
Chunk muxer. It writes out live WebM Chunks which can be used for
playback using Live DASH Clients.

Please see muxers.texi for sample usage.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-07 15:08:59 +02:00
wm4
511585ce7f matroskadec: export cover art correctly
Generally, libavformat exports cover art pictures as video streams with
1 packet and AV_DISPOSITION_ATTACHED_PIC set. Only matroskadec exported
it as attachment with codec_id set to AV_CODEC_ID_MJPEG.

Obviously, this should be consistent, so change the Matroska demuxer to
export a AV_DISPOSITION_ATTACHED_PIC pseudo video stream.

Matroska muxing is probably incorrect too. I know that it can create
broken files with an audio track and just 1 video frame when e.g.
remuxing mp3 with APIC to mkv. But for now this commit does not change
anything about muxing, and also continues to write attachments with
AV_CODEC_ID_MJPEG should the muxer application have special knowledge
that the Matroska is broken in this way.

Fixes trac #4423.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-04 02:25:56 +02:00
Carl Eugen Hoyos
b76df6efb6 lavf/matroskaenc: List subtitle codecs with fake codec_tags to allow remuxing.
Fixes remuxing of DVBSUB to mkv.
2015-03-24 10:07:18 +01:00
Carl Eugen Hoyos
7a5356c728 lavf/mkv: Ignore ff_isom_write_hvcc() return value as the mov muxer does.
This change allows remuxing hevc from mpeg-ts to Matroska.
2015-03-18 20:35:26 +01:00
Michael Niedermayer
e48ff13ba7 Merge commit '9272c965d9559a90ee64d46aebd99c117e07f7a3'
* commit '9272c965d9559a90ee64d46aebd99c117e07f7a3':
  matroskaenc: Fix type used for chapter timestamps

Conflicts:
	libavformat/matroskaenc.c

See: a4cd057bc7
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-11 20:09:18 +01:00
Vittorio Giovara
9272c965d9 matroskaenc: Fix type used for chapter timestamps 2015-03-11 17:56:51 +00:00
Michael Niedermayer
2e8020c66c Merge commit '9f25a109922da43c1f81273a431d3b40cb5a785a'
* commit '9f25a109922da43c1f81273a431d3b40cb5a785a':
  matroskaenc: Also validate chapter end time

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-09 20:31:22 +01:00
Vittorio Giovara
9f25a10992 matroskaenc: Also validate chapter end time
This prevents it to be written as unsigned. Also add an error message.

CC: libav-stable@libav.org
Bug-Id: CID 1265717
2015-03-09 12:57:19 +00:00
John Stebbins
da7e561964 matroskaenc: Allow writing track "forced" flag
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-02-24 22:28:51 +01:00
Michael Niedermayer
a4cd057bc7 avformat/matroskaenc: Use the correct data type for the chapter times
Fixes potential integer overflow

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-17 20:40:00 +01:00
Michael Niedermayer
d302853bca Merge commit '5dc47a2bd52e375ed742c45d08356b45098f458d'
* commit '5dc47a2bd52e375ed742c45d08356b45098f458d':
  matroskaenc: Validate chapter start and end times

Conflicts:
	libavformat/matroskaenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-17 20:25:47 +01:00
Vittorio Giovara
5dc47a2bd5 matroskaenc: Validate chapter start and end times
CC: libav-stable@libav.org
Bug-Id: CID 1265717
2015-02-17 11:27:41 -05:00
Michael Niedermayer
7d60baa8d9 avformat/matroskaenc: add allow_raw_vfw and disable it by default
Based on complaint by wm4

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-15 00:43:38 +01:00
Michael Niedermayer
a0fe1a25fa Merge commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e'
* commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e':
  avformat: Don't anonymously typedef structs

Conflicts:
	libavformat/adtsenc.c
	libavformat/aiffenc.c
	libavformat/avidec.c
	libavformat/gif.c
	libavformat/iff.c
	libavformat/img2dec.c
	libavformat/jvdec.c
	libavformat/matroskadec.c
	libavformat/udp.c
	libavformat/wtvdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-14 21:07:40 +01:00
Diego Biurrun
daf8cf358a avformat: Don't anonymously typedef structs 2015-02-14 10:13:47 -08:00
Michael Niedermayer
9ccc4eedd1 avformat/matroskaenc: Do not use native mode for raw RGB
This fixes generating totally unplayable files

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-14 13:02:30 +01:00
Michael Niedermayer
e2fb12b629 avformat/matroskaenc: fix handling of VFW style raw rgb
raw rgb uses 0 as codec tag in "VFW", the code assumed 0 means error

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-14 13:02:30 +01:00
Michael Niedermayer
f95cd5a235 Merge commit '51da7d02748cc54b7d009115e76efa940b99a8ef'
* commit '51da7d02748cc54b7d009115e76efa940b99a8ef':
  matroskaenc: refuse to write AAC without valid extradata

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-09 21:25:49 +01:00
Anton Khirnov
51da7d0274 matroskaenc: refuse to write AAC without valid extradata 2015-01-09 15:51:00 +01:00
Michael Niedermayer
988d27b802 Merge commit 'b1306823d0b3ae998c8e10ad832004eb13bdd93e'
* commit 'b1306823d0b3ae998c8e10ad832004eb13bdd93e':
  check memory errors from av_strdup()

Conflicts:
	avprobe.c
	libavformat/matroskaenc.c
	libavutil/opt.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-19 04:57:25 +01:00
Vittorio Giovara
b1306823d0 check memory errors from av_strdup() 2014-12-18 23:27:14 +01:00
Michael Niedermayer
ad2deb02e5 avcodec/xiph: mark returned header pointers const from avpriv_split_xiph_headers()
Reviewed-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-14 14:30:45 +01:00
Luca Barbato
69c1fe7c9c mkv: Validate ASS Start and End fields
CC: libav-stable@libav.org
2014-12-03 13:08:41 +00:00
Michael Niedermayer
f769671f86 Merge commit '090c67d586e3916f9acc49e010b6389d07f97153'
* commit '090c67d586e3916f9acc49e010b6389d07f97153':
  matroskaenc: write correct Display{Width, Height} in stereo encoding

Conflicts:
	libavformat/matroskaenc.c

See: 6103faaa51
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-27 22:18:03 +01:00
Vittorio Giovara
090c67d586 matroskaenc: write correct Display{Width, Height} in stereo encoding
should be the raw amount of pixels (for example 3840x1080 for full HD side by
side) and the DisplayWidth/Height in pixels should be the amount of pixels for
one plane (1920x1080 for that full HD stream)."

So, move the aspect ratio check in the mkv_write_stereo_mode() function
and always write the embl when stereo format and/or aspect ration is set.
Also add a few comments to that function.

CC: libav-stable@libav.org
Found-by: Asan Usipov <asan.usipov@gmail.com>
2014-10-27 18:21:35 +00:00
Michael Niedermayer
8be93ba049 Merge commit '28c020d4df9b060a58a124a7a5406d4313fbe249'
* commit '28c020d4df9b060a58a124a7a5406d4313fbe249':
  matroskaenc: check avio_open_dyn_buf return value

Conflicts:
	libavformat/matroskaenc.c

See: b1f517f503
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-25 04:45:23 +02:00
Vittorio Giovara
28c020d4df matroskaenc: check avio_open_dyn_buf return value
CC: libav-stable@libav.org
Bug-Id: CID 703629
2014-10-24 23:48:57 +01:00
Michael Niedermayer
4694c0bb7c Merge commit 'eabdc2a830f1ab1a3f12243eb7e2fba801cb81f0'
* commit 'eabdc2a830f1ab1a3f12243eb7e2fba801cb81f0':
  lavf: use initial_padding instead of deprecated delay

Conflicts:
	libavformat/matroskaenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-14 03:00:17 +02:00
Anton Khirnov
eabdc2a830 lavf: use initial_padding instead of deprecated delay 2014-10-13 19:10:30 +00:00
Frank Galligan
241b306b1e Fix writing first audio Cues in dash mode.
In dahsmode Matroska is not writing the first Cluster for every
audio stream in the Cues element.

Signed-off-by: Frank Galligan <frankgalligan@gmail.com>
Reviewed-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-09 21:50:48 +02:00
Clément Bœsch
55180b3299 Kill timed SRT 2014-09-30 20:21:14 +02:00
Clément Bœsch
c7d8dbad14 avformat: remove FF_API_ASS_SSA dead code 2014-09-09 21:34:23 +02:00
Michael Niedermayer
37520a91ac avformat: drop redundant MATROSKA_VIDEO_STEREO_MODE_COUNT identifier
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-29 01:26:52 +02:00
Michael Niedermayer
39cd9fdbf8 Merge commit '4d686fb721b485ebbc4c7779d927d876c1e630f7'
* commit '4d686fb721b485ebbc4c7779d927d876c1e630f7':
  matroskaenc: convert avstream stereo3d side data during encoding

Conflicts:
	libavformat/matroskaenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-29 00:44:47 +02:00
Vittorio Giovara
4d686fb721 matroskaenc: convert avstream stereo3d side data during encoding
Write the StereoMode Embl to bitstream.
2014-08-28 12:35:27 -04:00
Michael Niedermayer
c2c4cee866 avformat/matroskaenc: Check alpha_mode
Fixes CID1231992

Suggested-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-24 20:33:17 +02:00
Michael Niedermayer
fb33bff990 Merge commit 'f929ab0569ff31ed5a59b0b0adb7ce09df3fca39'
* commit 'f929ab0569ff31ed5a59b0b0adb7ce09df3fca39':
  cosmetics: Write NULL pointer equality checks more compactly

Conflicts:
	cmdutils.c
	ffmpeg_opt.c
	ffplay.c
	libavcodec/dvbsub.c
	libavcodec/dvdsubdec.c
	libavcodec/dvdsubenc.c
	libavcodec/dxa.c
	libavcodec/libxvid_rc.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/rv10.c
	libavcodec/tiffenc.c
	libavcodec/utils.c
	libavcodec/vc1dec.c
	libavcodec/zmbv.c
	libavdevice/v4l2.c
	libavformat/matroskadec.c
	libavformat/movenc.c
	libavformat/sdp.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-15 21:00:50 +02:00
Gabriel Dume
f929ab0569 cosmetics: Write NULL pointer equality checks more compactly
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2014-08-15 03:18:18 -07:00
Michael Niedermayer
64d029de41 avformat/matroskaenc: fix MAX_CUEPOINT_SIZE calculation
Fixes assertion failure
Fixes Ticket3822

as a side-effect this makes some mkv files a few bytes smaller

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-09 05:05:09 +02:00
Michael Niedermayer
d44b8f0a47 avformat/matroskaenc: print a warning when the relative timestamp wouldnt fit in 16bit
This is somewhat unusual so its better to use warning level than debug

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-24 20:25:29 +02:00
Michael Niedermayer
7923aa0fba avformat/matroskaenc: Start new cluster if relative timestamp could not otherwise be stored
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-24 18:19:50 +02:00
Michael Niedermayer
3c6e220a8c avformat/matroskaenc: Factor mkv_start_new_cluster() out
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-24 18:19:11 +02:00
Jan Gerber
73b7a360d8 matroskaenc: Don't set language to empty string, use "und"
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-20 14:03:00 +02:00
Michael Niedermayer
141ee10913 Merge commit '48e6432407a73d5006d84609456e6e0bc3dd8fc4'
* commit '48e6432407a73d5006d84609456e6e0bc3dd8fc4':
  matroska: Factor out mkv_write_stereo_mode

Conflicts:
	libavformat/matroskaenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-01 20:55:42 +02:00
Michael Niedermayer
ee78b0c252 Merge commit 'b75a1f9892b5b715397edbf837e4d4cda337907b'
* commit 'b75a1f9892b5b715397edbf837e4d4cda337907b':
  matroska: Factor out write_track from mkv_write_tracks

Conflicts:
	libavformat/matroskaenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-01 20:25:35 +02:00
Michael Niedermayer
8365287e61 Merge commit 'f1f6156b3fc9eb77b439d031ba18974d80b8341e'
* commit 'f1f6156b3fc9eb77b439d031ba18974d80b8341e':
  matroska: K&R formatting cosmetics

Conflicts:
	libavformat/matroskaenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-01 19:58:57 +02:00
Luca Barbato
48e6432407 matroska: Factor out mkv_write_stereo_mode 2014-07-01 16:43:20 +02:00
Luca Barbato
b75a1f9892 matroska: Factor out write_track from mkv_write_tracks 2014-07-01 16:43:01 +02:00
Luca Barbato
f1f6156b3f matroska: K&R formatting cosmetics 2014-07-01 16:42:32 +02:00
Vignesh Venkatasubramanian
c80181352c lavf/matroskaenc: Fix Cues on Audio for WebM DASH
Fix a change that was broken by [1]. Cues must be added for audio frames
on cluster start for WebM when the DASH flag is passed. Restoring
correct functionality.

[1] http://goo.gl/xYLq7Z

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-06 21:36:11 +02:00
Michael Niedermayer
955b31a751 Merge commit 'e19d48dfce52f1417f7f06143b96fed00cbcdc52'
* commit 'e19d48dfce52f1417f7f06143b96fed00cbcdc52':
  flac muxer: support reading updated extradata from side data

Conflicts:
	libavformat/flacenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-01 14:16:29 +02:00
Michael Niedermayer
754bf1212c Merge commit 'd2ef708c95ace2518deffe830a9c439aeb9edd5d'
* commit 'd2ef708c95ace2518deffe830a9c439aeb9edd5d':
  matroskaenc: Allow VP9 and Opus in webm

Conflicts:
	libavformat/matroskaenc.c

See: 820ffaed0f
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-01 12:00:20 +02:00
Anton Khirnov
e19d48dfce flac muxer: support reading updated extradata from side data 2014-06-01 08:32:33 +02:00
Tudor Suciu
d2ef708c95 matroskaenc: Allow VP9 and Opus in webm
Bug-Id: 695

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2014-06-01 07:50:00 +02:00
John Peebles
925f7980eb libavformat: output cues for each subtitle block in MKV muxer
Signed-off-by: John Peebles <johnpeeb@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-31 13:26:48 +02:00
Michael Niedermayer
4991eacc06 Merge commit '962d63157322466a9a82f9f9d84c1b6f1b582f65'
* commit '962d63157322466a9a82f9f9d84c1b6f1b582f65':
  matroskaenc: set the stream timebase earlier

Conflicts:
	tests/ref/lavf/mkv
	tests/ref/seek/lavf-mkv

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-29 13:43:04 +02:00
Michael Niedermayer
bc59d39b82 Merge commit '81eec081afea9fc017a175581ceea7c420a0dfc3'
* commit '81eec081afea9fc017a175581ceea7c420a0dfc3':
  matroskaenc: base DefaultDuration on the framerate, not the codec timebase

Conflicts:
	libavformat/matroskaenc.c
	tests/ref/lavf/mkv
	tests/ref/seek/lavf-mkv

See: ea83b032af
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-29 12:58:55 +02:00
Anton Khirnov
962d631573 matroskaenc: set the stream timebase earlier
Fixes calculating the ts offset for audio codecs with delay.
2014-05-29 08:01:58 +02:00
Anton Khirnov
81eec081af matroskaenc: base DefaultDuration on the framerate, not the codec timebase
This results in DefaultDuration not being written when the framerate is
not known, but as this field is purely informative, this should not
break any sane demuxers.
2014-05-29 08:00:57 +02:00
Vignesh Venkatasubramanian
c14045c818 lavf: Remove experimental flag for Opus in WebM
Opus in WebM is no more experimental as we have everything necessary in
the container writing code as per the spec. So removing the experimental flag.
Note that we removed the experimental suffix from the CodecId field long
ago ( http://goo.gl/O0TYRB ).

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-28 19:29:45 +02:00
Michael Niedermayer
cf3a038f50 avformat/matroskaenc: fix ident string
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-28 15:15:14 +02:00
Michael Niedermayer
61917a104e Merge commit '106b62f4ba600f24415eaded5e020aeceb23fd59'
* commit '106b62f4ba600f24415eaded5e020aeceb23fd59':
  matroskaenc: write the channel mask for FLAC

Conflicts:
	libavformat/matroskaenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-28 13:19:26 +02:00
Anton Khirnov
106b62f4ba matroskaenc: write the channel mask for FLAC 2014-05-28 07:55:14 +02:00
Vignesh Venkatasubramanian
37cef8c774 libavformat/matroskaenc: Add WebM DASH support
WebM DASH specification [1] requires the Clusters and Cues to be output in a
specific way. Adding a flag to matroskaenc that will enable support for
creating WebM/Mkv files conforming to the WebM DASH specification.

[1] http://wiki.webmproject.org/adaptive-streaming/webm-dash-specification

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-22 18:53:13 +02:00
Michael Niedermayer
0421409c52 avformat/matroskaenc: switch to AVFMT_FLAG_BITEXACT
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-18 04:04:01 +02:00
Michael Niedermayer
eacf7d650d Merge commit '0c1959b056f6ccaa2eee2c824352ba93c8e36d52'
* commit '0c1959b056f6ccaa2eee2c824352ba93c8e36d52':
  lavf: add AVFMT_FLAG_BITEXACT.

Conflicts:
	doc/APIchanges
	libavformat/avformat.h
	libavformat/flacenc.c
	libavformat/movenc.c
	libavformat/oggenc.c
	libavformat/options_table.h
	libavformat/version.h
	tests/fate/video.mak

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-15 19:16:57 +02:00
Anton Khirnov
0c1959b056 lavf: add AVFMT_FLAG_BITEXACT.
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.
2014-05-15 07:42:07 +02:00
Michael Niedermayer
f6d17d2aa9 avformat/matroskaenc: use av_mallocz_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-15 01:56:08 +02:00
Carl Eugen Hoyos
ab21acecc7 Use Matroska document version 2 for WebM files if possible.
Google's plugin for the Internet Explorer refuses to play
files with another document version.

Fixes ticket #3583.
2014-05-12 18:16:48 +02:00
Michael Niedermayer
82e4f39883 Merge commit 'a1aa37dd0b96710d4a17718198a3f56aea2040c1'
* commit 'a1aa37dd0b96710d4a17718198a3f56aea2040c1':
  matroskaenc: write CodecDelay

Conflicts:
	libavformat/matroskaenc.c
	tests/ref/lavf/mkv
	tests/ref/seek/lavf-mkv

This is largely not merged as it causes assertion failures and av sync errors
Further investigation of this is warranted if the changes are found to
fix/improve something in relation to d92b1b1bab

See: d92b1b1bab
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-01 15:56:38 +02:00
Anton Khirnov
a1aa37dd0b matroskaenc: write CodecDelay 2014-05-01 08:03:51 +02:00
Daniel Verkamp
5e7d21c7ad ff_put_wav_header: add flag to force WAVEFORMATEX
Partially undoes commit 2c4e08d89327595f7f4be57dda4b3775e1198d5e:

    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>
2014-04-30 16:41:35 +02:00
Michael Niedermayer
24725f8e09 avformat/matroskaenc: fix indention level
Fixes CID1206644
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-26 22:01:48 +02:00
Carl Eugen Hoyos
3d5c859fa6 Set Matroska private data when muxing Prores.
The specification requires the mov code point to be written as "fourcc".
2014-04-06 23:35:17 +02:00