[FFmpeg-user] Different FrameMD5 when converting between loss-less encodings

Tobias Rapp t.rapp at noa-archive.com
Mon Nov 7 11:09:08 EET 2022


Hi,

recently when testing I stumbled over the situation that a specific 
10-bit YUV input file was encoded separately using two different 
loss-less encoders V210 and FFV1. When comparing the FrameMD5 checksum 
of both output files most of the checksums did match, but some of them 
where different (approx. 3% of the frames).

When trying to reproduce the scenario with the attached batch script 
using a video source filter the resulting files even differ in every 
frame. My assumption would have been that the FrameMD5 checksums of both 
files would be the same, as they originate from the same input file and 
the intermediate encoding should be loss-less.

Can someone give a hint where the differences come from? Is there some 
command-line option for bit-exactness missing, or is there something 
going wrong in the decoder/encoders?

Regards,
Tobias
-------------- next part --------------
ffmpeg version N-109026-ge17628b Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --disable-network --enable-libsoxr --enable-libtwolame --enable-libmp3lame --enable-libvorbis --enable-libfreetype --enable-static --disable-shared --prefix=/usr/local
  libavutil      57. 42.100 / 57. 42.100
  libavcodec     59. 52.100 / 59. 52.100
  libavformat    59. 34.101 / 59. 34.101
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 50.100 /  8. 50.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
Stream mapping:
  format:default -> Stream #0:0 (ffvhuff)
Press [q] to stop, [?] for help
Output #0, avi, to './temp/ffmpeg-10bit-test-input.avi':
  Metadata:
    ISFT            : Lavf59.34.101
  Stream #0:0: Video: ffvhuff (FFVH / 0x48564646), yuv422p10le(tv, progressive), 720x576 [SAR 1:1 DAR 5:4], q=2-31, 200 kb/s, 25 fps, 25 tbn
    Metadata:
      encoder         : Lavc59.52.100 ffvhuff
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=   25 fps=0.0 q=-0.0 Lsize=    6869kB time=00:00:00.96 bitrate=58617.6kbits/s speed=9.06x    
video:6863kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.092806%
ffmpeg version N-109026-ge17628b Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --disable-network --enable-libsoxr --enable-libtwolame --enable-libmp3lame --enable-libvorbis --enable-libfreetype --enable-static --disable-shared --prefix=/usr/local
  libavutil      57. 42.100 / 57. 42.100
  libavcodec     59. 52.100 / 59. 52.100
  libavformat    59. 34.101 / 59. 34.101
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 50.100 /  8. 50.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
Input #0, avi, from './temp/ffmpeg-10bit-test-input.avi':
  Metadata:
    software        : Lavf59.34.101
  Duration: 00:00:01.00, start: 0.000000, bitrate: 56272 kb/s
  Stream #0:0: Video: ffvhuff (FFVH / 0x48564646), yuv422p10le, 720x576, 58563 kb/s, SAR 1:1 DAR 5:4, 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (ffvhuff (native) -> v210 (native))
Press [q] to stop, [?] for help
Output #0, avi, to './temp/ffmpeg-10bit-test-output01.avi':
  Metadata:
    software        : Lavf59.34.101
  Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le(progressive), 720x576 [SAR 1:1 DAR 5:4], q=2-31, 221184 kb/s, 25 fps, 25 tbn
    Metadata:
      encoder         : Lavc v210
frame=    0 fps=0.0 q=-0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=N/A    
frame=   25 fps=0.0 q=-0.0 Lsize=   27006kB time=00:00:00.96 bitrate=230452.7kbits/s speed=6.92x    
video:27000kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.022888%
ffmpeg version N-109026-ge17628b Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --disable-network --enable-libsoxr --enable-libtwolame --enable-libmp3lame --enable-libvorbis --enable-libfreetype --enable-static --disable-shared --prefix=/usr/local
  libavutil      57. 42.100 / 57. 42.100
  libavcodec     59. 52.100 / 59. 52.100
  libavformat    59. 34.101 / 59. 34.101
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 50.100 /  8. 50.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
Input #0, avi, from './temp/ffmpeg-10bit-test-input.avi':
  Metadata:
    software        : Lavf59.34.101
  Duration: 00:00:01.00, start: 0.000000, bitrate: 56272 kb/s
  Stream #0:0: Video: ffvhuff (FFVH / 0x48564646), yuv422p10le, 720x576, 58563 kb/s, SAR 1:1 DAR 5:4, 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (ffvhuff (native) -> ffv1 (native))
Press [q] to stop, [?] for help
[ffv1 @ 0x229a9c0] bits_per_raw_sample > 8, forcing range coder
Output #0, avi, to './temp/ffmpeg-10bit-test-output02.avi':
  Metadata:
    software        : Lavf59.34.101
  Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), yuv422p10le(progressive), 720x576 [SAR 1:1 DAR 5:4], q=2-31, 200 kb/s, 25 fps, 25 tbn
    Metadata:
      encoder         : Lavc ffv1
