Commit graph

118 commits

Author SHA1 Message Date
Nicolas Dufresne
2359ee29e8 qtmux: Correctly calculate the elst media start
The media start has nothing to do with the shift we have applied
but with the value of the first PTS. This is defined as:

  Dt(0) = 0
  Ct(0) = Dt(0) + CTTS(0)

So the media start is always the first CTTS.

https://bugzilla.gnome.org/show_bug.cgi?id=751361
2015-06-23 22:34:36 -04:00
Thiago Santos
1ec9a86e72 qtmux: store last_dts of the first buffer
Buffers need not to start at running-time 0 so the last_dts needs
to be the value of the first buffer's dts as it is used to compute
the duration of the buffers. If it was left at 0 the first buffer
would have a larger duration when it shouldn't

https://bugzilla.gnome.org/show_bug.cgi?id=751361
2015-06-23 22:34:35 -04:00
Nicolas Dufresne
7b8615d4fc qtmux: Use PTS to figure-out presence of gaps
We need to look at the presentation timestamp in order to conclude if
there is a gap at the start of a stream.

https://bugzilla.gnome.org/show_bug.cgi?id=751242
2015-06-22 17:45:30 -04:00
Nicolas Dufresne
feda525591 qtmux: Set edit list to compensate DTS shift
We shift DTS forward to avoid negative timestamps which cannot be
represented with version 0 of the CTTS table. To stick with that
version (backward compatibility), the spec recommend using an
edit list entry to move back the presentation time to where it
should be.

https://bugzilla.gnome.org/show_bug.cgi?id=751242
2015-06-22 17:45:30 -04:00
Nicolas Dufresne
12181efddc qtmux: Handle DTS with negative running time
As QT works with duration, simply bring back first DTS to 0 and shift
forward the PTS of the same amount.

https://bugzilla.gnome.org/show_bug.cgi?id=740575
2015-06-12 17:18:24 -04:00
Thiago Santos
ab18f5035c qtmux: add AC-3 muxing support
Adds AC-3 muxing support. It is defined for mp4 and 3gp formats.

One extra feature that was added was the ability to add extension
atoms after set_caps as the AC-3 extension atom needs some data
that has to be extracted from the stream itself and is not
present on caps.
2015-06-11 01:11:31 -03:00
Thiago Santos
f83fd7a88f qtmux: remove duplicate attribute value set
It is also set a few lines below
2015-06-11 01:11:18 -03:00
Jan Schmidt
23d610140d isomp4: fsync after sending updates in robust mode
Use the new GstBuffer SYNC_AFTER flag to trigger an fsync
after updating the moov or mdat atom, and after updating the free
atom to make it visible.
2015-06-08 14:49:11 +10:00
Jan Schmidt
3e17cd8acb isomp4: Only set moov header into streamheader at EOS
Only update the moov header into the caps if it's the finalised
moov at EOS time. Avoids posting a bogus moov at startup and
repeated updates in robust-recording mode
2015-06-08 14:49:11 +10:00
Jan Schmidt
1d058c7d8a isomp4: Implement robust muxing using ping-pong strategy
Implement a robust recording mode, where the output
file is always in a playable state, seeking and rewriting
the moov header at a configurable interval. Rewriting
moov is done using reserved space at the start of
the file, and a ping-pong strategy where the moov
is replaced atomically so it's never invalid.

Track when tags have actually changed, and don't write them into
the moov unless they've changed. Clear any existing tags when
re-writing them, so we can do progressive moov updating in robust
recording mode.

Write placeholder mdat as a free atom plus a 32-bit mdat
with '0' size, which means "rest of the file" in the spec.

Re-write it later to a full 64-bit extended size atom if needed.
2015-06-08 14:49:11 +10:00
Jan Schmidt
3d7b343525 isomp4: Update edit list when re-writing moov
Correctly update any edit lists each time the moov is recalculated,
updating existing table entries if they already exist instead of just
adding new ones.
2015-06-08 14:16:36 +10:00
Jan Schmidt
0c1bcc629d isomp4: Remove an extra bracket in a comment. 2015-06-08 14:16:36 +10:00
Thiago Santos
39c09284e2 qtmux: remove useless variable do_pts
We always write the CTTS in qtmux. Ideally we only want to do that
for streams that need DTS, it should be present on the track information
rather than be decided based on each buffer
2015-04-10 10:05:24 -03:00
Thiago Santos
5780afe131 qtmux: remove subtraction that makes PTS/DTS start from 0
As qt uses durations, it doesn't matter, only the difference
between consecutive buffers is important. Also, collectpads
already replaces PTS/DTS with the running times for them.
2015-04-10 10:05:24 -03:00
Jan Schmidt
fe739b7f88 isomp4: Refactor various state variables into a mux_mode var
Instead of checking various state variables around the muxer,
track the current muxing mode in a single 'mux_mode' enum.

