Video per-frame integrity check - verifying losslessness

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....

Video per-frame integrity check - verifying losslessness

Postby peter_b » Thu Jan 06, 2011 1:10 am

[PROBLEM]
Sometimes you want to verify the integrity of your video material when dealing with lossless codecs.
The only way to be sure that not a single bit of visual information is lost, is by decoding each frame into an uncompressed image and verify that.

[SOLUTION]
Using ffmpeg:
Code: Select all
ffmpeg -i video.avi -f framemd5 video.avi.framemd5

NOTE:
The suffix ".framemd5" is chosen arbitrarily to somewhat identify framemd5 files. The resulting framemd5-file is actually a plain text file.

ffmpeg also offers additional checksum abilities, like:
framecrc
md5
crc


NOTE:
The frame-checksum feature of ffmpeg also generates checksums for the audio "frames". As they are not necessarily sample-wise aligned the same way in a remuxed/transcoded file, it might be a good idea to disable the audio stream for image-checksum comparisons:
Code: Select all
ffmpeg -i video.avi -an -f framemd5 video.avi.framemd5

(The switch "-an" means "audio: no")

Using mplayer:
Code: Select all
mplayer -vo md5sum -o video.avi.framemd5 video.avi

(thanks to Diego's post on the ffmpeg-devel mailing list)
Warning: By default, mplayer seems to convert the colorspace to YV12 4:2:0
  • 0

Last edited by peter_b on Tue Dec 20, 2016 7:24 pm, edited 4 times in total.
User avatar
peter_b
Chatterbox
 
Posts: 277
Joined: Tue Nov 12, 2013 2:05 am
Reputation: 3

Re: Video per-frame integrity check - verifying losslessness

Postby peter_b » Mon Aug 13, 2012 4:55 pm

UPDATE:
As the alignment of audio data within each audio frames can change during remuxing, framemd5 cannot be applied to audio without preparation.

Using the audio filter "asetnsamples" helps packing a fixed amount of samples into one frame, therefore making the MD5 sum of each audio frame comparable, too:
Code: Select all
ffmpeg -i video.avi -filter_complex "asetnsamples=n=96000" -f framemd5 video.avi.framemd5


The "asetnsamples=96000" makes sure that only 96000 bytes are stored in each audio frame, therefore the framemd5 line for such an audio frame looks as follows:
0, 96000, 96000, 96000, 384000, 856c852b100fa835447df9dd48a71fe5


Thanks to Dave Rice, who suggested this on the ffmpeg-user mailing list (August 7th, 2012)
  • 0

User avatar
peter_b
Chatterbox
 
Posts: 277
Joined: Tue Nov 12, 2013 2:05 am
Reputation: 3

Re: Video per-frame integrity check - verifying losslessness

Postby peter_b » Sat Mar 09, 2013 11:14 pm

If you're trying to compare remuxed files, you might have to preprocess the framemd5 textfile.
It contains columns, separated by a comma-character, so we can use "cut" to extract the checkum-column:
Code: Select all
$ cat video.mkv.framemd5 | cut -d "," -f 6 > video.mkv.framemd5-only
  • 0

User avatar
peter_b
Chatterbox
 
Posts: 277
Joined: Tue Nov 12, 2013 2:05 am
Reputation: 3


Return to Knowledge Base

Who is online

Users browsing this forum: No registered users and 5 guests

Who is online over last 24 hours

Users browsed this forum in the last 24 hours: Bing [Bot], Google [Bot] and 54 guests

cron
Reputation System ©'