1

I'm doing some integration work with video (H.264) and audio (AAC) from an IP camera.

I've made a bit of progress and I can store the video & audio streams individually with the ability to play it back using VLC player. The H.264 is being stored in Annex B format and the audio is using an adts formatted file.

I'm now trying to mux the streams into an MP4 file without doing any decoding or encoding but so far haven't managed to find the answer.

I can do this manually with ffmpeg: ffmpeg -i recording.h264 -i recording.aac -vcodec copy -acodec copy -absf aac_adtstoasc recording.mp4

How do I do this with the ffmpeg library from C++?

Brad Mitchell
  • 254
  • 1
  • 3
  • 12

1 Answers1

1

Check out the muxing sample; the key is to keep track of your audio/video timestamps and write the next one in time using av_interleaved_write_frame.

congusbongus
  • 13,359
  • 7
  • 71
  • 99
  • I've been looking at the example but it doesn't help as much as I'd like. avcodec_find_encoder will not find the encoder for H.264 as the library has been compiled without the encoder for H.264. ffmpeg still works using by using "copy" for vcodec. This mux example does not do that. If I can't find a codec and open it, how can I establish an AVStream properly? – Brad Mitchell Mar 06 '13 at 06:20
  • @user1232361 The muxing example actually includes transcoding as well. You don't need the encoder at if you're just doing a straight copy. The example should serve as a starting point; the key parts would be lines 328-337 (for video). – congusbongus Mar 06 '13 at 06:34