I have a server with lots of video files. After a restore, I noticed that the checksum of a couple of files changed. Since I don't have checksums for all files, I wanted write a script to verify the file integrity. It's simple for archives (tar t
, unzip -t
, rar t
, etc) or images (convert image.jpg /tmp/test.png
).
Which options do I need to pass to mplayer
or vlc
or any other video tool on Linux to achieve the same effect (i.e. validate the file contents without having to watch the whole video)?
Using JavaScript, you can easily check the selected file extension with allowed file extensions and can restrict the user to upload only the allowed file types. For this we will use fileValidation() function. We will create fileValidation() function that contains the complete file type validation code.
How does a corrupt video file look? A corrupted video file may become unreadable, show errors, and won't open in any media player. Video not playing properly is also a sign of corruption. Black screen, no sound, truncated, jerky, flickering, color damaged, etc., indicate video corruption.
It sounds like what you want to do is:
mplayer -vo null -ao null input.file
and then parse the output and return value to see if it could actually play & decode the stream. This will take some time (but be faster than realtime). If you want something even faster, here are some more suggestions:
One easy thing is going to be to do an
mplayer -identify -vo null -ao null
on the file, and then parse the output and look at the return value for something that looks reasonable.
With respect to the checksums being incorrect, it's going to be hard to know if this is an issue for your media player or not (mplayer, vlc, totem, etc.). A good media player will tolerate many bit or byte level errors with little impact on the resulting playback. A very strict media player will exit when it sees malformed or incorrect codec & wrapper bytes.
To verify the wrapper (container) bytes, you could do something like
mencoder -ovc copy -oac copy input.file -o output.file
The problem is that mencoder will want to create an .avi file for output. If your inputs are .avi, then this will work great.
You can run a similar ffmpeg commandline, like this:
ffmpeg -acodec copy -vcodec copy input.file output.file
If the files are .mp4 files, you might want to take a look at mp4box ( http://www.videohelp.com/tools/mp4box ) for doing a similar task. The matroska tools are also good for this kind of thing. ( http://www.matroska.org/ )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With