sannies / mp4parser

A Java API to read, write and create MP4 files
Apache License 2.0
2.76k stars 566 forks source link

Reading metadata consumes entire file (out of memory error) #254

Open atoone opened 7 years ago

atoone commented 7 years ago

I am using the current 1.9.,27 release to find the frame rate and duration of a video file. However, the parser reads the entire file into memory, which causes out of memory errors. The main culprit is the video data (mdat) box.

There appear to be more recent commits that write the mdat box to a temporary file rather than keeping it in memory, but this is not ideal for large files as it essentially copies the entire video on disk.

A proposed solution is to initialise the parser with a list of box types to skip when reading the input. I have a pull request that illustrates this.