[FFmpeg-devel] [RFC] lavfi audio buffers and channel layout
stefasab at gmail.com
Mon Jul 30 18:20:20 CEST 2012
currently the following command
ffmpeg -f lavfi -i 'aevalsrc=sin(440*2*PI*t)' -t 5 -ac 2 -y test.wav
ffplay -f lavfi "amovie=test.wav,asplit[out1],showwaves=s=640x480[out0]"
will crash ffplay.
The problem is that channel_layout is set to 0 in the decoder context,
we set up the channel layout using get_default_channel_layout() but
then when we request a buffer the channel_layout info is not present
in the frame, and the frame -> buffer ref routine doesn't have the
Later nb_channels is derived from the channel_layout and we get 0, and
we get a FPE in show_frames when dividing for 0.
Possible solutions: we validate the channel layout when opening the
movie, if we can guess the channel layout from the number of channels,
we warn and set it in the decoder context. In case we can't map
nb_channels -> channel layout we just complain and fail.
Alternatively we may put the channels information in AVFrame, (already
posted a patch for that), and propagate that info in the filterchain,
but at this point we may need to extend:
avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, int linesize, int perms,
enum AVSampleFormat sample_fmt,
in order to take an additional nb_channels argument.
I don't know if this is a good idea, since we require the filtergraph
to be set up with a defined channel layout, and introducing a
nb_channels we may trigger possible inconsistencies in the filtergraph
(in case nb_channels doesn't match with the channel layout).
FFmpeg = Funny and Frightening Merciful Portable Extravagant God
More information about the ffmpeg-devel