0

To check the effects of additional compression on a video file, I found this useful ffmpeg trick:

ffmpeg -i orig.mkv -i compressed.mkv -filter_complex "blend=all_mode=difference" -c:v libx264 -crf 18 -c:a copy diff.mkv

By default, however, the difference between the two video streams is done in a YUV colorspace instead of an RGB colorspace. This results in a medium shade of green where there's no difference in the two video streams.

The recommendation I've found so far for RGB instead is to use format=gbrp... but I have no idea, syntactically speaking, where or how to apply that advice.

I'm also not sure if a lack of difference would then show up as black, rather than medium gray. I'd prefer gray so that there's room to go brighter or dimmer, rather than only showing positive differences and clipping negative differences as blacker-than-black.

Can someone show me what the command would look like with format=gbrp properly applied?

kshetline
  • 205
  • 2
  • 9

1 Answers1

1

With the help I got from Баяр Гончикжапов, I was able to go a little further and get this:

ffmpeg -i orig.mkv -i compressed.mkv -filter_complex "format=gbrp,blend=all_expr=(B-A)/2+128" -c:v libx264 -crf 18 -c:a copy -pix_fmt yuv420p diff.mkv

This turns out to be a really great way to visualize changes, one that I definitely prefer over the green YUV result. I'm not sure I can always depend on pixel values being in the 0-255 range (an assumption I'm making here), but for a sample I just tried, so far, so good.

Update:

A variant to show the full magnitude of the RGB difference, but clip the result if it's too big, rather than dividing by two to keep the result in range:

ffmpeg -i orig.mkv -i compressed.mkv -filter_complex "format=gbrp,blend=all_expr='clip(B-A+128,0,255)'" -c:v libx264 -crf 18 -c:a copy -pix_fmt yuv420p diff.mkv

kshetline
  • 205
  • 2
  • 9