Add some implementation notes about the different mux modes
2015-04-09 10:20:06 +10:00
Jan Schmidt
3d59b5f814 isomp4: Make non-seekable downstream an error in normal mode
When not in fast-start or fragmented mode, we need to be able
to rewrite the size of the mdat atom, or else the output just
won't be playable - the mdat placeholder with size == 0 will
cover the rest of the file, including any moov atom we write out.

https://bugzilla.gnome.org/show_bug.cgi?id=708808
2015-04-03 23:07:04 +11:00
Thiago Santos
84b7cf6795 qtmux: remove not needed condition
gst_buffer_replace can handle NULL inputs by itself
2015-02-18 10:36:06 -03:00
Thiago Santos
e52b2cb2cf qtmux: store stream and container tags separately
Tags received via events, when marked as stream tags, will
be stored on that stream's trak atom instead of being stored
in the main tags atom. This allows the resulting file to have
global and stream tags stored.

https://bugzilla.gnome.org/show_bug.cgi?id=692473
2015-01-31 17:23:01 -03:00
Thiago Santos
6321cdedb3 qtmux: refactor tags functions to accomodata UDTA at trak level
Refactor the functions that were bound to the 'moov' atom to
directly pass the desired 'udta' that should receive the tags.
This allows the tags to be written to 'udta' at the 'moov' or
the 'trak' level, creating tags that are for the container or
for a stream only.

https://bugzilla.gnome.org/show_bug.cgi?id=692473
2015-01-31 17:22:57 -03:00
Thiago Santos
f0fde8be88 qtmux: map application name to _swr tag
It refers to the application name and version used to create the
file

https://bugzilla.gnome.org/show_bug.cgi?id=692473
2015-01-31 17:22:44 -03:00
Sebastian Dröge
dc2251a664 qtmux: Add support for v210 2015-01-13 19:05:40 +01:00
Tim-Philipp Müller
aa94fc6beb qtmux: fix ALAC muxing
Actually copy the codec data instead of copying nothing
and then bombing out because there's no data.

Fixes: gst-launch-1.0 audiotestsrc ! avenc_alac ! qtmux ! fakesink

https://bugzilla.gnome.org/show_bug.cgi?id=741783
2014-12-25 21:37:49 +00:00
Matej Knopp
2505e343b1 qtmux: use 64bit chunk_offset
https://bugzilla.gnome.org/show_bug.cgi?id=741279
2014-12-10 18:42:30 -03:00
Tim-Philipp Müller
3956f5addc Sprinkle some G_PARAM_DEPRECATED and #ifndef GST_REMOVE_DEPRECATED 2014-11-02 16:58:30 +00:00
Matej Knopp
9f85dfd733 qtmux: Do not infer DTS on buffers from sparse streams.
DTS delta is used to calculate sample duration. If buffer has missing DTS, we take either segment start or previous buffer end time, whichever is later.
This must only be done for non sparse streams, sparse streams can have gaps between buffers (which is handled later by adding extra empty buffer with duration that fills the gap)

https://bugzilla.gnome.org/show_bug.cgi?id=737095
2014-09-23 22:25:47 -03:00
Matej Knopp
fd3e8c5672 qtmux: collect pad for sparse stream should be created with lock set to false
Avoids waiting for buffers from sparse streams

https://bugzilla.gnome.org/show_bug.cgi?id=737095
2014-09-23 15:25:45 -03:00
Matej Knopp
6695341583 qtmux: fix subtitle buffer duration and strip null termination
Strip the \0 off the subtitle as we already know the size and also remember
to set the duration as buffer copying doesn't do it.

https://bugzilla.gnome.org/show_bug.cgi?id=737095
2014-09-23 15:25:28 -03:00
Jan Schmidt
6e7930a10c qtmux: Make the default timescale 1/1800 second
The old default timescale of 1 millisecond produces irrational
numbers for a lot of framerate/audio-packet-duration multiples.
1/1800 is a nicer number, as it tends to produce better fractions
and therefore slightly higher accuracy overall
2014-08-15 13:03:52 +10:00
Jan Schmidt
d9e1aa4959 isomp4/qtmux: Write correct file duration when gaps exist.
When writing out a trak with an edit list, make sure the
overall file duration is also updated to reflect the
lengthening of the stream.

Add some more debug to qtdemux to warn about streams that
are longer than the file and get truncated.
2014-08-08 04:01:19 +10:00
Edward Hervey
112d948b7e qtmux: Free node_header in error cases
CID #1212134
2014-05-12 16:53:32 +02:00
Vincent Penquerc'h
1be86ebb2a qtmux: handle 0 size packets without dividing by 0
Coverity 1139691
2014-05-02 10:21:09 +01:00
Tim-Philipp Müller
c9597298f9 docs: remove outdated and pointless 'Last reviewed' lines from docs
They are very confusing for people, and more often than not
also just not very accurate. Seeing 'last reviewed: 2005' in
your docs is not very confidence-inspiring. Let's just remove
those comments.
2014-04-26 23:35:17 +01:00
Stefan Sauer
35da463618 docs: use the gtk-doc syntax to link to properties
Don't use docbook unless needed. Also stip other docbook tags in the the files we fix.
2014-02-18 22:35:00 +01:00
Thiago Santos
f5f27f7d0d qtmux: remove have_dts flag from pads
It was used in the past in 0.10 when there was no explicit DTS
field in buffers, now we have it in 1.x series and we can
check it directly with GST_BUFFER_DTS_IS_VALID
2014-02-07 13:10:25 -03:00
Thiago Santos
f89ba82f29 qtmux: improve support for sparse streams
Do not try to use subsequent buffer timestamps to calculate
sparse streams durations because the stream is sparse and
the buffers might not be 'time adjacent'. So rely on the
duration and give the option to the pad to provide
custom 'empty' buffers to represent the gaps in the
stream, this can vary on how the data is represented.

