Commit graph

79 commits

Author SHA1 Message Date
John Nikolaides
6fe214e7a9 splitmuxsink: Added a split-at-running-time action signal
The video file can now be split at an arbitrary time, given by the user
as an argument to the action signal.

https://bugzilla.gnome.org/show_bug.cgi?id=787922
2018-09-28 16:53:29 +03:00
Mathieu Duponchelle
9605028a71 splitmuxsink: Implement split-after
The behaviour of split-now is to output the current GOP after
starting a new file.

The newly-added split-after signal will output the current GOP
to the old file if possible once a new GOP is opened.

https://bugzilla.gnome.org/show_bug.cgi?id=796982
2018-09-21 16:31:34 +02:00
Mathieu Duponchelle
bfcddb7125 mp4 robust muxing: improve documentation and logging 2018-08-16 19:43:50 +02:00
Jan Schmidt
5da08a21c6 splitmuxsink: Don't leak old muxer/sink in async mode
Make sure to clear the reference taken earlier in the function
when switching muxer/sink asynchronously so they don't leak
2018-08-15 02:28:20 +10:00
Jan Schmidt
f8076e208b splitmuxsink: Fix reference counting loop
The stream context was holding a reference to the
internal queue and pads, with pad probes that were
in turn holding references to the stream context.

This lead to a leak if the request pads weren't explicitly
released.

https://bugzilla.gnome.org/show_bug.cgi?id=796893
2018-08-15 02:12:53 +10:00
Jan Schmidt
f672116c72 splitmux: Improve handling of repeated timestamps
When handling input with timestamps that repeat, sometimes
splitmuxsink would get confused and ignore a keyframe.

The logic in question is a holdover from before the cmd queue
moved the file cutting to the multiqueue output side and made
it deterministic, so it's no longer needed on the input
here.

https://bugzilla.gnome.org/show_bug.cgi?id=796773
2018-07-17 10:57:42 +10:00
Vivia Nikolaidou
d11339d616 splitmuxsink: Added new async-finalize mode
This mode is useful for muxers that can take a long time to finalize a
file. Instead of blocking the whole upstream pipeline while the muxer is
doing its stuff, we can unlink it and spawn a new muxer+sink combination
to continue running normally.

This requires us to receive the muxer and sink (if needed) as factories,
optionally accompanied by their respective properties structures. Also
added the muxer-added and sink-added signals, in case custom code has to
be called for them.

https://bugzilla.gnome.org/show_bug.cgi?id=783754
2018-05-24 12:47:24 +03:00
Vivia Nikolaidou
498ebc5503 splitmuxsink: Added caption_%u pad template
For closed-caption-enabled muxers (e.g. qtmux)
2018-05-11 16:39:46 +03:00
Vivia Nikolaidou
7d7c90bf5c splitmuxsink: Don't send fragment-opened-closed message if the reference ctx is NULL
It can happen during teardown that the reference context becomes NULL.
In that case, trying to send the fragment-opened-closed message would
lead to a crash.
2018-04-11 17:59:21 +03:00
Sebastian Dröge
6d7242925b splitmuxsink: Run gst_iterator_foreach() as long as it returns GST_ITERATOR_RESYNC
CID 1434160
2018-04-11 09:21:19 +02:00
Sebastian Dröge
0f1770f2bd splitmuxsink: Add new reset-muxer property
With this the muxer is not set to NULL after each segment but instead
only flush events are sent to it to reset the EOS state.

As a result, the muxer will keep stream state and e.g. mpegtsmux will
keep the packet continuity counter continuous between segments as needed
by hlssink2.

https://bugzilla.gnome.org/show_bug.cgi?id=794816
2018-04-03 14:37:44 +03:00
Sebastian Dröge
42f5f3d1be splitmuxsink: Allow splitting at exactly the time/bytes threshold
76e458a119 changed the conditions from
"queued > threshold" to "queued >= threshold", which broke hlssink2 and
resulting in too small fragments being created although keyframes would
be at *exactly* the configured threshold.

https://bugzilla.gnome.org/show_bug.cgi?id=794440
2018-03-19 12:23:47 +02:00
Justin Kim
ad8a6cb639 qtmux: send stream warning when refusing video caps
If codec_data is changed, the stream is no longer valid.
Rather than keeping running when refusing new caps,
this patch send a warning  to the bus.

Also fix up splitmuxsink to ignore this warning while changing caps.

https://bugzilla.gnome.org/show_bug.cgi?id=790000
2018-02-01 10:12:46 +00:00
John Nikolaides
91dfc20a04 splitmuxsink: added a "split now" action signal
Now, the video file can be split at an arbitrary time chosen by the user.

