Reputation: 11
How can I convert a media file from mp4 (aac and libx264) to mp4 (mp3 and h264) using libavcodec? Can anyone explain what steps I have to do? As I know, I must decode and then encode audio and video stream to target codec. But how can I save these stream into a mp4 file?
Upvotes: 1
Views: 551
Reputation: 189
You can write h264 and mp3 using libavcodec, but to write them in an mp4 file you're gonna need libavformat. It's not a simple process, and FFmpeg / Libav libraries are notoriously unintuitive. There are a couple of examples in their source tree which illustrates the process pretty well. Look for video_encode_example() and audio_encode_example() in decoding_encoding.c. There is also muxing.c.
For beginners, I recommend that you look into ffmpegsource which is a wrapper around FFmpeg / Libav libraries.
I wrote most of the code here for a plugin which works with a framework called Tuttle. This should also serve as an example. But don't use it as definitive. Read the documentation that comes with libavcodec and libavformat.
Upvotes: 1