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 578926 - [h264parse] Make sure h264parse are autoplugged when required
[h264parse] Make sure h264parse are autoplugged when required
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
0.10.21
Other All
: Normal enhancement
: 0.10.23
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 556133 601262 (view as bug list)
Depends on: 650228
Blocks:
 
 
Reported: 2009-04-14 12:45 UTC by Arnout Vandecappelle
Modified: 2011-09-07 10:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
about 8 seconds of MPEG4 captured from Sony camera (950.00 KB, application/octet-stream)
2009-04-14 12:55 UTC, Arnout Vandecappelle
  Details
Assume MPEG-4 stream is not parsed. (1.40 KB, patch)
2009-04-17 12:47 UTC, Arnout Vandecappelle
none Details | Review
mpeg4videoparse: increased rank above that of ffdec_mpeg4 (930 bytes, patch)
2009-04-21 10:51 UTC, Arnout Vandecappelle
reviewed Details | Review
[gst-plugins-good] Add 'parsed=true' to caps of rtpmp4vdepay, rtpmp4gdepay, and matroska MPEG-4 (2.72 KB, patch)
2009-04-21 11:24 UTC, Arnout Vandecappelle
reviewed Details | Review
Make sure h264parse is autoplugged before H.264 decoder (2.43 KB, patch)
2009-04-21 11:32 UTC, Arnout Vandecappelle
needs-work Details | Review
[gst-plugins-good] Add 'parsed=true' to caps of rtph264depay and matroska MPEG-4. (1.98 KB, patch)
2009-04-21 12:58 UTC, Arnout Vandecappelle
reviewed Details | Review
Make sure h264parse can be autoplugged (2.11 KB, patch)
2009-08-25 10:04 UTC, Arnout Vandecappelle
none Details | Review
fix video parsers rank (1.27 KB, patch)
2011-06-10 08:24 UTC, Benjamin Gaignard
rejected Details | Review

