1

I'm getting these results under Windows (ffmpeg version N-78636-g45d3af9)

ffmpeg.exe -i TEST.mp3 -c:a copy -f md5 -
MD5=cb017003b355c2b39d71e8020bd76f5b

ffmpeg.exe -i TEST.mp3 -f md5 -
MD5=7bbe06733ddc930c8a120bced0f3fad9

Why is it different? And what is the proper way to calculate MD5 checksum for audio data only? How do I make ffmpeg return the string (MD5=xxxxx.xxxxx) only?

4
  • 1
    Next time asking about ffmpeg, please include the full, uncut command line output.
    – slhck
    Feb 23, 2016 at 12:17
  • just thought it's easy to understand when I cut it! but nex time I will for sure ... Thanks
    – Data-Base
    Feb 23, 2016 at 12:23
  • 1
    Sure thanks. Sometimes it's not necessary, but it helps us catch minor errors or give explanations better suited to the question.
    – slhck
    Feb 23, 2016 at 12:23
  • See also this answer which shows how to use -map to select which stream to checksum.
    – mivk
    Nov 4, 2020 at 18:07

1 Answer 1

3

If you read the documentation for the MD5 muxer, it says:

By default audio frames are converted to signed 16-bit raw audio and video frames to raw video before computing the hash.

So, in your second command (without specifying any codec option), this'd be the equivalent of -c:a pcm_s16le, while in your first example, you keep the MP3 audio bitstream. That's why they have different checksums.

The proper way would probably be to disable video streams (if the MP3 file contains artwork, for example) using -vn:

ffmpeg.exe -i TEST.mp3 -vn -f md5 -

You can disable the other output by redirecting stderr:

ffmpeg.exe -i TEST.mp3 -vn -f md5 - 2>NUL

On Linux, use /dev/null instead of NUL.

4
  • now I get this MD5=6e08f3bb7e5e8cc27e2f77a7817abbba a bit more confused ... but I will change the file tags and see how it will be :)
    – Data-Base
    Feb 23, 2016 at 12:24
  • 2
    If the MP3 contains artwork, it'll be rendered as a video stream and used in the MD5 calculation unless you disable it with -vn. If you show the complete ffmpeg output in your question, we can have a better look at it.
    – slhck
    Feb 23, 2016 at 12:25
  • after deleting all tags from file: ffmpeg.exe -i TEST.mp3 -vn -f md5 - 2>NUL MD5=6e08f3bb7e5e8cc27e2f77a7817abbba ffmpeg.exe -i TEST.mp3 -f md5 - 2>NUL MD5=6e08f3bb7e5e8cc27e2f77a7817abbba ffmpeg.exe -i TEST.mp3 -c:a copy -f md5 - 2> MD5=886d08f4e9c5450ee12796b006307a33
    – Data-Base
    Feb 23, 2016 at 12:28
  • 1
    That makes sense now. (I was asking about the full output, without the redirection, to see what kind of tags there were, but you seem to have resolved the problem.)
    – slhck
    Feb 23, 2016 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.