[Libav-user] Error in reading streaming context - using libavcodec 57.64.101

יוסף אלון yos104104 at gmail.com
Tue Apr 4 13:15:38 EEST 2017


I am reading a udp data and recieve:

Input #0, mpegts, from 'udp://224.10.0.15:1234':
  Duration: N/A, start: 66502.042356, bitrate: N/A
  Program 29
    Metadata:
      service_name    : Galatz
      service_provider: Idan +
    Stream #0:0[0xb81]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011),
48000 Hz, stereo, fltp

But when I print the codec context I receive the following data:
Bits: 8, Channels:2048
sample_rate: 8.

What is the meaning of 2048 channels (2 - is stereo)?
and why do I have 8 bit for fltp?

The code part is:

 av_register_all();
   avformat_network_init();


    const char* input_filename=argv[1];

   AVFormatContext* container=avformat_alloc_context();
    if(avformat_open_input(&container,input_filename,NULL,NULL)<0)
        die("Could not open file");

    if(avformat_find_stream_info(container,NULL)<0)
        die("Could not find file info");


   av_dump_format(container,0,input_filename,0);


    int stream_id=-1;
    int i;
    for(i=0;i<container->nb_streams;i++)
    {
       if(container->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO)
        {
            stream_id=i;//audio stream index
            break;
        }
    }
    if(stream_id==-1){
        die("Could not find Audio Stream");
    }

  //  AVDictionary *metadata=container->metadata;

    AVCodecContext *ctx=container->streams[stream_id]->codec;
    AVCodec *codec=avcodec_find_decoder(ctx->codec_id);

   // ctx=avcodec_alloc_context3(codec);

    if(codec==NULL){
        die("cannot find codec!");
    }


    if(avcodec_open2(ctx,codec, NULL)<0){
        die("Codec cannot be found");
    }
int bits;
if(sfmt==AV_SAMPLE_FMT_U8){
        printf("U8\n");

        bits=8;
    }else if(sfmt==AV_SAMPLE_FMT_S16){
        printf("S16\n");
        bits=16;
    }else if(sfmt==AV_SAMPLE_FMT_S32){
        printf("S32\n");
       bits=32;
    }
   else if(sfmt==AV_SAMPLE_FMT_FLTP){
        bits=32;
   }
printf("\nBits: %d, Channels:%d\nRate: %d, byte_format:%d
matrix:%s\n",bits, ctx->channels, sformat.rate,
sformat.byte_format,sformat.matrix);

Yosef Alon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20170404/f6e0c5ab/attachment.html>


More information about the Libav-user mailing list