[Libav-user] Left channel noise in audio

Ankush wadkes93 at gmail.com
Tue May 13 08:11:17 CEST 2014


This is my sample audio code for reading a fixed size of buffer. 
everything works just fine in it even the sync is maintained but the 
problem is i get only noise on the left channel and a constant noise on 
the right channel along with the audio output.

can anyone have a look at it and show me some solution to remove the noise.
my input file is a AV_SAMPLE_FMT_FLTP with channel_layout = 3.

audio_pkt_size = bufferSize;
while (av_read_frame(m_mpegIn->pFormatCtx, &avpkt)>=0)
     {
         if(avpkt.stream_index==m_mpegIn->audioStreamIndex)
         {
             if (!(decoded_frame = avcodec_alloc_frame()))
             {
                         fprintf(stderr, "Could not allocate audio 
frame\n");
                         exit(1);
                 }
         else
         {
             avcodec_get_frame_defaults(decoded_frame);
         }

         len = avcodec_decode_audio4(m_mpegIn->pAudioCodecCtx, 
decoded_frame, &got_frame, &avpkt);

         if (len < 0)
         {
             // if error, skip frame
             audio_pkt_size = 0;
             break;
         }

         if(audio_pkt_size >= decoded_frame->linesize[0])
         {
             //My calculations for filling remaining buffer

         }
         buf = buf + 
decoded_frame->linesize[0]/*(decoded_frame->nb_samples * 
(m_mpegIn->bitsPerSample/8))*/;
         avpkt.data += len;
         avpkt.dts = avpkt.pts = AV_NOPTS_VALUE;

         if( audio_pkt_size > 0 )
         {
             int size = sizeof(*_buffer);
             // No data yet, get more frames
             continue;
         }
         else
         {
             av_frame_free(&decoded_frame);

             return ;
         }

         }

         if (avpkt.data)
             av_free_packet(&avpkt);

     }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140513/ac88a44c/attachment.html>


More information about the Libav-user mailing list