Some years back, I was perturbed … nay … triggerred by a news report. Like an SJW, my blood pressure … to use the language of these fools … literally shot up. The title of the report read something like Fans of actress so-and-so are tired of seeing this hairstyle on her! What? Don't the jerks have nothing better to do? And, what insect of a journalist thought this was newsworthy? Sheesh!
I was reminded of this news report when I saw an online video today. It distracted me so much that I decided to change the colour of the top that the person was wearing. I did that using FFmpeg, of course. To protect the innocent, I shall not use the same video as I explain how I did it.
Use huesaturation filter to replace colours
In the video that I used for this blog post, the lone speaker (Oceana — pronounced O-Sheena) wears a blue sweater. Using the huesaturation filter, I was able to change to several different to any other colour I wanted to.
To change all blue pixels to purple during playback:
ffplay \
-vf "huesaturation=hue=150:saturation=0.5:colors=b:strength=20" \
Reading-Christian-Booktube-s-favourite-books.mp4
To make the colour changes permanent:
ffmpeg -i Reading-Christian-Booktube-s-favourite-books.mp4 \
-vf "huesaturation=hue=150:saturation=0.5:colors=b:strength=20" \
-c:v libx264 -crf 21 -preset medium -tune film -pix_fmt yuv420p -r 24 \
-c:a copy \
Reading-Christian-Booktube-s-favourite-books-color-replaced.mp4
The range for hue filter option is from -180 to 180. In this range, you can cover all colours. For different shades of the same colour, you will have to adjust the saturation option (from -1.0 to 1.0). In the colors option, specify which primary colour you want to change — all reds, all greens, all blues or some combination thereof. The -pix_fmt option ensures compatibility with most playback devices.

Animation demo
Video demos

For the next video (featuring a green vine snake, I wrote a script to randomly change the colors as a function of time.

Become an FFmpeg PRO by reading my book Quick Start Guide to FFmpeg.
- MORE INFO — http://www.vsubhash.in/ffmpeg-book.html
- BUY — https://books2read.com/ffmpeg (common link for all stores)
- FREE INTERNATIONAL SHIPPING -
https://www.apress.com/9781484287002
