1

I'm looking to write already compressed (h264) image data into an MPEG-4 video file. Since this code needs to be optimized to run on an embedded platform the code should be as simple as possible. Best would be to just give some header information (like height width format fourcc etc.) and a filename and the compressed data and have that transformed into a data chunck and writen to that file.

So what i need either of these:

  • MPEG-4 header information (what goes where exactly)
    • Is there a main header or are there just headers for each data chunck
    • What header information is needed for a single video stream (rectangular)
    • What header information is needed for adding audio
  • A simple MPEG-4 file writer that does not have to do the compression itself and also allows to add audio frames. (c/c++)
Roman R.
  • 68,205
  • 6
  • 94
  • 158
p.streef
  • 3,652
  • 3
  • 26
  • 50

1 Answers1

1

.MP4 file format is described in MPEG-4 Part 14 specification. It is not just main header and subheaders, it has certain hierarchy and so called boxes in there. Some of your choice to write data into .MP4 file:

Community
  • 1
  • 1
Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • @ Roman R. After wasting a lot of time on trying to get ffmpeg to work I just started looking into GDCL's muxer. I have gotten the dll to compile so i should be able to debug in it, but i have no idea where to start with this. Can you perhaps send me towards some example code to use this multiplexer? I've tried GDCL site but it seems to be down (except for the site you've linked to) – p.streef Aug 28 '12 at 12:29
  • http://www.gdcl.co.uk/mpeg4/ is back to life. It might be not so easy to start with DirectShow from scratch because in order to consume this MP4 multiplexer, you need to create a graph with this component and others, and run it. And in order to inject your own chunks into the graph, you need a custom filter that delivers this data. It is not rocket science but it assumes certain understanding of the API. I am not even sure if it can be recommended for embedded system, but ffmpeg stroke out what else remains. – Roman R. Aug 29 '12 at 09:15
  • Basically I would create a custom source filter to send H.264 chunks. Then I would have it connected to the MP4 multiplexer, which would then be connected to standard File Writer component. All together started would have data written into an .MP4 file. To add audio, you would need another source filter for audio (AAC typically) and the multiplexer has another input for it as well, to put all this into the resulting single .MP4 – Roman R. Aug 29 '12 at 09:17