After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752999 - Splitmuxsink does not work with mpegtsmux
Splitmuxsink does not work with mpegtsmux
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
1.5.2
Other Windows
: Normal normal
: 1.5.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-29 07:32 UTC by Baby octopus
Modified: 2015-08-22 10:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
splitmuxsink: Support mpegtsmux as a muxer. (1.16 KB, patch)
2015-07-29 09:30 UTC, Jan Schmidt
committed Details | Review
mpegtsmux: Don't clear the PID on reset. (917 bytes, patch)
2015-07-29 12:59 UTC, Jan Schmidt
committed Details | Review

Description Baby octopus 2015-07-29 07:32:38 UTC
Hi,

splitmuxsink works perfectly with mp4mux as follows 

gst-launch-1.0 filesrc location=big_buck_bunny_1080p.mp4 ! qtdemux ! video/x-h264 ! h264parse ! splitmuxsink max-size-time=12000000000 location=video%05d.mp4 muxer=mp4mux 

But does not work with mpegtsmux for H264 and Mpeg2 codec
Mpeg2:
gst-launch-1.0 videotestsrc ! avenc_mpeg2video ! splitmuxsink max-size-time=12000000000 location=video%05d.ts muxer=mpegtsmux -v 

(gst-launch-1.0:8166): GStreamer-CRITICAL **: gst_element_request_pad: assertion `templ != NULL' failed 
WARNING: erroneous pipeline: could not link avenc_mpeg2video0 to splitmuxsink0 

H264:
gst-launch-1.0 filesrc location=big_buck_bunny_1080p.mp4 ! qtdemux ! video/x-h264 ! h264parse ! splitmuxsink max-size-time=12000000000 location=video%05d.ts muxer=mpegtsmux

(gst-launch-1.0:23781): GStreamer-CRITICAL **: gst_element_request_pad: assertion `templ != NULL' failed
WARNING: erroneous pipeline: could not link h264parse0 to splitmuxsink0
Comment 1 Jan Schmidt 2015-07-29 09:30:07 UTC
Created attachment 308364 [details] [review]
splitmuxsink: Support mpegtsmux as a muxer.

As a fallback, look for a pad template sink_%d on
the muxer when requesting pads, to support mpegtsmux
Comment 2 Baby octopus 2015-07-29 11:14:06 UTC
Seems to be some error. It's working fine now. But the output is still mp4
Comment 3 Jan Schmidt 2015-07-29 11:20:10 UTC
if the output is mp4, it's not using mpegtsmux at all. Did you lose the 'muxer=mpegtsmux' setting?
Comment 4 Baby octopus 2015-07-29 11:28:42 UTC
Sorry, that was a false alarm. It's working perfectly but performance is very low. Take a look at these two pipelines for example. splitmuxsink is almost 55times slower than having traditional mpegtsmux ! filesink. Am I missing something here? Kindly let me know

[root@localhost multifile]$ time gst-launch-1.0 filesrc location=/home/root/big_buck_bunny_1080p.mp4 ! qtdemux ! video/x-h264 ! h264parse ! mpegtsmux ! filesink location=single.ts
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:02.164395016
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

real    0m2.251s
user    0m1.936s
sys     0m0.314s
[root@localhost multifile]$ time gst-launch-1.0 filesrc location=/home/root/big_buck_bunny_1080p.mp4 ! qtdemux ! video/x-h264 ! h264parse ! splitmuxsink max-size-time=12000000000 location=video%05d.ts muxer=mpegtsmux sink=filesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:01:50.757893834
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

real    1m50.792s
user    1m51.052s
sys     0m0.407s
Comment 5 Jan Schmidt 2015-07-29 12:59:12 UTC
Created attachment 308390 [details] [review]
mpegtsmux: Don't clear the PID on reset.

The PID on a pad shouldn't change on a state change, only
if the pad is freed and a new one created. Clearing the PID
prevented mpegtsmux from being reused, because all packets
would end up muxed in PID 0
Comment 6 Jan Schmidt 2015-07-29 13:02:33 UTC
That one line change makes it generate OK files, but there's a remaining problem that the H.264 SPS/PPS don't get inserted into subsequent files. Adding 'config-interval=1' to h264parse makes them at least playable, although a little bit at the start of each file fragment is unplayable until an SPS/PPS is inserted.

A better solution would be to be able to insert the SPS/PPS before the keyframe that starts each new file part, but that requires changes in a few places.
Comment 7 Baby octopus 2015-07-30 04:35:35 UTC
Performance of both the pipelines are matching now(with or without fragment) . Not sure how why that one line of code was adding so much of cpu load :)

I think introducing SPS/PPS should entirely be left to encoder/h264parser here.
Comment 8 Jan Schmidt 2015-07-31 04:11:44 UTC
(In reply to Baby octopus from comment #7)
> Performance of both the pipelines are matching now(with or without fragment)
> . Not sure how why that one line of code was adding so much of cpu load :)

It was making every packet be considered a header and accumulated in a linked list that was never intended to be that long :)

> I think introducing SPS/PPS should entirely be left to encoder/h264parser
> here.

Yes, but a mode on h264parse that inserted SPS/PPS before every key-frame would let splitmuxsink split into files where each fragment is playable independently, which would be nice.
Comment 9 Baby octopus 2015-07-31 06:10:50 UTC
Perfect :) I think we can close this bug now