[Libav-user] Problems decoding mp3 files

Gonzalo Garramuno ggarra13 at gmail.com
Mon Apr 28 02:02:41 CEST 2014


On 27/04/14 20:54, b.mcdonagh at sky.com wrote:
> I've had a look at your code, thanks. It seems you are using 
> av_read_frame which for me crashes with mp3 files as previously described.
>
> I have just quickly written some code which has the crashes in when I 
> run it - I hope this can help somebody to point me in the right 
> direction. It crashes on av_read_frame or (find_stream_info - if i 
> uncomment it out)
>
     What are inputAudioFormat and inputAudioContextz?  Also did you 
call av_register_all() before?
>         int ret= avformat_open_input(&inputAudioFormat, filename, 
> NULL, NULL);
> //yyy = avformat_find_stream_info(inputAudioFormat, NULL);
> //qDebug() << " crashes above line if not commented out ...after find 
> stream info inputAudioFormat res=" << yyy;
>
>
> inputAudioContextz = inputAudioFormat->streams[0]->codec;
> inputAudioContextz->strict_std_compliance = -2;
> inputAudioContextz->bit_rate = 
> 64000;//inputAudioFormat->streams[0]->codec->bit_rate;
> inputAudioContextz->channels = 2;
> inputAudioContextz->request_channel_layout = AV_CH_LAYOUT_STEREO;
> inputAudioContextz->sample_rate = 
> 44100;//inputAudioFormat->streams[0]->codec->sample_rate;
> inputAudioContextz->codec = 
>  avcodec_find_decoder(inputAudioContextz->codec_id);
You shouldn't need to initialize the audio context when demuxing. Leave 
all values at their default.

> inputAudioCodec = (AVCodec*)inputAudioContextz->codec;
This definitively looks wrong.

>
> if (!inputAudioCodec) {
> fprintf(stderr, "no codec not found\n");
> exit(1);
> }
> if (avcodec_open2(inputAudioContextz, inputAudioContextz->codec, NULL) 
> < 0) {
> fprintf(stderr, "could not open codec\n");
> exit(1);
> }
>
Here you would start with av_read_frame()



More information about the Libav-user mailing list