GNOME Bugzilla – Bug 752186
gst-libav: avaudenc: fails at 2 channel wmav2 file
Last modified: 2015-07-27 18:20:07 UTC
Fails because the file has 2 channels but no channel layout was provided. From a quick look between the differences in libav and ffmpeg it seems that libav had a default channel layout function that would provide a LEFT|RIGHT layout as default for stereo audio while ffmpeg just returns 0 (no layout defined). I can host the file somewhere if anyone is interested in taking a deeper look at the issue.
Created attachment 307163 [details] [review] avauddec: do not fail when no channel layout was provided ffmpeg seems to not provide channel layout for some default settings (2 channels, for example) and avauddec should not fail on that but try to move forward.
The question is whether we want to just use channels from the avcontext and leave the layout as 0 or just do that for 1 or 2 channels where a default layout is implicit.
Review of attachment 307163 [details] [review]: ::: ext/libav/gstavauddec.c @@ +381,3 @@ if (channels == 0) + /* ffmpeg might not have default channel layout for some channels */ + channels = context->channels; The problem here is that in theory the number of channels in the context might be different than the number of channels in the current output frame. Like what we had in the video decoder before, which then caused crashes. The context values are always for the latest input data, which might be newer values than what you currently get as output from the decoder.
This should IMHO be solved by fixing ffmpeg :)
Did anyone file upstream?
It seems to have been caused by 464f94b206b041fa383ab4257226cb3f18dfb550, but I didn't follow up on that.
Created attachment 308117 [details] [review] avauddec: Read channels from the channels field Turns out it's not a ffmpeg bug, it's gst-libav not using the API correctly, there is a channels field with the channel couunt. Having no layout means the same thing it does in GStreamer. If there is no layout, just read the channel count from the channels field.
Created attachment 308118 [details] [review] avauddec: Read channels from the channels field Slighly rebased patch
Comment on attachment 308118 [details] [review] avauddec: Read channels from the channels field This API (and the field in AVFrame) did not exist in libav when I did this changes, so we are probably removing libav compatibility with this commit now. libav developers told me that I can assume the channel layout field to always be set.
Do we care enough to want some kind of #ifdef FFMPEG or #ifdef LIBAV ?
We don't care so much about libav, merged: commit 3b6c656e2552c936a17ff6bb9a0e753fcc42e4ce Author: Olivier Crete <olivier.crete@collabora.com> Date: Sat Jul 25 02:54:20 2015 -0400 avauddec: Read channels from the channels field If there is no layout, just read the channel count from the channels field. https://bugzilla.gnome.org/show_bug.cgi?id=752186