Description Arnout Vandecappelle 2009-04-14 12:45:09 UTC
When I view an MPEG4 stream from a Sony camera with playbin or playbin2 (or decodebin or decodebin2), the decoded stream is weird.  It looks like only the top row or so of macroblocks is really decoded, and the rest only has differential info (probably the I-frames aren't detected).  I get the same effect with a manually constructed pipeline:

 souphttpsrc location=... ! ffdec_mpeg4 ! autovideosink

Inserting an mpeg4videoparse solves this:

 souphttpsrc location=... ! mpeg4videoparse ! ffdec_mpeg4 ! autovideosink


This is using -base 0.10.21, -bad 0.10.9 and -ffmpeg 0.10.4.
Comment 1 Arnout Vandecappelle 2009-04-14 12:55:56 UTC
Created attachment 132639 [details]
about 8 seconds of MPEG4 captured from Sony camera

This is about 8 seconds (truncated at 950K) of raw MPEG4 video captured from the Sony camera using

gst-launch souphttpsrc location=... ! filesink location=sony.mp4

Just in case you can't reproduce the problem, the video is actually a screenshot of what you get on my installation.
Comment 2 Arnout Vandecappelle 2009-04-17 12:44:01 UTC
To solve this, I propose adding the 'parsed=(boolean)false' field to the caps found by typefind, and 'parsed=(boolean)true' to the caps of ffmpeg.

The same issue also applies to h264.  Currently, h264parse doesn't have the 'parsed' field, so I'm going to add that as well.

Patches follow.  I'll clone this bug for -ffmpeg.
Comment 3 Arnout Vandecappelle 2009-04-17 12:47:10 UTC
Created attachment 132822 [details] [review]
Assume MPEG-4 stream is not parsed.

Set the 'parsed' field of the MPEG-4 caps to 'false'.  This
forces an mpeg4parse element to be inserted before the stream
can be decoded.  Unfortunately, it is not possible to detect
if the stream is already parsed or not.  However, that typically
happens only if a demuxer or depayloader comes in front of it, which
also sets the caps anyway.  Only a multifilesrc (with a sufficiently
high buffer size) may produce a parsed stream.
Comment 4 Jan Schmidt 2009-04-17 12:58:13 UTC
For mp3, we fixed this by raising the rank of the parser high enough that it's always preferred over all the decoders, and having 'parsed=false' on the sinkpad and 'parsed=true' of the srcpad of the parser, to avoid having an endless chain of them plugged.

It's slightly better than changing the typefind caps, imho, because it's a bit more explicit, and a demuxer that does output parsed data, can add 'parsed=true' to the caps it produces, to avoid the parser if it wants.
Comment 5 Arnout Vandecappelle 2009-04-17 15:01:08 UTC
Sounds good!  Except...  that means that the mpeg4videoparse will always be inserted, even if the stream is already parsed (i.e. coming out of a demuxer or depayloader).  That incurs some overhead because mpeg4videoparse is scanning over the stream byte-by-byte.

However, I just did some measurements and it looks like mpeg4videoparse takes less than 10% of the time of ffdec_mpeg4 (which is already pretty fast).

Conclusion: raise the rank of mpeg4videoparse.
Comment 6 Jan Schmidt 2009-04-17 15:04:23 UTC
Like I said, we can mark 'parsed=true' on such demuxers/depayloaders' caps and it'll skip mpeg4videoparse
Comment 7 Arnout Vandecappelle 2009-04-21 10:51:15 UTC
Created attachment 133032 [details] [review]
mpeg4videoparse: increased rank above that of ffdec_mpeg4

As proposed.
Comment 8 Arnout Vandecappelle 2009-04-21 11:24:34 UTC
Created attachment 133034 [details] [review]
[gst-plugins-good] Add 'parsed=true' to caps of rtpmp4vdepay, rtpmp4gdepay, and matroska MPEG-4

These are the main depayloaders/demuxers for MPEG-4.

Missing:
* ffdemux_mpeg4: rank is NONE anyway.
* avidemux/ogmdemux: riff-media doesn't even set systemstream=false, so I don't dare touching it.
Comment 9 Arnout Vandecappelle 2009-04-21 11:32:09 UTC
The same is actually true for h264 (and probably others).  Patches follow.
Comment 10 Arnout Vandecappelle 2009-04-21 11:32:59 UTC
Created attachment 133035 [details] [review]
Make sure h264parse is autoplugged before H.264 decoder

Added 'parsed' property to h264parse caps and increased its rank
above that of ffdec_h264.
Comment 11 Arnout Vandecappelle 2009-04-21 12:58:09 UTC
Created attachment 133037 [details] [review]
[gst-plugins-good] Add 'parsed=true' to caps of rtph264depay and matroska MPEG-4.

Same comments as for MPEG-4.
Comment 12 Sebastian Dröge (slomo) 2009-07-30 12:27:38 UTC
*** Bug 556133 has been marked as a duplicate of this bug. ***
Comment 13 Sebastian Dröge (slomo) 2009-07-30 12:35:30 UTC
Except the rank changes this could immediately be committed. Could you separate the rank change of h264parse from the parsed=true setting? The other patches are good and I'll commit them all in one go later.


Also, MPEG 4 video will also often be inside qt/mp4 files so qtdemux should be adjusted too.
Comment 14 Arnout Vandecappelle 2009-08-25 10:04:48 UTC
Created attachment 141625 [details] [review]
Make sure h264parse can be autoplugged

I removed the one line from the h264parse patch that does the rank change.  I didn't actually do this on the git tree but just modified the patch, so it may not apply cleanly to HEAD...

qtdemux is still todo.
Comment 15 Arnout Vandecappelle 2010-06-09 13:12:19 UTC
It looks like these patches never got committed.  Is there still a problem with them?
Comment 16 Tim-Philipp Müller 2010-06-09 13:24:07 UTC
*** Bug 601262 has been marked as a duplicate of this bug. ***
Comment 17 Sebastian Dröge (slomo) 2011-05-20 06:11:40 UTC
mpeg4videoparse has a high enough rank now, only h264parse is left. I don't know why its rank was not increased yet.
Comment 18 Benjamin Gaignard 2011-06-10 08:24:29 UTC
Created attachment 189603 [details] [review]
fix video parsers rank

following this idea of David:
https://bugzilla.gnome.org/show_bug.cgi?id=649542#c10

I propose to set rank of all parsers in -bad/gst/videoparsers/ directory to PRIMARY -10.
Comment 19 Sebastian Dröge (slomo) 2011-09-07 10:05:50 UTC
Comment on attachment 189603 [details] [review]
fix video parsers rank

This should be done on a case-by-case basis. Also h264parse has PRIMARY+1 now
Comment 20 Sebastian Dröge (slomo) 2011-09-07 10:06:56 UTC
This is fixed in -bad git now. h264parse is autoplugged, but only h264parse and none of the other parsers in the videoparsers plugin.