linuxvideoffmpegmd5checksum

How to md5 the video track (only) in ffmpeg


I have a .mov file with a video and several audio tracks. To md5 the entire file I can do:

[pdev@d ~]$ md5sum 1_TRAILER_HD_2CH_ES419_ENSUB_16X9_178_2398_DIGITAL_FINAL.mov
042f0e177fe25f562079cc07208ec446

Though when I try doing the same thing in ffmpeg, I get a different value:

$ ffmpeg -i 1_TRAILER_HD_2CH_ES419_ENSUB_16X9_178_2398_DIGITAL_FINAL.mov -f md5 -
MD5=74bd904f1edb4eb1368040e2792d7497   0kB time=00:01:59.11 bitrate=   0.0kbits/s speed=2.36x
frame= 2867 fps= 56 q=-0.0 Lsize=       0kB time=00:01:59.57 bitrate=   0.0kbits/s speed=2.35x
video:23222700kB audio:22421kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Why is the value different? Additionally, how can I checksum only the video track? I have various files that have different audio tracks and want to see if I have the same video track on those files.


Update: I believe this answer shows how to compute an audio-only checksum, but not sure about video-only: https://superuser.com/a/1044419/118248.


Solution

  • md5sum vs ffmpeg

    To checksum only the video track

    Add the -map option to only choose the video stream(s). Using -map disables the default stream selection behavior and allows you to manually choose the streams you want.

    Example: Decoded

    The video and/or audio will be fully decoded. This can be slow.

    ffmpeg -i input.mp4 -map 0:v -f md5 -
    

    Example: Stream copied

    This just gets the MD5 using stream copy mode. There is no decoding.

    ffmpeg -i input.mp4 -map 0:v -c copy -f md5 -
    

    Example: Show video and audio checksums separately

    Using the streamhash muxer:

    ffmpeg -i input.mp4 -map 0 -c copy -f streamhash -hash md5 -
    ...
    0,v,MD5=50224fec84bc6dfde90d742bcf1d2e01
    1,a,MD5=1d2a32ed72798d66e0110bd02df2be65
    

    Example: Per frame

    Using the framehash muxer:

    ffmpeg -i input.mp4 -map 0 -f framehash -
    

    More info