How to wrap H264 in mp4 container?

I have a program that creates a bunch of unprocessed H264 frames and would like to place this in an mp4 container for streaming.

Does anyone know how to do this?

I thought I would use ffmpeg, however it should be used for commercial purposes, and it seems that ffmpeg can only do this through the x264 library ... which uses the GPL license.

Thanks!

+6
source share
2 answers

libmp4v2 is under MPL and can be used as part of larger work for commercial purposes. This is much easier than libavformat.

+1
source

If you are looking for the FFMPEG command line for this, try the following:

ffmpeg -i "source.h264" -c:v copy -f mp4 "myOutputFile.mp4" 

If you have a separate audio file, you can also add it:

 ffmpeg -i "source.h264" -i "myAudio" -c:v copy -c:a copy -f mp4 "myOutputFile.mp4" 

If your sound should also be encoded (e.g. AAC-LC codec, 256-bit / s bit-bit):

 ffmpeg -i "source.h264" -i "myAudio" -c:v copy -c:a aac -b:a 256k -strict -2 -f mp4 "myOutputFile.mp4" 

If this helps, mark this as a good answer. Thanks!

+13
source

All Articles