ExifTool Forum

ExifTool => Developers => Topic started by: TheGreatFuzz on March 11, 2018, 03:00:16 AM

Title: Would it be possible to extract, save and analyze only the header information?
Post by: TheGreatFuzz on March 11, 2018, 03:00:16 AM
Hello All,

I would like to write a web application that allows us to analyze the file before it is uploaded. This is to save our users the frustration of us rejecting a 10 gig video file because of an incorrect setting.
I am able to extract any number of bytes from a local file already (in javascript) using :


var blob = file.slice(startingByte, endindByte);
reader.readAsBinaryString(blob);

or

var byteArray= reader.readAsDataURL(blob);


There is a nifty javascript library https://github.com/exif-js/exif-js based on Exiftool that only allows image analysis currently, and The above code works with that, if I for example extract the first 1000 bytes of an image and run it through the library it is able to show me all the exif data.

So I am hoping I could do the same with large videos, I attempted to grab the first 1000 bytes of a video file as a bytearray then I converted it to a base64 string, then I passed it to my backend where I   decoded it to a binary file and then ran that file through the exiftool.exe but it failed to anaylize.

I assume I am either barking up the wrong tree or I don't fully understand one or many of the implications of what I am trying to achieve.

If anyone would be able to assist me I would be most grateful.

Is what I am trying to do possible? if so.. what would you recommend?

Thanks
Title: Re: Would it be possible to extract, save and analyze only the header information?
Post by: Phil Harvey on March 11, 2018, 08:08:35 AM
This may work with some video types where the metadata is stored at the beginning of the image (but I would take the first few MB, not just 1 kB).  However I would say that it won't work for maybe 40% of videos because it is fairly common for the metadata to be stored at the end of the file.

- Phil
Title: Re: Would it be possible to extract, save and analyze only the header information?
Post by: TheGreatFuzz on March 12, 2018, 06:10:31 AM
Thanks Phil, I appreciate the response.

I managed to get it to work (mostly).. Is there anyway to tell how many bytes I should extract by analyzing any specific bytes at the start?
IE: is there an indicator how long the meta/exif data is and where to find it if possible.

Kind regards 
Title: Re: Would it be possible to extract, save and analyze only the header information?
Post by: Phil Harvey on March 12, 2018, 07:06:04 AM
If the metadata is at the start, you only need to load up to the 'mdat' atom in MOV/MP4 videos.  Usually this works for MOV, but I think MP4 more often has metadata at the end.

- Phil