https://bugzilla.gnome.org/show_bug.cgi?id=787922
2017-12-08 21:16:15 +02:00
Jan Schmidt
76e458a119 splitmuxsink: Use muxer reserved space properties if present.
If the use-robust-muxing property is set, check if the
assigned muxer has reserved-max-duration and
reserved-duration-remaining properties, and if so set
the configured maximum duration to the reserved-max-duration
property, and monitor the remaining space to start
a new file if the reserved header space is about to run out -
even though it never ought to.
2017-11-25 00:56:11 +11:00
Jan Schmidt
3a813a0dcc splitmux: Fix file switch-on-caps-change.
Switching to a new fragment because the input caps have
changed didn't properly end the previous file. Use the normal
EOS sequence to ensure that happens. Add a test that it works.
2017-11-24 16:56:03 +11:00
Vivia Nikolaidou
96cd941788 splitmux: Drop allocation queries
They can cause us to deadlock, while we're waiting for a new frame and
upstream is waiting for the allocation query to be answered before
sending a frame

https://bugzilla.gnome.org/show_bug.cgi?id=783753
2017-06-13 18:29:37 +03:00
Vivia Nikolaidou
a910329f6d splitmuxsink: Add alignment-threshold argument
If a non-reference stream is behind the reference stream by an amount of
time smaller than the alignment threshold (in nsec), it counts as being
after it.

https://bugzilla.gnome.org/show_bug.cgi?id=782563
2017-05-16 15:30:52 +03:00
Sebastian Dröge
fe77e2efe8 splitmuxsink: Don't use an explicit name for requesting audio pads
... unless the muxer uses the same audio pad template name as
splitmuxsink. We can't request a pad called "audio_0" on a muxer that
wants pads to be "sink_%d".
2017-04-20 13:17:33 +01:00
Xavier Claessens
6b42569ded splitmuxsink: Correctly catch FLUSH events in probes
https://bugzilla.gnome.org/show_bug.cgi?id=767498
2017-04-20 20:17:35 +10:00
Olivier Crête
d8868c6339 splitmuxsink: Change files on incompatible caps
https://bugzilla.gnome.org/show_bug.cgi?id=761761
2017-02-17 15:11:02 -05:00
Olivier Crête
f79a7afac2 splitmuxsink: Reset ready_for_output on state change
https://bugzilla.gnome.org/show_bug.cgi?id=761761
2017-02-17 15:11:02 -05:00
Olivier Crête
c98d932fb8 splitmuxsink: Remove unused muxed_out_time
https://bugzilla.gnome.org/show_bug.cgi?id=761761
2017-02-17 15:11:02 -05:00
Vivia Nikolaidou
05db87de21 splitmuxsink: Add option for timecode-based split
If this option is given, it will calculate the next split point based on
timecode difference.

https://bugzilla.gnome.org/show_bug.cgi?id=774209
2017-01-13 10:37:32 +11:00
Vivia Nikolaidou
394be2c318 splitmuxsink: Return a bin with a "location" property as a sink
Splitmuxsink might be called with a custom bin as a sink. If it has a
"location" property, it can be used.
2017-01-03 01:34:02 +11:00
Jan Schmidt
335c9f28d6 splitmux: Rewrite buffer collection and scheduling
Majorly change the way that splitmuxsink collects
incoming data and sends it to the output, so that it
makes all decisions about when / where to split files
on the input side.

Use separate queues for each stream, so they can be
grown individually and kept as small as possible.

This removes raciness I observed where sometimes
some data would end up put in a different output file
over multiple runs with the same input.

Also fixes hangs with input queues getting full
and causing muxing to stall out.
2017-01-03 01:34:02 +11:00
Jan Schmidt
f7009eb5d7 splitmuxsink: Add format-location-full signal
Add a new signal for formatting the filename, which receives
a GstSample containing the first buffer from the reference
stream that will be muxed into that file.

Useful for creating filenames that are based on the
running time or other attributes of the buffer.

To make it work, opening of files and setting filenames is
now deferred until there is some data to write to it,
which also requires some changes to how async state changes
and gap events are handled.
2017-01-03 01:34:02 +11:00
Vinod Kesti
11fd0e6120 splitmuxsink: pad request fails for flvmux
splitmuxsink requests pad from element using pad template like "video_%u", "audio_%u" and "sink_%d". This is true for most of the muxers.
But splitmuxsink not able to request pad to flvmux as flvmux has "audio" and "video" as pad templates.
fix: splitmuxsink should fallback to "audio" and  "video" when template not found.

https://bugzilla.gnome.org/show_bug.cgi?id=774507
2016-11-17 23:19:44 +11:00
Vivia Nikolaidou
bbd4dd2fb1 splitmuxsink: Use first buffer TS as mux start time
Do not use last buffer TS + buffer duration because buffer duration
might be inaccurate, especially for frame rates like 30fps where a
rounding error is observed.

https://bugzilla.gnome.org/show_bug.cgi?id=773785
2016-11-08 21:09:12 +11:00
Jan Schmidt
8ff5dd8029 splitmuxsink: Fix GObject warnings on shutdown.
Commit 83e718 added a pad template to splitmux request
pads, which means that GstElement now releases the pads on
dispose, but after having removed all elements in the bin
and unlinked them. Make sure we can handle cleanup in that case
without throwing assertions.

https://bugzilla.gnome.org/show_bug.cgi?id=773784
2016-11-02 11:02:12 +11:00
Jan Schmidt
5067d7254f splitmuxsink: Only allow one video request pad
The pacing of the overall muxing is controlled
by the video GOPs arriving, so we can only handle
1 video stream, and the request pad is named accordingly.

