pixop / video-compare

Split screen video comparison tool using FFmpeg and SDL2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Overlaying histograms on both videos

jonfryd opened this issue · comments

At times, I need to overlay the RGB or YUV color histogram of both videos onto the source to examine for saturated pixels and/or quantization. To facilitate this task, I've developed a compact bash script that presents a small histogram of the three color channels in the bottom left and right corners. It may prove helpful to other members of the community.

#!/bin/bash

# RGB formats: gbrp, gbrp9, gbrp10 - 256, 512, 1024 bins
# YUV formats: yuv444p, yuv444p9le, yuv444p10le - 256, 512, 1024 bins
PIX_FMT_L=gbrp
PIX_FMT_R=gbrp

HIST_OUT_FMT=yuva444p

DISPLAY_MODE=stack # stack, parade, overlay
LEVEL_HEIGHT=100 # 50-2048
LEVELS_MODE=linear # linear, logarithmic
ALPHA=0.75 # 0.0-1.0

video-compare -l "split=2[a][b],[b]format=$PIX_FMT_L,histogram=display_mode=$DISPLAY_MODE:colors_mode=coloronblack:level_height=$LEVEL_HEIGHT:levels_mode=$LEVELS_MODE:fgopacity=1:bgopacity=1,format=$HIST_OUT_FMT,colorchannelmixer=aa=$ALPHA[hh],[a][hh]overlay=20:main_h-overlay_h-50" \
              -r "split=2[a][b],[b]format=$PIX_FMT_R,histogram=display_mode=$DISPLAY_MODE:colors_mode=coloronblack:level_height=$LEVEL_HEIGHT:levels_mode=$LEVELS_MODE:fgopacity=1:bgopacity=1,format=$HIST_OUT_FMT,colorchannelmixer=aa=$ALPHA[hh],[a][hh]overlay=main_w-overlay_w-20:main_h-overlay_h-50" \
              "$@"

In the future, I may consider incorporating native histogram support into video-compare so that FFmpeg filters are not required. However, for now, I am content with this approach.

You are welcome to adapt this script into a Windows Batch file and share the outcome here.

A screen capture showcasing it in action:

histogram_overlay