Search code examples
ffmpegmetadatamp4checksummkv

Same FFmpeg command produces different Matroska MKV output file checksum


The following exemplary FFmpeg command takes an MP4 file, doesn't do any re-encoding, but simply writes the output to an MKV file:

ffmpeg -i input.mp4 -c copy output.mkv

If I run the same command twice, with two different output files:

ffmpeg -i input.mp4 -c copy output1.mkv
ffmpeg -i input.mp4 -c copy output2.mkv

The resulting files will have differing checksums:

aa46d308197cb08d71f271c61d5412ad  output1.mkv
8b48c3ebdbf2384705fcb78e864d12e3  output2.mkv

This difference disappears if I convert them back to an MP4 container:

ffmpeg -i output1.mkv -c copy output1.mp4
ffmpeg -i output2.mkv -c copy output2.mp4

For differing MKV input files I'm getting the same checksum for the MP4 output files:

24e92b3e228db780b5feab14255870e3  output1.mp4
24e92b3e228db780b5feab14255870e3  output2.mp4

So obviously the video itself hasn't been modified and there's some metadata in the MKV container that's responsible. What data is it and how do I prevent this data from being added?


Solution

  • Matroska and WebM formats assign random IDs to tracks unless suppressed by adding -bitexact.