frame=    0 fps=0.0 q=-0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=N/A    
frame=   25 fps=0.0 q=-0.0 Lsize=     231kB time=00:00:00.96 bitrate=1969.5kbits/s speed=4.12x    
video:224kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.845928%
ffmpeg version N-109026-ge17628b Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --disable-network --enable-libsoxr --enable-libtwolame --enable-libmp3lame --enable-libvorbis --enable-libfreetype --enable-static --disable-shared --prefix=/usr/local
  libavutil      57. 42.100 / 57. 42.100
  libavcodec     59. 52.100 / 59. 52.100
  libavformat    59. 34.101 / 59. 34.101
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 50.100 /  8. 50.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
Input #0, avi, from './temp/ffmpeg-10bit-test-output01.avi':
  Duration: 00:00:01.00, start: 0.000000, bitrate: 221234 kb/s
  Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le, 720x576, 230400 kb/s, SAR 1:1 DAR 5:4, 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (v210 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, framemd5, to './temp/ffmpeg-10bit-test-output01.avi.framemd5':
  Stream #0:0: Video: rawvideo (Y3[10][10] / 0xA0A3359), yuv422p10le(progressive), 720x576 [SAR 1:1 DAR 5:4], q=2-31, 207360 kb/s, 25 fps, 25 tbn
    Metadata:
      encoder         : Lavc rawvideo
frame=    0 fps=0.0 q=-0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=N/A    
frame=   25 fps=0.0 q=-0.0 Lsize=       2kB time=00:00:00.96 bitrate=  18.2kbits/s speed=17.4x    
video:40500kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
ffmpeg version N-109026-ge17628b Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --disable-network --enable-libsoxr --enable-libtwolame --enable-libmp3lame --enable-libvorbis --enable-libfreetype --enable-static --disable-shared --prefix=/usr/local
  libavutil      57. 42.100 / 57. 42.100
  libavcodec     59. 52.100 / 59. 52.100
  libavformat    59. 34.101 / 59. 34.101
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 50.100 /  8. 50.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
Input #0, avi, from './temp/ffmpeg-10bit-test-output02.avi':
  Duration: 00:00:01.00, start: 0.000000, bitrate: 1890 kb/s
  Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), yuv422p10le, 720x576, 1915 kb/s, SAR 1:1 DAR 5:4, 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (ffv1 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, framemd5, to './temp/ffmpeg-10bit-test-output02.avi.framemd5':
  Stream #0:0: Video: rawvideo (Y3[10][10] / 0xA0A3359), yuv422p10le(progressive), 720x576 [SAR 1:1 DAR 5:4], q=2-31, 207360 kb/s, 25 fps, 25 tbn
    Metadata:
      encoder         : Lavc rawvideo
frame=    0 fps=0.0 q=-0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=N/A    
frame=   25 fps=0.0 q=-0.0 Lsize=       2kB time=00:00:00.96 bitrate=  18.2kbits/s speed=7.19x    
video:40500kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Files ./temp/ffmpeg-10bit-test-output01.avi.framemd5 and ./temp/ffmpeg-10bit-test-output02.avi.framemd5 differ
=== TEST FAILED ===
-------------- next part --------------
#!/bin/bash

set -e

# =========================================================================
# Configuration

BASE_PATH="./temp"
INPUT_FILE="$BASE_PATH/ffmpeg-10bit-test-input.avi"
OUTPUT_FILE01="$BASE_PATH/ffmpeg-10bit-test-output01.avi"
OUTPUT_FILE02="$BASE_PATH/ffmpeg-10bit-test-output02.avi"

FFMPEG_PATH="."
FFMPEG_BIN="$FFMPEG_PATH/build-linux/ffmpeg"
FFMPEG_BITEXACT_OPTS="-flags +bitexact -sws_flags +accurate_rnd+bitexact -fflags +bitexact -threads 1"

# =========================================================================
# Create Input File

mkdir -p "$BASE_PATH"

$FFMPEG_BIN \
  -lavfi "yuvtestsrc=size=720x576:rate=25,format=yuv422p10le" \
  -f avi -vcodec ffvhuff -g 1 \
  -t 1.0 -y "$INPUT_FILE"

# =========================================================================
# Create Output Files

$FFMPEG_BIN \
  $FFMPEG_BITEXACT_OPTS -i "$INPUT_FILE" \
  -f avi -map 0:v -vcodec v210 -g 1 -pix_fmt +yuv422p10le \
  $FFMPEG_BITEXACT_OPTS -y "$OUTPUT_FILE01"

$FFMPEG_BIN \
  $FFMPEG_BITEXACT_OPTS -i "$INPUT_FILE" \
  -f avi -map 0:v -vcodec ffv1 -g 1 -level 3 -pix_fmt +yuv422p10le \
  $FFMPEG_BITEXACT_OPTS -y "$OUTPUT_FILE02"

# =========================================================================
# Create Frame-MD5 Files

$FFMPEG_BIN \
  $FFMPEG_BITEXACT_OPTS -i "$OUTPUT_FILE01" \
  -f framemd5 -map 0:v -map_metadata -1 \
  $FFMPEG_BITEXACT_OPTS -y "$OUTPUT_FILE01.framemd5"

$FFMPEG_BIN \
  $FFMPEG_BITEXACT_OPTS -i "$OUTPUT_FILE02" \
  -f framemd5 -map 0:v -map_metadata -1 \
  $FFMPEG_BITEXACT_OPTS -y "$OUTPUT_FILE02.framemd5"

diff -q "$OUTPUT_FILE01.framemd5" "$OUTPUT_FILE02.framemd5" && result=$? || result=$?

if [ $result -eq 0 ]; then
  echo "=== TEST SUCCEEDED ===";
else
  echo "=== TEST FAILED ===";
fi


More information about the ffmpeg-user mailing list