GNOME Bugzilla – Bug 341563
[faad] fails to decode middle of file, should just skip occasional stream errors
Last modified: 2006-05-13 18:46:28 UTC
Please describe the problem: I have some mkv files, and those are contained xvid video stream and aac audio stream. but during play some of those files with totem, shows popup error dialog that says "Could not decode stream." after set GST_DEBUG=faad:4 these messages are printed. DEBUG (0x863ccb0 - 0:00:01.948496000) faad( 6711) gstfaad.c(777):gst_faad_sink_event: Got NEWSEGMENT event in GST_FORMAT_TIME, passing on (0:00:00.000000000 - 0:46:59.902000000) DEBUG (0x863ccb0 - 0:00:02.612531000) faad( 6711) gstfaad.c(285):gst_faad_setcaps:<faad0> channels=2, rate=48000 DEBUG (0x863ccb0 - 0:00:02.613445000) faad( 6711) gstfaad.c(983):gst_faad_update_caps: New output caps: audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)2, channel-positions=(GstAudioChannelPosition)< GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT > DEBUG (0x863ccb0 - 0:01:21.843410000) faad( 6711) gstfaad.c(1198):gst_faad_chain:<faad0> decoding error, reopening with faacDecInit2() DEBUG (0x863ccb0 - 0:01:21.843573000) faad( 6711) gstfaad.c(1204):gst_faad_chain:<faad0> faacDecInit2(): rate=48000,channels=2 WARN (0x863ccb0 - 0:01:21.848375000) faad( 6711) gstfaad.c(1324):gst_faad_chain:<faad0> error: Failed to decode buffer: Invalid number of channels Steps to reproduce: I can't dump aac stream from mkv file. anybody can tell me how I can get aac stream from mkv file? Actual results: totem shows popup dialog that says can't decode. Expected results: play anyway. Does this happen every time? yes. Other information: in mplayer, it shows this message, but play anyway. FAAD: Failed to decode frame: Maximum number of bitstream elements exceeded In mplayer source, if error were occured, continue decoding anyway. after I avoid goto decode_error in ext/faad/gstfaad.c:1211, totem plays file properly, too.
Created attachment 65385 [details] [review] retry decode faad stream when error occured I made a patch that referred mplayer faad decode source. You can see mplayer's faad decode code at http://www1.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/libmpcodecs/ad_faad.c and at 244 line, mplayer continue decode stream when error occurred.
Thanks for tracking this down, here are some comments, as already discussed on IRC: - the error counter should be moved into the GstFaad structure and reset to 0 whenever a decode operation was successful. In the setup like in the patch where the error counter is local to the chain function, it would never be triggered for framed data and hardly ever for unframed data. - the limit for the error counter doesn't really make sense to me in the context of how the GStreamer decoder works (I presume mplayer does the resyncing in a different way than we do), it should probably just be #define MAX_DECODE_ERRORS 5 or something (some magic number). Btw, it would be great if you could make the first 5 or 10 megabytes of the file available somewhere for download (or the whole file if it's not too big) so we can add it to our test suite.
I uploaded sample file at http://ftp.mizi.com/~ganadist/test.mkv Size of that file is about 70 Megabytes, and error occurs at about 90 secend from beginning.
Created attachment 65389 [details] [review] updated patch as Tim's suggestion, error counter move into GstFaad, and changed limit for error count
I also said you should reset the error counter whenever a decode operation was successful :) Committed to CVS, including that counter reset: 2006-05-13 Tim-Philipp Müller <tim at centricular dot net> Patch by: Young-Ho Cha <ganadist chollian net> * ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chain), (gst_faad_change_state): * ext/faad/gstfaad.h: If we encounter a decoding error, don't error out immediately, but try to resync (or see if we have better luck with the next buffer in case of framed input). Only error out after five consecutive errors. Fixes #341563. Thanks for the patch!