[FFmpeg-user] Trying to get he example prorgam decode_encode.c to run

Peadar Ó'Colmáin peadar.e.ocolmain at gmail.com
Wed Dec 13 16:05:20 EET 2017

Hello all,
I am looking at the demonstration code decode_encode.c which I received 
with ffMpeg when I downloaded it. I want to get this code  to run as it 
is before doing anything else with it.
I have the part that uses avcodec_encode_audio2 to encode into mp2 format.
This program opens just one file, the one it writes to so I am taking it 
that I am supposed to give it its source sound.
I am using Windows and Visual C++.
I recorded my voice with Audacity and saved it as a WAV file.
Then I opened that WAV file with a fopen command and I put the following 
'fread' line into the example program.
         pkt.data = NULL; // packet data will be allocated by the encoder
         pkt.size = 0;
BytesRead = fread(samples, 1, buffer_size, InFilePtr); // from my WAV file
         for (j = 0; j < c->frame_size; j++)
             samples[2*j] = (int)(sin(t) * 10000);

             for (k = 1; k < c->channels; k++)
                 samples[2*j + k] = samples[2*j];
             t += tincr;
It runs and writes to the file ok but the output file in MP2 format just 
makes a whirring noise.
Has anyone managed to get his program to run and to process a source 
file into MP2?. Am I misunderstanding something? Is WAV the correct 
format to start with?

Any help much appreciated


This email has been checked for viruses by AVG.

More information about the ffmpeg-user mailing list