Commit graph

267 commits

Author SHA1 Message Date
Thibault Saunier 5ff769d731 Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
Matthew Waters f441c72e5a isomp4: also allow muxing different h264/5 profiles/levels/etc
All of that is advertised through the codec_data itself so can change
just fine within isomp4.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1071>
2021-09-13 09:42:15 +00:00
Ruslan Khamidullin f510d48ecf qtmux: for Apple ProRes, allow overriding pixel bit depth for 4:4:4:4 variants
e.g. when exporting an opaque image, yet with alpha channel.

Apple ProRes certification requires that, when a ProRes-writing
application *knows* that the entire frame is opaque, the application
writes only RGB without alpha even when the clip is RGBA. For that,
this tiny change allows the app to override pixel depth when writing ProRes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1061>
2021-08-24 12:35:47 +00:00
Matthew Waters 6605174358 isomp4/mux: add a function for seeking to a specific output byte position
We do it enough times that this makes sense.  Also add a debug log line
for the seek position requested.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1060>
2021-08-23 04:17:36 +00:00
Matthew Waters 0d27e6f86e isomp4: actually make streamable fallback work
We weren't setting the fragment_mode field anymore now that the
implementation doesn't change based on the value of the streamable
property.  This lead to invalid files.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1060>
2021-08-23 04:17:36 +00:00
Matthew Waters d806486503 isomp4: fix trun data offset handling
The trun offset was missing a calculation for one of the box type
headers.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/866

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1060>
2021-08-23 04:17:36 +00:00
Matthew Waters 467829358c isomp4/mux: fixes for fragmented mp4 output
Various buffer offset calculations were not quite correct in all cases.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/866

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1060>
2021-08-23 04:17:36 +00:00
Mathieu Duponchelle cb75eda13b isomp4/qtmux: allow renegotiating when tier / level / profile change
Those are carried either in codec_data or in-band SPS (for avc3),
and it is OK for those to change, though decoders obviously need
to support it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1047>
2021-08-20 00:16:43 +00:00
Mathieu Duponchelle 896c49cf49 isomp4/qtmux: accept video/x-h264, stream-format=avc3
The main difference between avc1 and avc3 is that avc3 is allowed
to contain in-band SPS / PPS. In practice decoders will always use
in-band parameter sets anyway, but it is cleaner to explicitly
advertise it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1047>
2021-08-20 00:16:43 +00:00
Mathieu Duponchelle fa835d686f isomp4/qtmux: make sure to switch to next chunk on new caps
For example, with single video sink pad, and new codec_data is
received, current_chunk_offset must be reset to -1 for the
aggregate loop to open a new chunk.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1047>
2021-08-20 00:16:43 +00:00
Seungha Yang adae01e4c3 qtmux: Don't need to update track per GstCaps if it's not changed
Skip GstQTMuxPad::set_caps() call for duplicated caps.
All the processing done in set_caps() method for duplicated caps
are redundant.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1019>
2021-07-02 06:22:41 +00:00
Jan Schmidt fae29cb3c2 qtmux: Protect against writing absurd sample durations
If the input DTS goes backward or is missing, the calculated
sample duration goes negative and wraps around to a very big
number. In that case, just write a sample with a duration of
0 and hope the problem is transient.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/914>
2021-04-13 00:18:36 +10:00
Stéphane Cerveau 2cce1247da isomp4: allow per feature registration
Split plugin into features including
dynamic types which can be indiviually
registered during a static build.

More details here:

https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/876>
2021-03-29 12:45:22 +02:00
Matthew Waters 9d74a60810 qtmux: support muxing multiple codec_data for h264/h265
Each codec_data is put into its own SampleTableEntry inside the stsd.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/787>
2020-11-02 03:32:50 +00:00
Jan Schmidt 537e7d873a qtmux: Chain up when releasing pad, and fix some locking.
Release pads by calling up into aggregator so it can do the right
things. Don't clean up the pad until after that.

 Add some missing locks around some accesses to shared pad state.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/797>
