Commit graph

189 commits

Author SHA1 Message Date
Vivia Nikolaidou
5f7fe63fea qtmux: Do not check timecode data for mp4 container
Timecode trak is only supported for mov right now, not for mp4. That
code would otherwise create an invalid trak if the muxed video contained
timecode metadata.

https://bugzilla.gnome.org/show_bug.cgi?id=782684
2017-05-16 15:16:58 +03:00
Sebastian Dröge
347e814074 qtmux: When accepting renegotiation, just return TRUE and change nothing
We only accept new caps if they are basically the same. We don't want to
reset anything as if the caps are new, otherwise various state could get
out of sync with the current run.
2017-05-11 20:01:15 +02:00
Sebastian Dröge
10f4693163 qtmux: In prefill mode, only pad buffers with > 0 sized memories as needed
Adding a 0-byte memory has not much effect.

Also add some debug output.
2017-05-11 19:21:22 +02:00
Sebastian Dröge
63492ee141 qtmux: Lateness is in QT timescale, diff in GstClockTime
Print the right one in debug output to get meaningful numbers.
2017-05-10 15:58:41 +02:00
Sebastian Dröge
163b62fc25 qtmux: Error out if a gap edit list has to be written in prefill mode
We don't have any space reserved for this in the moov and the
pre-finalized moov would have broken A/V synchronization. Error out here
now
2017-05-10 14:31:40 +02:00
Sebastian Dröge
c0f505e80e qtmux: Calculate with reserved moov size instead of last moov size
We have some padding added after the initial moov, so a bigger updated
moov can be handled to some degree and is expected. Previously we just
ignored the padding and errored out in cases when the padding would've
just been enough.
2017-05-10 11:42:09 +02:00
Sebastian Dröge
419f53259f qtmux: Error out directly if sending filler data results in a flow error
CID 1405994
2017-05-10 11:12:23 +02:00
Sebastian Dröge
3fcfe774e6 qtmux: In prefill mode, handle the case when only the first chunk was ever used 2017-05-09 16:02:43 +02:00
Sebastian Dröge
55f949676e qtmux: Add new prefill recording mode
This sets up a moov with the correct sample positions beforehand and
only works with constant framerate, I-frame only streams.

Currently only support for ProRes and raw audio is implemented but
adding new codecs is just a matter of defining appropriate maximum frame
sizes.

https://bugzilla.gnome.org/show_bug.cgi?id=781447
2017-05-09 14:17:04 +02:00
Sebastian Dröge
f0163a016c qtmux: Error out on discontinuities/gaps when muxing raw audio
When muxing raw audio, we have no way of storing timestamps but are just
storing a continuous stream of audio samples. If the difference between
the expected and the real timestamp becomes to big, we should error out
instead of silently creating files with wrong A/V sync.

https://bugzilla.gnome.org/show_bug.cgi?id=780679
2017-05-09 14:16:51 +02:00
Sebastian Dröge
e51c08b0a2 qtmux: Fix timescale of timecode tracks
They should have ideally the same timescale of the video track, which we
can't guarantee here as in theory timecode configuration and video
framerate could be different. However we should set a correct timescale
based on the framerate given in the timecode configuration, and not just
use the framerate numerator.
2017-04-14 13:38:53 +03:00
Edward Hervey
7077425c3d qtmux: Don't forget to update pad->last_buf
buf is the current pad->last_buf value. If ever it gets copied/unreffed,
we need to make sure to write back the new  pointer to the last_buf
variable.

Fixes using wrong pointer values in the case of decrasing DTS value
2017-04-12 13:26:59 +02:00
Sebastian Dröge
d6b145df5f qtmux: Fix last_dts tracking for raw audio and similar formats
Accumulate the durations directly and don't scale yet another time by
the number of samples.
2017-04-10 15:55:54 +03:00
Sebastian Dröge
6f3737f0c5 qtmux: Simplify buffer refcounting in add_buffer() and remove unneeded NULL checks 2017-04-04 15:24:45 +03:00
Sebastian Dröge
6b889bea69 qtmux: Select the best pad based on the cached last_buf if any
last_buf is the one we're going to write next, not buf. As such we
should check timestamps against that one if there is one to select the
earliest pad.

Also remember the currently selected pad in the very beginning when
storing the first last_buf.

