Convert mp4 tracks to images WITHOUT ffmpeg


Convert mp4 tracks to images WITHOUT ffmpeg



I'm developing an C# tool to extract mp4 frames to images. ( Without using ffmpeg )



I use a tool named ISO Viewer 2.0.2 and i see all my mp4 video frames (145 frames for 5 seconds, each frames is called as sample) in Tracks tab.



ISO Viewer 2.0.2 screen shot



On each frames/samples I can get it data byte. So how it convert this data to image in C# ?




1 Answer
1



You most likely want to use some library to do this. This can get quite complex, if you are planning to do this yourself. I will try to illustrate by listing the steps needed to do that.



First you will need to figure out what video codec is used on the MP4. If you are lucky, it is H.264, but MP4 files can contain a lot of different video codecs. You can find the H.264 spec here: https://www.itu.int/rec/T-REC-H.264-201704-I/en (it is over 700 pages)



Then you need to actually use the extracted frame, and decode it according to the H.264 spec



If the frame is not an I-frame, you might need to look at prior frames to decode it. You might need to look at more than one prior frame.



If you are unlucky enough that the video contains B frames, you might need to look at future frames in addition to prior frames in order to decode it.



You are looking at a very large project to do this with just H.264 files, and then that only covers some MP4 files, and far from all. You will be much better off using something like ffmpeg, or a similar framework to do this.



If for some reason you are unable to use ffmpeg, then you might look into https://msdn.microsoft.com/en-us/library/windows/desktop/dd940436 (the usage of C# implies that you are using Windows).






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Moria Casán

How to make file upload 'Required' in Contact Form 7?

Quinn's Post Commonwealth War Graves Commission Cemetery