I can't get the ffmpeg to work with sound at all.

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

I can't get the ffmpeg to work with sound at all.

Peadar Ó'Colmáin

I can't seem to make any headway with ffmpeg and sound.

I've been at it for quite some time now and I have downloaded half the
internet looking for a working example.

I am using a downloaded program falled 'fister' which is probably quite
well known.

I have put code into it so that it will read the file, then compress and
decompress the sound and play it.

I should be getting my own voice back but I get nothing.

Here is the code.

I can send the whole fister project if anyone could like to have a look
at it.

Again, thanks in advance for any help received.


void CPipe::ReadSoundDataFromFile(CBuffer* buffer)
     char ErrLine[501];

     int j,k,ret, got_output, len2, cnt;
     uint8_t *       out[]   = { audio_buf };

             delete m_pFile;

     ChineseFrameBuff = (uint8_t *)buffer->ptr.c;

     ChinesePacket.data = NULL;
     ChinesePacket.size = 0;

     ret = avcodec_encode_audio2(ChineseCodecCtx, &ChinesePacket,
ChineseFrame, &got_output);
     if (ret < 0)
         sprintf(ErrLine, "Error encoding audio frame");

     if (got_output)
         int got_frame=0;
     //    avcodec_get_frame_defaults(Mp3Frame);    // doesn't seem to
do aything

         int len = avcodec_decode_audio4(Mp3CodecContext, Mp3Frame,
&got_frame, &ChinesePacket);

         if (len < 0 || got_frame == 0)
             sprintf(ErrLine, "Error while decoding");
         if(m_pSwrCtx == NULL)
             m_pSwrCtx = swr_alloc_set_opts(NULL
                             , AV_CH_LAYOUT_STEREO
                             , AV_SAMPLE_FMT_S16
                             , Mp3CodecContext->sample_rate
                             , (AVSampleFormat)Mp3Frame->format
                             , Mp3Frame->sample_rate
                             , 0
                             , NULL

         len2 = swr_convert(m_pSwrCtx
                             , out
                             , AVCODEC_MAX_AUDIO_FRAME_SIZE * 4
                             , (const uint8_t **)Mp3Frame->extended_data
                             , Mp3Frame->nb_samples

         // make sure the buffer is cleared out.

         for(int count=0; count<2000; count++)
             buffer->ptr.c[count] = '*';

         strcpy(buffer->ptr.c,  (char *)audio_buf);

This email has been checked for viruses by AVG.

ffmpeg-user mailing list
[hidden email]

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".