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 550472 - [mpegtsdemux] Fails to demux video/mpeg,mpegversion=4 streams
[mpegtsdemux] Fails to demux video/mpeg,mpegversion=4 streams
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 0.10.23
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-09-02 14:44 UTC by Sebastian Dröge (slomo)
Modified: 2012-05-24 08:52 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Sebastian Dröge (slomo) 2008-09-02 14:44:29 UTC
Hi,
a MPEG-TS file created with
gst-launch-0.10 videotestsrc num-buffers=1000 ! ffenc_mpeg4 ! "video/mpeg,mpegversion=4" ! flutsmux ! filesink location=test.ts

Can't be demuxed by flutsdemux (one gets only grey frames) while ffplay plays it fine.
Comment 1 Sebastian Dröge (slomo) 2008-09-03 06:52:35 UTC
Of course I meant mpegtsmux from gst-plugins-bad... flutsmux didn't support mpeg4 video
Comment 2 vanista 2008-11-19 13:48:14 UTC
I think I have the same issue although it's somewhat generalized to all codecs in my case. I was able to track down the problem to the PID / PID type the muxer sets for the data streams.

If you take a look at gst_fluts_demux_parse_stream, there is a switch case for the PID type (which I believe is derived from the PID). The audio/video streams are expected to be "PID_TYPE_ELEMENTARY", and I saw that an output TS with H.264 and AAC has PID types 1 and 3 for PIDs 0x0001 and 0x0000 respectively. Therefore the demux sees those streams as PID_TYPE_CONDITIONAL_ACCESS and PID_TYPE_PRIVATE_SECTION, and simply drops them.

I'm not sure why FFMPEG demuxes the streams, maybe it doesn't rely on PID for content type.

Investigating the mux to see where these values come from...
Comment 3 vanista 2008-11-19 14:29:48 UTC
Oups, that was an operation error. In my pipeline I specified the mux pad names (sink_0 and sink_1) and just figured these are use directly as PID in mpegtsmux_request_new_pad... Retested without pad names and it works perfectly.

Tested successfully H.264, MPEG-4, MPEG-2 video, AAC and MP3 audio, so I couldn't reproduce original problem sorry.
Comment 4 Sebastian Dröge (slomo) 2008-11-24 10:01:05 UTC
I can still reproduce it here as mentioned above.

When playing it with gstreamer I get millions of warnings from gst-ffmpeg:

0:00:10.671266760 12574  0x90aaaa0 ERROR               ffmpeg :0:: Error at MB: 247
0:00:10.703037216 12574  0x90aaaa0 ERROR               ffmpeg :0:: header damaged
0:00:10.703629872 12574  0x90aaaa0 ERROR               ffmpeg :0:: ac-tex damaged at 16 11
Comment 5 vanista 2008-11-25 13:32:07 UTC
I suppose you're using the latest gst-ffmpeg ... For my specific usecase I wrote a couple of patches for the mpegtsdemux (pushing complete payloads with adjusted timestamps), and my gst-ffmpeg also has a couple timestamp hacks, but nothing which actually changes the bitstream. Nevertheless it could be one of those changes which "fixes" the problem ;-)

Can you attach a sample so I could check?
Comment 6 Thiago Sousa Santos 2009-10-15 14:21:44 UTC
This issue is still around. You can run the pipeline that Sebastian wrote (gst-launch-0.10 videotestsrc num-buffers=1000 ! ffenc_mpeg4 !
"video/mpeg,mpegversion=4" ! mpegtsmux ! filesink location=test.ts) to generate a sample.
Comment 7 Thiago Sousa Santos 2009-10-26 13:20:13 UTC
It works with ffdemux_mpegts and does not with mpegtsdemux.
Comment 8 Thiago Sousa Santos 2009-10-26 14:34:20 UTC
Adding a mpeg4videoparse after mpegtsdemux makes it work. (Edward noticed this).

From IRC:

bilboed-pi: I don't know exactly which way it should be fixed though
bilboed-pi: we could either go the mp3 way... and force parsed=True on the mpeg4 decoder input caps
bilboed-pi: (so that when autoplugging it automatically adds the mpeg4videoparse)
bilboed-pi: but that would require having mpeg4videoparse in -ugly
bilboed-pi: the alternative is... doing the parsing in the demuxer
Comment 9 Edward Hervey 2009-10-26 14:53:17 UTC
Just checked, we deactivated the parser for mpeg4 in gstffmpegdec.

But even if I reactivate it, it still fails as-is... but if one adds the width/height to the incoming caps it works fine.
Comment 10 vanista 2009-11-04 20:52:15 UTC
Video properties such as dimensions or framerate are out of the scope of the demuxer. FFMPEG's demuxes cheat in that regard by parsing the streams. The decoder should be capable of handling a raw stream without parameters. If it can't, maybe the encoding/muxing did not provide the required codec data.

For instance, H.264 has parameter sets on IDR frames which must be kept intact when muxed in a Transport Stream. The TS format doesn't specify a way to contain codec data so it must be embedded in the bitstream.

I'm not sure what's the specification for codec data in MPEG-4 but it's probably missing in this case.
Comment 11 vanista 2009-12-05 11:49:34 UTC
If ffdec_mpeg4 doesn't parse the stream and the demux doesn't push complete payloads there's no way it can work. Furthermore, the current implementation of the demux which pushes data as soon as it's available is not very good. This creates a lot of traffic of GstBuffers of <= 182 bytes and doesn't allow basic error correction by sequence number validation. Since most of FFMPEG's decoders are not robust to data corruption there's higher chances of crash.

One way to improve this is to accumulate data on a given PID until a new PUSI flag is found and then push a complete PES payload in a single GstBuffer. If there is a gap in sequence numbers, the whole payload should be dropped. It's way more efficient this way and each outgoing GstBuffer gets a valid timestamp.
Comment 12 Christian Fredrik Kalager Schaller 2011-05-26 14:51:56 UTC
Just tested that this bug is still here with current git versions of GStreamer.
Comment 13 Thibault Saunier 2012-02-14 15:45:30 UTC
It seem to be working properly with latest git and tsdemux (not mpegtsdemux which should be deprecated in the near future).
Comment 14 Edward Hervey 2012-05-24 08:52:01 UTC
Works fine with tsdemux.