Reputation: 613
In my servlet application (that serves android apps) i allow to upload mp4 files. Now i am paranoic and i want to validate uploaded videos by looking at the content not only by checking the content type and the extension since : the content type can be easily spoofed and if someone finds some bugs in standard android player it can also upload a .mp4 malware that can exploit my users applications.
So im just looking for a simple way to check if the uploaded files have at least a valid mp4 structure. Im also very interested in performance so i also dont like to parse the whole file like i were doing when i want to play it.
Is there any way to do that ?
Thanks
Upvotes: 2
Views: 4241
Reputation: 1919
The simple answer is: no, there is not really a simple way to do it. You could use a 3rd party java library that knows how to decode/intepret a valid .mp4 file such as the one zod mentioned, but (in my mind) that falls outside of the 'simple category'.
Another option would be to check to see if valid .mp4 metadata is available in the file, but because the metadata is not required, this isn't really a good solution.
Upvotes: 3