[FFmpeg-user] Detecting blue frames.

Dave Rice dave at dericed.com
Sat Jan 24 00:59:32 CET 2015

Hi Alex,

> On Jan 23, 2015, at 10:23 AM, Alex Kink <alexkink at gmail.com> wrote:
> Hello all.
> Is there a way to detect blue screen (usually generated by analog videotape equipment) using ffmpeg. I know there is a way to detect black screen.
> Below is a sample of what I have in mind.
> https://www.youtube.com/watch?v=fC_bO-4uwFk

You could use the metadata output of the signalstats filter to get the average hue (HUEAVG), like this:

 ffprobe -f lavfi movie=AnalogVideoToBlueScreen5seconds-fC_bO-4uwFk.mp4,signalstats -show_entries frame_tags=lavfi.signalstats.HUEAVG -of flat

The HUEAVG value for a blue frame is 279, so finding frames where HUEAVG equals 279 +/- some margin would find frames are blue.

If looking for a specific saturation of blue you could use the average values of the chroma plans (UAVG and VAVG), which could be accessed like this:

ffprobe -f lavfi movie=AnalogVideoToBlueScreen5seconds-fC_bO-4uwFk.mp4,signalstats -show_entries frame_tags=lavfi.signalstats.UAVG,lavfi.signalstats.VAVG -of flat

The specific blue is your video is roughly UAVG=205 and VAVG=114, so finding frames close to those values would give you the blue frames you're looking for.

Another option could be using the geq filter with if statements which would replace U and V values with black if in those numerical ranges, then adding blackdetect next in the filterchain.

Dave Rice

More information about the ffmpeg-user mailing list