[Ffmpeg-devel] Encoding from PCM to MPEG

Michel Bardiaux mbardiaux
Tue Jan 9 10:23:40 CET 2007


Paul wrote:
> i get output_example.c in installation of ffmpeg..
> 
> i care about encoding audio frame from PCM to MPEG,
> 
> i see these code:
> 
> void get_audio_frame(int16_t *samples, int frame_size, int
> nb_channels) { int j, i, v; int16_t *q;
> 
> q = samples; for(j=0;j<frame_size;j++) { v = (int)(sin(t) * 10000); 
> for(i = 0; i < nb_channels; i++) *q++ = v; t += tincr; tincr +=
> tincr2; }
> 
> }
> 
> the samples point will be use for the function write_audio_frame. So
> if run my app (code copy from output_example.c ) then this work. But
> now, i would like to to use buffer PCM instead of constant values of
> samples .
> 
> Beside that, I used directsound and can get each captured buffer .
> The data of buffer were stored in this point: VOID * pbCaptureData
> 
> So, how i can use data or change data for samples . I would like pass
> all data of pbCaptureData to samples . And after this, i will call
> function write_audio_frame.
> 
> Please help me how to do that? 

get_audio_frame simply synthesizes a frame. If you grab real ones, what 
you need is a function to extract frame_size*nb_channels samples from 
your data. If what remains in pbCaptureData is not enough, grab another 
buffer. If its too much, keep the remainder somewhere.

output_example has mostly tutorial value. For 'real' applications, 
ffmpeg.c itself is *the* reference.

Greetings,
-- 
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux at mediaxim.be

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/




More information about the ffmpeg-devel mailing list