This both solves some edge cases where not the correct next pad was
selected corresponding to the target interleave.
2017-04-04 15:24:45 +03:00
Sebastian Dröge
eb307baff4 qtmux: Error out immediately if a timecode is to be written but downstream return not-OK 2017-04-04 15:24:45 +03:00
Sebastian Dröge
e66d75ec87 qtmux: Remove some unused variables 2017-03-23 17:53:54 +02:00
Sebastian Dröge
ebdaca603c qtmux: Remove a couple of unneeded levels of indentation 2017-03-23 15:02:03 +02:00
Sebastian Dröge
9c121b09a5 qtmux: Reset current chunk after writing out timecode
If we have multiple tracks with timecodes, or it's not the first track
that has timecodes, or not the first buffer, we already started a chunk
for media data. We now need to "close" that chunk because we wrote data
for the timecode track and a new chunk has to be started for the
original track the next time it has data.
2017-03-22 19:16:33 +02:00
Sebastian Dröge
cb6aab8685 qtmux: Do timecode handling per track, not per muxer instance
There could be multiple video tracks with timecodes.
2017-03-22 18:53:19 +02:00
Thiago Santos
7e39dec391 qtmux: avoid fallthrough to moovrecovery failure section
Return before that to preserve our successfull results, otherwise no
moov recovery information would be written

https://bugzilla.gnome.org/show_bug.cgi?id=771478
2017-03-14 20:27:48 -07:00
Emeric Grange
534be3313c qtmux: add CineForm support
https://bugzilla.gnome.org/show_bug.cgi?id=780024
2017-03-14 18:03:34 +02:00
Sebastian Dröge
6cb8c802f4 qtmux: Only create new chunks if we have more than a single stream
There's no point in creating multiple chunks otherwise, it only wastes
some bytes for storing the chunk offsets.
2017-03-14 15:09:44 +02:00
Wim Taymans
16f3fd6782 qtmux: init fourcc
Initialize the fourcc to 0 so that we can detect failure later.
2017-03-10 11:24:14 +01:00
Sebastian Dröge
0e62a0603d qtmux: Fix some memory leaks related to timecode tracks 2017-03-08 15:27:32 +02:00
Sebastian Dröge
7709920ca3 qtmux: Update modification times when sending the moov
https://bugzilla.gnome.org/show_bug.cgi?id=779422
2017-03-02 20:33:30 +02:00
Jan Schmidt
2987e66f22 qtmux: Add a comment about how atom_trak_set_elst_entry() works 2017-02-09 11:29:43 +11:00
Sebastian Dröge
1426a55a83 qtmux: Clear edit lists every time we recalculate them
We recalculate them, so any old information has to be forgotten.
Otherwise we write invalid edit lists when writing headers multiple
times.

https://bugzilla.gnome.org/show_bug.cgi?id=778330
2017-02-08 17:26:21 +02:00
Brendan Shanks
a9056a8a7e qtmux: Fix debug typo and remove misleading warning
https://bugzilla.gnome.org/show_bug.cgi?id=777362
2017-01-26 15:05:24 +02:00
Georg Lippitsch
d71c06c8fe qtmux: Don't write Sync Sample Atom for ProRes
https://bugzilla.gnome.org/show_bug.cgi?id=777331
2017-01-16 19:29:08 +02:00
Jan Schmidt
b0e38ed374 qtmux: Don't reset request pad numbering across uses
When reset, don't restart request pad numberings, as
request pads can survive across state changes. Only
restart at 0 if all request pads are handed back first.

https://bugzilla.gnome.org/show_bug.cgi?id=777174
2017-01-13 10:37:21 +11:00
Aurélien Zanelli
52d1355d87 qtmux: simplify video/x-h264 caps handling
'stream-format' and 'alignment' are defined in pad template caps so
there is no need to check them again here. Also remove bitrate parsing from
caps as bitrate in caps doesn't make sense but from tags, which is
actually the case.

https://bugzilla.gnome.org/show_bug.cgi?id=777181
2017-01-12 19:16:57 +02:00
Aurélien Zanelli
4c6a69fdff qtmux: add basic HEVC/H.265 muxing support
https://bugzilla.gnome.org/show_bug.cgi?id=736752
2017-01-12 19:16:23 +02:00
Georg Lippitsch
fcdba65302 qtmux: Calculate clean aperture size
Calculate clean aperture dimensions by first guessing
display aspect ratio based on pixel aspect ratio and
frame size.

https://bugzilla.gnome.org/show_bug.cgi?id=777100
2017-01-12 19:09:22 +02:00
Sebastian Dröge
e12c94065d qtmux: Write tapt atom for MOV files if PAR not 1/1
Needed for QuickTime 7 to properly play files.

Also write the clap atom for MOV files always, not only when ProRes is
used as a video codec. It's mandatory for MOV.

https://bugzilla.gnome.org/show_bug.cgi?id=777100
2017-01-12 19:09:22 +02:00
Jan Schmidt
12ad37fdb3 qtmux: Write tfdt atom into fragmented files.
The DASH spec requires that tfdt atoms be present, so
write one out. ISO/IEC 23009-1:2014 6.3.4.2

