[FFmpeg-user] aac latm decoding

Sven Dueking sven at nablet.com
Mon Aug 20 14:00:48 CEST 2012


Hi all,

 

I try to decode an AAC latm stream with the latest ffmpeg (it´s from
zeranoe).

According to FFProbe everything is fine with the stream and the ffmpeg build
(exe) can play the stream without errors.

 

ffprobe.exe aac_dump_ref.aac

ffprobe version N-43594-gf0896a6 Copyright (c) 2007-2012 the FFmpeg
developers

  built on Aug 15 2012 21:25:48 with gcc 4.7.1 (GCC)

  configuration: --enable-gpl --enable-version3 --disable-pthreads
--enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r
--enable-libass --enable-libcelt --en

able-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype
--enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg
--enable-librtmp --enable-libschroed

inger --enable-libspeex --enable-libtheora --enable-libutvideo
--enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libxavs --

enable-libxvid --enable-zlib

  libavutil      51. 69.100 / 51. 69.100

  libavcodec     54. 52.100 / 54. 52.100

  libavformat    54. 23.101 / 54. 23.101

  libavdevice    54.  2.100 / 54.  2.100

  libavfilter     3.  9.100 /  3.  9.100

  libswscale      2.  1.101 /  2.  1.101

  libswresample   0. 15.100 /  0. 15.100

  libpostproc    52.  0.100 / 52.  0.100

[aac_latm @ 01f2cd60] initializing latmctx

[loas @ 01f2c4e0] max_analyze_duration 5000000 reached at 5034667

[loas @ 01f2c4e0] Estimating duration from bitrate, this may be inaccurate

Input #0, loas, from 'aac_dump_ref.aac':

  Duration: N/A, bitrate: N/A

    Stream #0:0: Audio: aac_latm, 48000 Hz, stereo, s16

 

I try to pass this stream to :

 

    AVCodec *codec;

    AVCodecContext *c= NULL;

    int len;

    FILE *f, *outfile;

    uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];

    AVPacket avpkt;

    AVFrame *decoded_frame = NULL;

 

    av_init_packet(&avpkt);

 

    printf("Audio decoding\n");

 

    /* find the mpeg audio decoder */

 

    codec = avcodec_find_decoder(CODEC_ID_AAC_LATM);

    if (!codec) {

        fprintf(stderr, "codec not found\n");

        exit(1);

    }

 

    c = avcodec_alloc_context3(codec);

 

    /* open it */

    if (avcodec_open2(c, codec, NULL) < 0) {

        fprintf(stderr, "could not open codec\n");

        exit(1);

    }

 

    f = fopen("ref.aac", "rb");

    if (!f) {

        fprintf(stderr, "could not open\n");

        exit(1);

    }

    outfile = fopen("out.raw", "wb");

    if (!outfile) {

        av_free(c);

        exit(1);

    }

 

    /* decode until eof */

    avpkt.data = inbuf;

    avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);

 

    while (avpkt.size > 0) {

        int got_frame = 0;

 

        if (!decoded_frame) {

            if (!(decoded_frame = avcodec_alloc_frame())) {

                fprintf(stderr, "out of memory\n");

                exit(1);

            }

        } else

            avcodec_get_frame_defaults(decoded_frame);

 

        len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);

        if (len < 0) {

            fprintf(stderr, "Error while decoding\n");

            continue;

            exit(1);

        }

 

And this doesn´t work, len reports always -11 (not sure what this means) 


 

Any help is more than welcome !


Thanks,

Sven

 

 

 



More information about the ffmpeg-user mailing list