[Libav-user] libswresample vs libavfilter for target format conversion

Jorge Israel Peña jorgepblank at gmail.com
Mon Mar 18 01:25:39 CET 2013


Hey, this is my first time decoding audio and I'm currently trying to
figure out the best way to convert audio to the target format.

My understanding is that when the audio is decoded, in order to play it
through the sound system (with say pulseaudio), it should be converted to
the sound system's target format if it isn't already in that format, like
say if my target format is two channels, S16 non-planar, 44100hz. After
consulting the ffplay source I found that they use libswresample. However
I've also found mention of using libavfilter for this purpose. I have no
experience with libavfilter but it seems to me like a very recent commit to
ffplay adds support for it:
https://github.com/FFmpeg/FFmpeg/commit/e96175ad7b576ad57b83d399193ef10b2bb016ae
so
I can probably learn from that.

It seems like it uses the 'abuffer' filter, is this the one to use for this
case? It doesn't strike me (from the doxygen) as a filter used for
conversion. It seems to me like it's setup as an `abuffer` for the input
and an `abuffersink` for the output, and the `abuffersink`'s parameters
describe the target format. So when a frame is put in and pulled out from
the filter graph it's automatically converted to that format due to the
parameters passed to 'abuffersink'?

I had also previously seen someone say to use the 'aformat' filter for this
purpose. Is there a difference? Looking at the list of filters, I also see
"aconvert: Sample format and channel layout conversion audio filter" and
"resample: Sample format and channel layout conversion audio filter". So I
see there's abuffer, aformat, aconvert, and resample, so I'm pretty
confused here and would really appreciate any clarification. Then again I
know nothing about the whole filter system so this may be something very
simple/obvious.

Aside from that, what are the benefits of using libavfilter for converting
to the target format over using libswresample? It seems to me like after
the initial setup for avfilter, the actual conversion process seems a lot
simpler, simply consisting of putting frames and pulling them out of the
filter graph. Is this the benefit?

Thanks, I would really appreciate some clarification for this.

-- 
- Jorge Israel Peña
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130317/ef0b0c15/attachment.html>


More information about the Libav-user mailing list