https://bugzilla.gnome.org/show_bug.cgi?id=708221
2017-01-08 01:23:52 +11:00
Sebastian Dröge
01682ae95b qtmux: Make sure to only change DTS of writable buffers
And trivial cleanup

https://bugzilla.gnome.org/show_bug.cgi?id=774840
2016-11-23 18:17:06 +02:00
Sebastian Dröge
01e45b25b7 qtmux: Error out much earlier if we don't have a valid PTS
https://bugzilla.gnome.org/show_bug.cgi?id=774840
2016-11-23 18:17:06 +02:00
Sebastian Dröge
6fb5f85354 qtmux: Only use buffer durations if they are actually valid
https://bugzilla.gnome.org/show_bug.cgi?id=774840
2016-11-23 18:17:06 +02:00
Sebastian Dröge
351f2fca0a qtmux: Revert commits that set DTS and duration on buffers unconditionally
39f7e52266 was setting the buffer duration
to 0 if is not valid, under the assumption that this is "the last"
buffer and no others are coming next. This is wrong, last_buf is the
previous buffer and not the very last one.

4e3c13c87c was setting DTS to 0 if there
was none. This will set DTS to 0 for all e.g. audio streams, completely
messing up calculations if streams don't start at 0.

https://bugzilla.gnome.org/show_bug.cgi?id=774840
2016-11-23 18:17:06 +02:00
Sebastian Dröge
9acc0b5d0e qtmux: Only write "gap" edit list if there is a non-zero gap
https://bugzilla.gnome.org/show_bug.cgi?id=774840
2016-11-23 18:17:06 +02:00
Sebastian Dröge
7fb278d7d2 qtmux: Always write edit lists for the tracks to give a more accurate duration
Always write an edit list for the whole track. In general this is not
necessary except for the case of having a gap or DTS adjustment but
it allows to give the whole track's duration in the usually more
accurate media timescale.

https://bugzilla.gnome.org/show_bug.cgi?id=774403
2016-11-19 13:53:34 +02:00
Sebastian Dröge
09c4cc55f2 qtmux: Don't deref NULL pads in debug output
That tends to crash.
2016-11-02 14:33:28 +02:00
Sebastian Dröge
c709abbb99 qtmux: Use a default interleave of 250ms for all codecs
https://bugzilla.gnome.org/show_bug.cgi?id=773217
2016-11-01 20:41:22 +02:00
Sebastian Dröge
4eaf5ea062 qtmux: Use a default interleave when ProRes is used
The ProRes guidelines suggest an interleave of 0.5s is common, but
specifies that for ProRes at most 2MB (for SD) and 4MB (for HD) should
be used per chunk.

It might also make sense to use similar numbers in general.

https://bugzilla.gnome.org/show_bug.cgi?id=773217
2016-11-01 20:41:22 +02:00
Sebastian Dröge
c2225781bb qtmux: Allow configuring the interleave size in bytes/time
Previously we were switching from one chunk to another on every single
buffer. This wastes some space in the headers and, depending on the
software, might depend in more reads (e.g. if the software is reading
multiple samples in one go if they're in the same chunk).

The ProRes guidelines suggest an interleave of 0.5s is common, but
specifies that for ProRes at most 2MB (for SD) and 4MB (for HD) should
be used per chunk. This will be handled in a follow-up commit.

https://bugzilla.gnome.org/show_bug.cgi?id=773217
2016-11-01 20:41:22 +02:00
Sebastian Dröge
cba6cc4fd4 qtmux: Set compressor name, horizontal/vertical resolution and depth for ProRes
This is also required by some software to handle ProRes files.

https://bugzilla.gnome.org/show_bug.cgi?id=769048
2016-11-01 20:41:22 +02:00
Sebastian Dröge
7b565475bf qt: Add support for ProRes 4444 XQ
And also 4444 in the muxer.

https://bugzilla.gnome.org/show_bug.cgi?id=769048
2016-11-01 20:41:22 +02:00
Sebastian Dröge
a2c6921482 qtmux: Write 'clap' atom for ProRes
It's required for ProRes to work with other software.

It is also in the MP4 standard, but inventing values here seems a bit
tricky for the general case and it does not really give any extra
information.

https://bugzilla.gnome.org/show_bug.cgi?id=769048
2016-11-01 20:41:22 +02:00
Sebastian Dröge
53e436883a qtmux: Always write colr atom with the colorimetry information
https://bugzilla.gnome.org/show_bug.cgi?id=772181
2016-11-01 20:41:22 +02:00