Skip to content

Instantly share code, notes, and snippets.

@s4y
Created November 28, 2020 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s4y/0dd09f6689571726d0f8b68dc7ca9e3b to your computer and use it in GitHub Desktop.
Save s4y/0dd09f6689571726d0f8b68dc7ca9e3b to your computer and use it in GitHub Desktop.
FFmpeg get hue from RGB

The following FFmpeg filter will populate the red channel of a video with the hue of the video:

geq=r='if(eq(st(3,max(max(st(0,r(X,Y)/255),st(1,g(X,Y)/255)),st(2,b(X,Y)/255))),ld(0)),(ld(1)-ld(2))/(ld(3)-min(ld(1),ld(2))),if(eq(ld(3),ld(1)),2+(ld(2)-ld(0))/(ld(3)-min(ld(0),ld(2))),4+(ld(0)-ld(1))/(ld(3)-min(ld(0),ld(1)))))*42*ld(3)'

You can make a grayscale video by appending the following:

 , geq=g='r(X,Y)':b='r(X,Y)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment