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 607471 - decodebin3: Race with caps changing in stream
decodebin3: Race with caps changing in stream
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 608495 706774 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-01-19 18:01 UTC by Arun Raghavan
Modified: 2018-11-03 14:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix bogus error message. (1.01 KB, patch)
2010-02-02 12:44 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
committed Details | Review
qtdemux: Avoid buffers from multiple stsd entries (3.09 KB, patch)
2010-02-04 16:01 UTC, Thiago Sousa Santos
rejected Details | Review
qtdemux: Refactor stsd parsing (16.28 KB, patch)
2010-02-04 16:01 UTC, Thiago Sousa Santos
rejected Details | Review
qtdemux: Select the predominant stsd entry (4.04 KB, patch)
2010-02-04 16:02 UTC, Thiago Sousa Santos
rejected Details | Review

Description Arun Raghavan 2010-01-19 18:01:57 UTC
While playing the following file, I do not see the video, only a still image:

http://samples.mplayerhq.hu/archive/container/mov/mov+svq3+aac++animatrix_2_program_640-sample.mov

gst-launch then quits with the following error:

$ gst-launch playbin2 uri=file:///$PWD/mov+svq3+aac++animatrix_2_program_640-sample.mov
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstPulseSinkClock
ERROR: from element /GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstJpegDec:jpegdec0: Failed to decode JPEG image
Additional debug info:
gstjpegdec.c(1261): gst_jpeg_dec_chain (): /GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstJpegDec:jpegdec0:
Error #70: Unsupported marker type 0x%02x
Execution ended after 3505994408 ns.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

----

FWIW, I noticed that the stream topology that gets posted looks like this:

  CONTAINER: video/quicktime
    AUDIO: audio/mpeg, mpegversion=(int)4, framed=(boolean)true, codec_data=(buffer)1210, rate=(int)44100, channels=(int)2
      AUDIO: audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
    UNKNOWN: image/jpeg, width=(int)640, height=(int)272, framerate=(fraction)15/1
      VIDEO: video/x-raw-yuv, format=(fourcc)I420, width=(int)640, height=(int)272, framerate=(fraction)15/1
Comment 1 Wim Taymans 2010-01-21 10:08:37 UTC
The error is from the libjpeg library.
Comment 2 Stefan Sauer (gstreamer, gtkdoc dev) 2010-01-25 20:20:17 UTC
Could jpegparse help here (bug #583098)?
Comment 3 Sebastian Dröge (slomo) 2010-02-02 09:26:09 UTC
*** Bug 608495 has been marked as a duplicate of this bug. ***
Comment 4 Stefan Sauer (gstreamer, gtkdoc dev) 2010-02-02 12:44:15 UTC
Created attachment 152830 [details] [review]
fix bogus error message.

I have a fix for the nonsense error (fix in jpegdec). Then the error becomes.
Error #69: Unsupported marker type 0xfb

This is also what jpegpare figures :) 0xfb is one of the reserved jpeg markers. I've tried to strip them in jpegparse, but hit the end of the block right now.
Comment 5 Tim-Philipp Müller 2010-02-02 13:08:44 UTC
Comment on attachment 152830 [details] [review]
fix bogus error message.

Ah, I've been wondering about that. Feel free to push this fix.
Comment 6 Stefan Sauer (gstreamer, gtkdoc dev) 2010-02-02 15:26:00 UTC
Comment on attachment 152830 [details] [review]
fix bogus error message.

commit a9f5bbe1ffbe5c09ecb7ecff478587ee0a09dfec
Author: Stefan Kost <ensonic@users.sf.net>
Date:   Tue Feb 2 13:41:03 2010 +0200

    jpeg: don't directly access message, some message have args
    
    This caused bogus messages, such as reported in bug #607471.
Comment 7 Stefan Sauer (gstreamer, gtkdoc dev) 2010-02-02 16:22:57 UTC
Could it be that we select the wrong stream here?
FOUND TAG      : found by element "qtdemux0".
     video codec: JPEG still images
FOUND TAG      : found by element "qtdemux0".
     audio codec: MPEG-4 AAC audio
 maximum bitrate: 128000
         bitrate: 160000

mp4info crashes on the clip :/

If I play it with seek test app I get no streams to switch
./tests/examples/seek/seek 16 file:///home/ensonic/Videos/mov+svq3+aac++animatrix_2_program_640-sample.mov

mplayer reports
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x862a680]multiple edit list entries, a/v desync might occur, patch welcome
ID_VIDEO_ID=0
[lavf] Video stream found, -vid 0
ID_AUDIO_ID=1
[lavf] Audio stream found, -aid 1
ID_AUDIO_ID=2
[lavf] Audio stream found, -aid 2
VIDEO:  [SVQ3]  640x272  24bpp  24.000 fps    0.0 kbps ( 0.0 kbyte/s)
Comment 8 Thiago Sousa Santos 2010-02-03 11:01:03 UTC
The problem here is that this file contains 2 stsd entries (in the same track), the first one being jpg, the second is svq3. This is probably confusing qtdemux.
Comment 9 Thiago Sousa Santos 2010-02-03 11:28:38 UTC
From the qtff spec I gathered the following info:

There might be multiple stsd entries for one track, meaning that the track has data in multiple formats. "Sample-to-chunk" atom is used to identify which format apply to which buffers.


For this file, the first and last buffers of this 'problematic' track are jpeg, the others are svq3.
Comment 10 Thiago Sousa Santos 2010-02-04 16:01:40 UTC
Created attachment 153018 [details] [review]
qtdemux: Avoid buffers from multiple stsd entries

quicktime permits the use of multiple codecs on the
same trak (multiple stsd entries), this patch makes
qtdemux skip buffers that are not from the selected
stsd entry. (It always selects the first one currently)

Fixes #607471
Comment 11 Thiago Sousa Santos 2010-02-04 16:01:56 UTC
Created attachment 153019 [details] [review]
qtdemux: Refactor stsd parsing

Use offsets based on the stsd entry start position and not
on the stsd atom start position. Making the code reusable to
parsing multiple stsd entries.
Comment 12 Thiago Sousa Santos 2010-02-04 16:02:17 UTC
Created attachment 153020 [details] [review]
qtdemux: Select the predominant stsd entry

peeks on the first stsc entries and selects the stsd entry with
the most occurences on that interval.

Fixes #607471
Comment 13 Thiago Sousa Santos 2010-02-04 16:04:27 UTC
Those patches fix the issue by picking the stsd entry that has most chunks.

It doesn't play correctly yet because of the empty entries in the edit list that aren't handled yet.
Comment 14 Thiago Sousa Santos 2010-02-05 12:44:33 UTC
Pushed some patches for the empty edit lists handling in #345830

They need some review and testing is always welcome.


As it wasn't already enough, this file has yet another tricky issue:

The two audio traks are complimentary, the smaller ones fills the starting 11secs that are empty (by the use of the edit lists) on the longer audio trak. This smaller trak is classified by qtdemux as a preview.

Haven't really thought on how we can make this work. It surprises me that we haven't found a way (maybe qtff doesn't allow it) to identify what streams are previews or what should be played together.
Comment 15 Sebastian Dröge (slomo) 2011-05-26 10:08:43 UTC
What's the progress on this?
Comment 16 Thiago Sousa Santos 2011-05-27 21:14:05 UTC
I think we never reached a conclusion on how to reach the above case.
Comment 17 Thiago Sousa Santos 2011-05-27 21:14:42 UTC
(In reply to comment #16)
> I think we never reached a conclusion on how to handle the above case.
Comment 18 Edward Hervey 2013-08-13 18:45:07 UTC
This bug has an assigned developer but has not received activity in almost a year.

Is the assigned person still working on this ?
Comment 19 Thiago Sousa Santos 2013-08-19 11:28:37 UTC
I've never seen any other file with 2 stsd entries again ever since this bug.

The main issue here is that each stsd has a different codec, and the audio stream has a single stsd.

Is it relevant to fix this? Has someone seen files like this around?
Comment 20 Arun Raghavan 2013-08-19 12:35:57 UTC
FWIW, since I filed the bug, I've not seen any other file with this problem.
Comment 21 Haithem BEN GHORBAL 2014-02-17 11:13:11 UTC
(In reply to comment #14)
> Pushed some patches for the empty edit lists handling in #345830
> 
> They need some review and testing is always welcome.
> 
> 
> As it wasn't already enough, this file has yet another tricky issue:
> 
> The two audio traks are complimentary, the smaller ones fills the starting
> 11secs that are empty (by the use of the edit lists) on the longer audio trak.
> This smaller trak is classified by qtdemux as a preview.
> 
> Haven't really thought on how we can make this work. It surprises me that we
> haven't found a way (maybe qtff doesn't allow it) to identify what streams are
> previews or what should be played together.

there is a way to check that in Track Header 'tkhd' atom.
following the qtff spec here :
> https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-BBCEIDFA

starting from byte 9 :
> Flags
>   Three bytes that are reserved for the track header flags. These flags indicate how the track is used in the movie. The following flags are valid (all flags are enabled when set to 1).
>   Track enabled
>     Indicates that the track is enabled. Flag value is 0x0001.
>   Track in movie
>     Indicates that the track is used in the movie. Flag value is 0x0002.
>   Track in preview
>     Indicates that the track is used in the movie’s preview. Flag value is 0x0004.
>   Track in poster
>     Indicates that the track is used in the movie’s poster. Flag value is 0x0008.

concerning the multiple stsd entries, I don't see where is the problem. If we store these descriptions in an array of struct with their predefined caps (in the 'qtdemux_parse_trak' function), and store in the QTDemuxSample struct the needed index as specified in Sample-to-Chunk atoms, shouldn't this do the trick ?
Comment 22 Thiago Sousa Santos 2016-04-27 17:51:41 UTC
FWIW I have a branch here that uses all stsd entries and pushes a new caps when a different format is required:

https://cgit.freedesktop.org/~thiagoss/gst-plugins-good/log/?h=qtdemux-stsd-all-entries

The new decodebin3 will support these caps changes and it already (kind of*) works with the above patches applied.

* There is a race to be fixed.
Comment 23 Thiago Sousa Santos 2016-04-29 18:18:10 UTC
I might push this as it shouldn't interfere with the standard 1 format per stsd trak. This is required to support part of the DVB DASH profile.
Comment 24 Tim-Philipp Müller 2016-04-29 18:27:57 UTC
What happens with the old decodebin/playbin?
Comment 25 Thiago Sousa Santos 2016-04-29 18:33:58 UTC
Current: keeps using the first stsd entry and pushes svq3 to a jpeg decoder

ERROR Failed to decode JPEG image for file:///home/thiagoss/media/mov+svq3+aac++animatrix_2_program_640-sample.mov


With those patches: detects the change of format and pushes a new caps event that is rejected by the jpeg decoder. (Decodebin3 is able to react to this and plugs a new decoder)
ERROR debug information: qtdemux.c(5650): gst_qtdemux_loop (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0:
streaming stopped, reason not-negotiated
Comment 26 Edward Hervey 2018-05-05 16:08:15 UTC
Didn't we fix those issues (multiple stsd entries) ?
Comment 27 Thiago Sousa Santos 2018-05-08 05:19:29 UTC
The multiple stsd part is fixed but there is a race on handling the sequence of caps events on decodebin3. As the first stsd only has 1 frame there is something comparing caps from the second stsd with decoders from the first and it will fail with not-negotiated.
Comment 28 Edward Hervey 2018-05-10 11:39:28 UTC
Remaining issue is indeed in decodebin3, renaming
Comment 29 Edward Hervey 2018-08-23 06:45:58 UTC
Comment on attachment 153018 [details] [review]
qtdemux: Avoid buffers from multiple stsd entries

Fixed since 2016
Comment 30 Edward Hervey 2018-08-23 06:46:08 UTC
Comment on attachment 153019 [details] [review]
qtdemux: Refactor stsd parsing

Fixed since 2016
Comment 31 Edward Hervey 2018-08-23 06:46:20 UTC
Comment on attachment 153020 [details] [review]
qtdemux: Select the predominant stsd entry

Fixed since 2016
Comment 32 Edward Hervey 2018-08-23 06:50:26 UTC
(Copying my latest comment from Bug #706774 which I'll mark as a duplicate of this one).

So I generally agree on the fundamental problem which is that whoever creates the collection and streams can updated them *separately* from what actual data flow is currently happening at the multiqueue level.

Furthermore I'm working on adding more collection/stream emission in upstream elements (demuxers, adaptive demuxers, ...) for which this will be even more TRUE.

==> So yes, decodebin3's handling of caps should be done using the *actual* caps travelling through multiqueue.

Regarding the "multiple stsd entries" in qtdemux, this corresponds to "stream variants". i.e. it's the same "stream" per-se (from a human audio/visual point of view) but the nature of it (codec, resolution,...) can change throughout time.

It's a bit like adaptive streaming. The bitrate, resolution, framerate,... can change throughout time, but from a human perspective it's still the same "stream". (Note that DASH uses this multiple stsd-entry system extensively for exactly that purpose).

I'm working on an API extension of GstStreamCollection to be able to specify such streams and variants. I'll keep this updated.
Comment 33 Edward Hervey 2018-08-23 06:50:41 UTC
*** Bug 706774 has been marked as a duplicate of this bug. ***
Comment 34 GStreamer system administrator 2018-11-03 14:40:46 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/20.