[Libav-user] decode audio example broken

drwho drwho at infidigm.net
Thu Nov 22 18:52:34 EET 2018


On 2018-11-21 3:40 p.m., Jaka Bac wrote:
> Hi Jon,
>
> The decode example here: 
> https://www.ffmpeg.org/doxygen/trunk/decode_audio_8c-example.html
> uses the new API.
>
> But you have to be aware that it does not involve libavformat for 
> demuxing and it expects the "raw" bitstream for the specified codec, 
> if you are opening a file which has a wrapper, you should use 
> libavformat to first extract the packets and then just send the 
> packets to the codec.

Hi Jaka,

That was the issue...I was sending the decoder a container and not the 
raw bitstream.  I guess I assumed av_parse_parse2() would demux.

I tried the old api demux and decode example....

https://www.ffmpeg.org/doxygen/trunk/demuxing_decoding_8c-example.html

Should I be able to send a wav file to this example and get correct 
output (it maybe expects video+audio)?

./example input.wav video.mkv output.wav

The output is distorted.  When I compare input.wav and output.wav 
(beginning of each attached) they are identical until offset / position 
0x82C.  The input is a 440Hz sine wave, so it is easy to see the 
periodic data in the hex viewer.  It looks like every so often the 
output stream skips over parts of the sign wave (at for example offset / 
position 0x82C).  Maybe the decoder is doing some time 
re-synchronization?  My application is audio only and has the same 
behavior if I use the new or old apis.  I thought I could use the 
example to compare against to see where I went wrong.

built on Debian 9.....

gcc example.c -lavcodec -lavformat -lavutil -o example

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20181122/bd00da2c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: output.wav
Type: audio/x-wav
Size: 2582 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20181122/bd00da2c/attachment.wav>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: input.wav
Type: audio/x-wav
Size: 5120 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20181122/bd00da2c/attachment-0001.wav>


More information about the Libav-user mailing list