[Ffmpeg-devel] encode audio with FFMPEG ... Please help me

Paul paul.pham
Sat Oct 28 11:47:47 CEST 2006

I have used DirectSound for recording wave file from microphone.

I create a thread to run recording,.... Inside recording function, i have pbCaptureData (type is IDirectSoundBuffer) to get sound data in real-time.

And i also write these codes (in recording function) to encode audio and then write to file

DWORD out_size ;
out_size = avcodec_encode_audio(c, outbuf, outbuf_size, (short*)pbCaptureData);
fwrite(outbuf, 1, out_size, outputfile);
(Note: Before call above, i set outbuf_size = 10000; and outbuf = (unsigned char*)malloc(outbuf_size); i used codec is MP2... )
But the outputfile  (output file) is not correct. Althought the output file was encoded, but data not correct.

I donot know where i am wrong??? Anyone can help me fix...

Or anyone can show me source sample for encoding from exist file (wave format) to MP2.

Thanks you...  

More information about the ffmpeg-devel mailing list