Ignore a request for a 2nd video pad if there's already
an active one.
2016-10-26 20:17:40 +11:00
Jan Schmidt
917776730d splitmuxsink: Take ownership of floating refs
sink the floating ref when handed a muxer or sink to use so
we clearly take ownership.
2016-10-26 20:17:40 +11:00
Jan Schmidt
a80265d65a splitmuxsink: Set child elements to NULL when removing.
Make sure that elements are in the NULL state when removing.
Fixes critical warnings when errors occur early on in starting up.
2016-10-26 20:17:40 +11:00
Jan Schmidt
83e7182b30 splitmuxsink: Set pad template on request sink pads
Ensure that the ghost pad returned as a request pad
has the template that was requested
2016-10-26 20:17:40 +11:00
Tim-Philipp Müller
78bb4cc7e2 splitmuxsink: fix printf format compiler warning in debug message
On 32-bit x86: gstsplitmuxsink.c:966:31: warning: format ‘%u’ expects
argument of type ‘unsigned int’, but argument 9 has type
‘guint64 {aka long long unsigned int}’
2016-08-22 00:07:51 +01:00
Jie Jiang
655856deee Fixed splitmuxsink 32-bit overflow bug
Extend the byte tracking counters to 64-bit on
all platforms, instead of using gsize, which overflows
after 4GB.

https://bugzilla.gnome.org/show_bug.cgi?id=770019
2016-08-20 19:53:11 +10:00
Vivia Nikolaidou
b9a8188704 splitmuxsink: Add option to split at exactly max-size-time
Will try to request a keyframe from the encoder to be sent at the target
running time.

https://bugzilla.gnome.org/show_bug.cgi?id=769664
2016-08-17 17:42:55 +10:00
Vivia Nikolaidou
369d37d227 splitmuxsink: Allow time and bytes to reach their respective thresholds
https://bugzilla.gnome.org/show_bug.cgi?id=769664
2016-08-17 17:42:55 +10:00
Jan Schmidt
75b601bbd4 splitmux: Fix typo converting to running time.
Use the correct collected timestamp.
2016-08-08 13:49:19 +10:00
Jan Schmidt
5a71334fb0 Revert "splitmuxsink: Use GstBin async-handling instead of our own."
This reverts commit fa008f271a.

async-handling in GstBin causes the pipeline to spin at 100%
CPU as the top-level pipeline tries to change that state
to PLAYING constantly. This is a workaround for a core
problem, essentially, but an improvement in this case for now.
2016-08-08 03:07:34 +10:00
Jan Schmidt
89af379ff0 splitmux: Recheck state after unlocking mutex.
After dropping the splitmux lock, re-check the state,
don't just fall through and sleep unconditionally,
as we may have already missed the wakeup.

https://bugzilla.gnome.org/show_bug.cgi?id=769514
2016-08-08 00:56:38 +10:00
Jan Schmidt
8b4ceb2ef3 splitmuxsink: Fix debug statement signedness.
The ts variable is a GstClockTime, don't print it
as a GstClockTimeDiff.
2016-07-25 18:20:03 +10:00
Jan Schmidt
6755691b28 splitmuxsink: Handle negative running time
Use signed clock times for running time everywhere
so that we handle negative running times without
going haywire, similar to what queue and multiqueue
do these days.
2016-07-20 00:39:38 +10:00
Jan Schmidt
e2505dd7df splitmuxsink: Drop lock when sending dummy event
When pushing the dummy event into the multiqueue,
drop the splitmux lock or else we might deadlock.
2016-07-20 00:32:30 +10:00
Jan Schmidt
fa008f271a splitmuxsink: Use GstBin async-handling instead of our own.
Set the async-handling property on GstBin to let it manage
async-handling instead of the local handling from the previous
commit. Works because of #174a5e in core
2016-05-15 00:03:15 +10:00
Jan Schmidt
08af8cd5b8 splitmuxsink: Hide internal async state changes.
When switching fragments, hide the async-start/async-done
messages from the parent bin, as otherwise we sometimes (very rarely)
hang in PAUSED instead of returning / continuing to PLAYING
state.
2016-05-14 18:34:57 +10:00
Jan Schmidt
f35f604610 splitmuxsink: Remove stray carriage-return from debug 2016-05-14 18:34:57 +10:00
Xavier Claessens
0fc02f35c7 splitmuxsink: Fix deadlock case when source reaches EOS
https://bugzilla.gnome.org/show_bug.cgi?id=765072
2016-05-05 01:22:10 +10:00
Xavier Claessens
7886e8d8a0 spitmuxsink: Avoid creating small file at EOS
When EOS is reached, the current file get closed and the last
GOP in the mq was written in a new file.

https://bugzilla.gnome.org/show_bug.cgi?id=765072
2016-04-16 22:14:37 +10:00
Damian Ziobro
ae4484c2ba splitmuxsink: Add max_files_number property
https://bugzilla.gnome.org/show_bug.cgi?id=744612
2016-04-14 04:18:11 +10:00