Adding an audio channel using ffmpeg

I am working on ffmpeg and trying to add an audio stream on the fly. I use AudioQueues and I get the original sound buffer. I encode audio with linear PCM, and therefore the sound I get will have a raw format, which, as I know, ffmpeg really accepts it. But I can’t figure out how to do this. I looked into AVStream, where we need to create a new stream for this audio channel, but how to encode it on a video that is already initialized in another AVStream structure.

In general, I would like to have an idea of ​​the ffmpeg architecture. It was difficult for me to work, as this is the least documented. Any pointers or details are appreciated.

Thanks and Regards, Raj Pavan G

+6
cocoa ffmpeg macos
source share
1 answer

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

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

+2
source share

All Articles