2020-10-31 02:01:10 +00:00
Thibault Saunier 6eef0967b9 isomp4: Rename GstQTMux to GstBaseQTMux to avoid breaking API
Since 52b63de19a the qtmux GType was
renamed GstQTMuxElement which breaks presets, revert that change.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/755>
2020-09-30 09:18:13 -03:00
Matthew Waters 7736a21659 qtmux: output the correct limits in error messages
Having the current bytes being less than the limit was confusing!

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/732>
2020-09-28 15:37:12 +10:00
Matthew Waters e81ce6f2d7 qtmux: properly support initial caps nego failure
Scenario:
- gap event causes h264parse to push made up caps that may fail checks
  inside qtmux (e.g missing codec_data).
- the caps event has already been marked as received and is sticky on
  the sink pad
- gst_qt_mux_pad_can_renegotiate() will retrieve the failed caps event
  using gst_pad_get_current_caps() and reject the correct updated caps
  with codec_data.
- Failure!

Keep track of the configured caps ourselves instead of relying on the
sticky event on the pad.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/732>
2020-09-28 15:37:12 +10:00
Matthew Waters b27dc540d0 qtmux: support non-seekable downstream mode
Write an mdat per buffer in that case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/732>
2020-09-28 15:37:12 +10:00
Matthew Waters e64227f585 qtmux: make documentation happy
introduce a base qtmux class that we can install documentation snippets
on instead of duplicating across alll the isomp4 elements

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/643>
2020-09-21 12:09:09 +10:00
Matthew Waters 52b63de19a isomp4/mux: add a fragment mode for initial moov with data
Used by some proprietary software for their fragmented files.

Adds some support for multi-stream fragmented files

Flow is as follows.
1. The first 'fragment' is written as a self-contained fragmented
   mdat+moov complete with an edit list and durations, tags, etc.
2. Subsequent fragments are written with a mdat+moof and each stream is
   interleaved as data arrives (currently ignoring the interleave-*
   properties).  data-offsets in both the traf and the trun ensure
   data is read from the correct place on demuxing.  Data/chunk offsets
   are also kept for writing out the final moov.
3. On finalisation, the initial moov is invalidated to a hoov and the
   size of the first mdat is extended to cover the entire file contents.
   Then a moov is written as regularly would in moov-at-end mode (the
   default).

This results in a file that is playable throughout while leaving a
finalised file on completion for players that do not understand
fragmented mp4.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/643>
2020-09-21 12:08:14 +10:00
Sebastian Dröge 54bc0157b5 qtmux: Don't lock object lock twice in prefill mode
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/762

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/663>
2020-07-07 12:36:01 +03:00
Jordan Petridis 3e2420361a Use gst_element_class_set_metadata when passing dynamic strings
gst_element_class_set_metadata is meant to only be used with
static or inlined strings, which isn't the case for the 2 elements
here resulting in use-after-free later on.

https://gstreamer.freedesktop.org/documentation/gstreamer/gstelement.html?gi-language=c#gst_element_class_set_static_metadata

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/622>
2020-06-11 20:39:33 +03:00
Mathieu Duponchelle f63299ff2f plugins: uddate gst_type_mark_as_plugin_api() calls 2020-06-06 00:42:25 +02:00
Mathieu Duponchelle 37c619f995 plugins: Use gst_type_mark_as_plugin_api() for all non-element plugin types 2020-06-03 22:44:09 -04:00
Sebastian Dröge cf3fbf57bf qtmux: Add property for enforcing the creation of chunks in single-stream files
This is disabled by default as it unnecessarily creates bigger headers
but it is something that is required by some applications and most
notably the Apple ProRes spec.
2020-04-06 16:25:59 +03:00
Vivia Nikolaidou 5817c659e6 qtmux: Add option to create a timecode trak in non-mov flavors
Even if timecode trak is officially unsupported in non-mov flavors,
some software still supports it, e.g. Final Cut Pro X:

