tags:

views:

391

answers:

1

Hi all,

I am working on ffmpeg and trying to add a audio stream on the fly. I am using AudioQueues and I get raw audio buffer. I am encoding audio with linear PCM and hence the audio I get will be of raw format, which I know ffmpeg does accept it. But I cannot figure out how. I have looked into AVStream, where in we have to create a new stream for this audio channel but how do I encode it to a video which is already initialized in another AVStream structure.

Overall, I would like to have an idea of the architecture of ffmpeg. I found it difficult to work since it is least documented. Any pointers or details are appreciated.

Thanks and Regards, Raj Pawan G

+2  A: 

If you want to use java, you'll find a much better documented API wrapper for FFmpeg with Xuggler.

That said, FFmpeg can support Raw PCM bu tnot all containers can contain it. use the PCM codecs (see avcodec.h) and find the one that has the right size and attributes you want. To add the audio to the same container find a AVFormatContext object that you use for your existing video stream, and use av_new_stream(...) to add a new stream. Then attach your PCM encoder and 'encode' to that and write resulting packets. See output_example.c in the FFmpeg for examples of this API in action.

Xuggle
Ya thanks, I already started following in that direction. I am basically following output_example.c and will get back to you if I am struck anywhere. I am using Cocoa though, not java. But anyhow, the implementation language is an abstraction for FFMpeg calls!
Raj