0
votes

I need to develop a small module, that can read and write h.264 packets to a container file. So far I have understood, typically h.264 encoded packets are stored in a mp4 file.

My question is, can h.264 encoded packets be stored in other file containers like in ogg file or in mkv file or in webm file.

If yes, how do I convert a mp4 file to an ogg file or mkv file or webm file, keeping same h.264 encoded packets in file.

1
Most containers do (mkv, flv, avi, ts) some don't (webm, oog). To convert, use ffmpeg.szatmary
If you're writing your own code... Search for XYZ Format Specifications PDF where you replace XYZ with your required format, like MP4 or FLV etc. This will help you understand how each format is structured and where the H.264 bytes should be placed.VC.One

1 Answers

1
votes

H.264 can go into MP4, MKV, webm (pretty much same as MKV), FLV, F4V and others. Please check https://en.wikipedia.org/wiki/Comparison_of_video_container_formats

For conversion I'd use ffmpeg which will do most combinations.

ffmpeg -i inputfile.xyz -vcodec copy ... (specify output file and audio stream)