https://developer.apple.com/library/archive/technotes/tn2174/_index.html

The user might still expect to see the timecode information in the
non-mov file despite it being officially unsupported , because other
software e.g. QuickTime will create a timecode trak even in mp4 files.
Furthermore, software that supports timecode trak in non-mov flavors
will also display the file duration in "timecode units" instead of real
clock time, which is not necessarily the same for 29.97 fps and friends.
This might confuse users, who see a different duration for the same
framerate and amount of frames depending on whether the container is mp4
or mov.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/512
2020-04-03 18:19:38 +00:00
Sebastian Dröge d427b9bddf qtmux: Error out instead of crashing if reserved-max-duration is 0 or no samples could be created in prefill mode 2020-03-27 10:35:04 +00:00
Seungha Yang 4f443c81cf qtmux: Fix build warning
gstqtmux.c(644): warning C4133: '=':
  incompatible types - from 'gboolean (__cdecl *)(GstAggregator *,GstAggregatorPad *,GstEvent *)'
  to 'GstFlowReturn (__cdecl *)(GstAggregator *,GstAggregatorPad *,GstEvent *)'
2020-03-19 19:20:05 +00:00
Mathieu Duponchelle 56e5243f03 qtmux: fix renegotiation check
By the time sink_event is called, the pad's current caps have
already been updated. To address this, implement sink_event_pre_queue,
and check if the pad can be renegotiated there.

Fixes #707
2020-03-19 23:34:52 +11:00
Jan Schmidt 54f68ff36b qtmux: Remove warning in the log for mono video
Vanilla mono video was generating a spurious warning into the debug log
that's just misleading. Handle mono caps explicitly to avoid the warning.
2020-03-04 04:14:40 +00:00
Sebastian Dröge 35a1cedb97 qtmux: Add support for 8k resolutions in prefill mode with ProRes 2020-02-25 15:46:44 +02:00
Mathieu Duponchelle 5766731bd4 qtmux: protect access to GstElement.sinkpads 2019-12-16 14:17:38 +00:00
Mathieu Duponchelle e2462005fb qtmux: port to GstAggregator 2019-12-16 14:17:38 +00:00
Patricia Muscalu 203ad39d53 qtmux: Fix memory leak while pushing fragmented data
The memory leak occurs in the case when the buffer has been
added to the fragment_buffers array of the current pad and
never been sent because of the push failure of the previous
buffers: moof or mdat header or fragmented buffer(s).
2019-10-24 10:21:11 +00:00
Aaron Boxer 46989dca96 documentation: fix a number of typos 2019-10-05 22:38:11 +00:00
Seungha Yang 2ef74f2c81 qtmux: Fix incompatible type warning with MSVC
gstqtmux.c(5582): warning C4133: 'function':
  incompatible types - from 'GstVideoMultiviewFlags *' to 'guint *'
