1

I am trying to write a code in c/c++ (objective c) to parse the audio and video data from mp4 file. I know that data in mp4 file contains under the mp4 atom but not sure how i can parse out the audio and video data separately.

Thanks in advance for any help.

Paul R
  • 208,748
  • 37
  • 389
  • 560
Dinesh
  • 929
  • 7
  • 25
  • Want to add that mp4 contains h264 encoded video and aac encoded audio. – Dinesh Aug 20 '15 at 09:32
  • You mention three different languages in your question - which one are you actually planning to use ? – Paul R Aug 20 '15 at 09:32
  • Thanks for showing the interest in this question @PaulR language doesn't matter much i need the logic for parsing the same. if its in c it can run on other languages as well.. – Dinesh Aug 20 '15 at 09:33
  • 1
    OK - so you don't want to use a library or OS API for this then - you want to write it all from scratch ? – Paul R Aug 20 '15 at 09:36
  • basically yes.. I am trying to do RTSP broadcasting and i am reading data from mp4 file. i have found the logic somewhere where they are reading video packets from the mp4 and brodcasting it on RTSP but same is not available for audio. So need a logic for the same. – Dinesh Aug 20 '15 at 09:39
  • Here is the code which i am trying to modify for both audio and video.. http://www.gdcl.co.uk/iOS/encoderdemo.zip – Dinesh Aug 20 '15 at 09:41
  • Any more suggestions from anyone who has worked on RTSP implementation reading data from mp4 file? – Dinesh Aug 20 '15 at 13:00

1 Answers1

0

Mp4 format is fairly complicated. I suggest you use a library. But if you can't use a library, or just wan to learn the format, Than you must parse about a dozen boxes or atoms under the root moov box. The information from there can be used to find frames within the mdat atom. The full specifications is numbered ISO/IEC 14496-12 You should be able to find a copy online.

szatmary
  • 29,969
  • 8
  • 44
  • 57
  • Thanks szatmary.. i have added a link to the code above in which usr has parsed some Atoms of the mp4 container. but it is for video only. It read atoms avc1 and avcC and some information (which i don't understand)and after that it jumps to mdat elemet and start reading the video packets. I am not sure how to modify the same code for reading the Audio and video data from the same file. Can you please let me know how can i differentiated between an audio data and video data while reading a mp4 file mdat data.. – Dinesh Aug 21 '15 at 05:09