Right now, the only sparse stream supported is tx3g subtitles.
2014-02-07 13:10:24 -03:00
Thiago Santos
99e966e2e1 qtmux: add support for text/x-raw subtitles
Adds it to mp4mux, qtmux and gppmux.

Buffers need to be prefixed with 2 bytes for the text length before
being muxed.

https://bugzilla.gnome.org/show_bug.cgi?id=581295
2014-02-07 13:10:24 -03:00
Thiago Santos
2ae1897273 qtmux: add subtitle support to qtmuxmap structures
adds basic stubs for subtitle support around the qtmux and
qtmuxmap structures. Still no real subtitle implemented, but
basic functions in place

https://bugzilla.gnome.org/show_bug.cgi?id=581295
2014-02-07 13:10:24 -03:00
Sebastian Dröge
4a91a93d4e qtmux: Don't error out if downstream is not seekable for non-fragmented variants
Doing so would be a regression over 1.0 and breaks the unit test.
However the result will be most likely unusable, so let's post
a warning message on the bus.
2013-09-25 13:25:34 +02:00
Andoni Morales Alastruey
cfefdaebb6 qtmux: handle issues correctly when downstream is not seekable
The streamable property only make sense for fragmented formats.
For regular MP4, when downstream is not seekable we can't rewrite
the headers, so qtmux can only work with fast-start=TRUE, where
the headers are written finishing the file.
For fragmented MP4, when streamable is not seekable and the streamable
property is FALSE, we must enforce streamable=TRUE warning the user
about this change

https://bugzilla.gnome.org/show_bug.cgi?id=707242
2013-09-20 10:09:48 +02:00
Andoni Morales Alastruey
9ae5082204 qtmux: make "streamable" TRUE as default
The most common use case for fragmented MP4 (Dash and Smooth Streaming)
is producing streamable content (even for VOD). streamable=FALSE would only
be used to generate fragmented MP4 with and index of MOOF's that could
be reproduced without a playlist/manifest
https://bugzilla.gnome.org/show_bug.cgi?id=707242
2013-09-20 10:09:48 +02:00
Andoni Morales Alastruey
5732684e18 qtmux: deprecate the streamable property for non-fragmented MP4
The streamable property only makes sense for fragmented MP4.
https://bugzilla.gnome.org/show_bug.cgi?id=707242
2013-09-20 10:09:48 +02:00
Matej Knopp
b2982bb749 qtmux: remove MAX_TOLERATED_LATENESS
https://bugzilla.gnome.org/show_bug.cgi?id=707411
2013-09-16 11:11:12 -03:00
Matej Knopp
b363832c2c qtmux: set first_ts to DTS for streams that have DTS
https://bugzilla.gnome.org/show_bug.cgi?id=707340
2013-09-16 12:14:00 +02:00
Matej Knopp
39f7e52266 qtmux: make sure duration is a valid number for last buffer
https://bugzilla.gnome.org/show_bug.cgi?id=707340
2013-09-16 12:14:00 +02:00
Matej Knopp
4e3c13c87c qtmux: use segment.start or last buffer end time in case of missing DTS
https://bugzilla.gnome.org/show_bug.cgi?id=707340
2013-09-16 12:14:00 +02:00
Matej Knopp
85728c04c4 Revert qtmux: Use buffer PTS if DTS is not set"
This reverts commit f72c3cf71fde622067f41f31a53978ba4c94469d.

https://bugzilla.gnome.org/show_bug.cgi?id=707340
2013-09-16 12:13:54 +02:00
Edward Hervey
4f4f6432cc qtmux: Use buffer PTS if DTS is not set
Avoids ending up with completely bogus scaled duration/pts when new
buffers have invalid DTS.
2013-08-04 17:15:38 +02:00
Tim-Philipp Müller
ce52b319ff qtmux: when streaming don't try to seek when stopping
It might cause errors in sinks that are not seekable and
have reported this (like e.g. fdsink)

https://bugzilla.gnome.org/show_bug.cgi?id=696228
2013-07-19 17:31:38 +01:00
Matej Knopp
5686512b77 qtmux: use timestamp delta as duration if possible
https://bugzilla.gnome.org/show_bug.cgi?id=696437
2013-03-30 15:18:45 -07:00
David Schleef
c0443a17c4 qtmux: Fix test regression with one buffer streams 2013-03-22 15:14:15 -07:00