2019-09-02 15:07:17 +00:00
Mathieu Duponchelle 3429ddde38 docstrings: port ulinks to markdown links 2019-08-23 18:56:01 +02:00
Sebastian Dröge 2bed2687bb qtmux: Use size of first closed caption buffer in prefill mode
It must be accurate for all samples to work in Final Cut properly, so
the best we can do is to assume that all samples are the same as the
first. Bigger samples are truncated, smaller samples are padded.
2019-06-03 12:46:34 +03:00
Mathieu Duponchelle d704790519 doc: fix element section documentations
Element sections were not rendered anymore after the hotdoc
port, fixing this revealed a few incorrect links.
2019-05-25 16:57:31 +02:00
Thibault Saunier 232e3682ea Mark some properties as DOC_SHOW_DEFAULT 2019-05-13 10:24:40 -04:00
Thibault Saunier 0a6a62aa76 docs: Port all docstring to gtk-doc markdown 2019-05-13 10:24:40 -04:00
Vivia Nikolaidou 92272b5e5c qtmux: Only write timecode trak for video
Recent changes in ccextractor were attaching timecode meta to the closed
caption track. We shouldn't write timecode information for the closed
caption trak.
2019-02-08 14:13:46 +02:00
Sebastian Dröge 4f7ef56c53 isomp4: Replace GST_VIDEO_CAPTION_TYPE_CEA608_IN_CEA708_RAW with CEA608_S334_1A
For the demuxer we have to select line offset 0 for the time being as
this information is not passed over MOV.
2018-12-15 21:31:20 +00:00
Sebastian Dröge 830e7dc14b qtmux: Set timescale of closedcaption tracks to the one of the main video track 2018-12-06 16:05:50 +00:00
Alicia Boya García 5fcb7f715a qtmux: round to nearest when computing mehd and tkhd duration
This fixes a bug where in some files mehd.fragment_duration is one unit
less than the actual duration of the fragmented movie, as explained below:

mehd.fragment_duration is computed by scaling the end timestamp of
the last frame of the movie in (in nanoseconds) by the movie timescale.

In some situations, the end timestamp is innacurate due to lossy conversion to
fixed point required by GstBuffer upstream.

Take for instance a movie with 3 frames at exactly 3 fps.

$ gst-launch-1.0 -v videotestsrc num-buffers=3 \
  ! video/x-raw, framerate="(fraction)3/1" \
  ! x264enc \
  ! fakesink silent=false

dts: 999:59:59.333333334,  pts: 1000:00:00.000000000, duration: 0:00:00.333333333
dts: 999:59:59.666666667,  pts: 1000:00:00.666666666, duration: 0:00:00.333333334
dts: 1000:00:00.000000000, pts: 1000:00:00.333333333, duration: 0:00:00.333333333

The end timestamp is calculated by qtmux in this way:

end timestamp = last frame DTS + last frame DUR - first frame DTS =
  = 1000:00:00.000000000 + 0:00:00.333333333 - 999:59:59.333333334 =
  = 0:00:00.999999999

qtmux needs to round this timestamp to the declared movie timescale, which can
ameliorate this distortion, but it's important that round-neareast is used;
otherwise it would backfire badly.

Take for example a movie with a timescale of 30 units/s.

0.999999999 s * 30 units/s = 29.999999970 units

A round-floor (as it was done before this patch) would set fragment_duration to
29 units, amplifying the original distorsion from 1 nanosecond up to 33
milliseconds less than the correct value. The greatest distortion would occur
in the case where timescale = framerate, where an entire frame duration would
be subtracted.

Also, rounding is added to tkhd duration computation too, which
potentially has the same problem.

https://bugzilla.gnome.org/show_bug.cgi?id=793959
2018-10-27 13:12:56 +01:00
Sebastian Dröge 01a2119ad0 qtmux: Add property for providing a threshold after which we create an edit list for gaps at the start
https://bugzilla.gnome.org/show_bug.cgi?id=797290
2018-10-22 12:29:23 +01:00
Vivia Nikolaidou 09904e59df qtmux: Allow up to 1% of frame rate for lateness
https://bugzilla.gnome.org/show_bug.cgi?id=797290
2018-10-16 16:05:46 +03:00
Sebastian Dröge c6e07a6eee qtmux: Set Closed Caption track width/height to that of the first video track
Otherwise software like Premiere or Final Cut Pro won't like our files.

https://bugzilla.gnome.org/show_bug.cgi?id=797111
2018-09-20 11:35:31 +03:00
Sebastian Dröge 54a5b3f845 qtmux: Initialize caption track language code to 0 instead of "und"
Without this, Final Cut considers it "non-standard" and 0 (english) is a
good default for closed captions.

https://bugzilla.gnome.org/show_bug.cgi?id=797111
2018-09-18 17:32:46 +03:00