Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlaying histograms on both videos #45

Open
jonfryd opened this issue Jul 12, 2023 · 1 comment
Open

Overlaying histograms on both videos #45

jonfryd opened this issue Jul 12, 2023 · 1 comment
Labels
contribution Useful contributions from others

Comments

@jonfryd
Copy link
Member

jonfryd commented Jul 12, 2023

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.

@jonfryd jonfryd added the contribution Useful contributions from others label Jul 12, 2023
@jonfryd jonfryd changed the title How to overlay the histogram of both videos How to overlay the histograms of both videos Jul 12, 2023
@jonfryd
Copy link
Member Author

jonfryd commented Jul 12, 2023

A screen capture showcasing it in action:

histogram_overlay

@jonfryd jonfryd changed the title How to overlay the histograms of both videos Overlaying histograms on both videos Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution Useful contributions from others
Projects
None yet
Development

No branches or pull requests

1 participant