FFmpeg, PHP - script to do Chroma Key (green screen) background removal in video file


A user has uploaded a video to my server. The video content shows a person in the foreground, and a green background.

I need a script that will remove the green background, and output a new video file with a transparent background.

The script must return the file path to the output video, so I can use that file in other scripts on the server.

Possibly, you will need to use FFmpeg to export each frame in the video as an image, then compare each pixel in the image with the color green. If green, then set the pixel to transparent. After analysing every frame, join all the frames back together and save as a video file.

FFmpeg documentation says you will also need to split the audio and visual channels first, before you work on the pixel colors. Then recombine the audio and video at the end.

Allow some tolerance when checking the pixel color. For example, instead of an exact match at rgb values 0,128,0 (green), allow some variation so that if the pixel is dark green or light green it is still made transparent. A way to do this might be to use a distance formula in 3D color space.

Skills: PHP

See more: ffmpeg chroma key, ffmpeg chroma key green, ffmpeg green screen video, php chroma key, remove background ffmpeg, php video background, chroma key removal script, ffmpeg video color key, remove green background video ffmpeg, remove green background ffmpeg, to do video, php save as, ffmpeg-php example, ffmpeg php example, 3d export, work to do, video file, transparent background, the green, path to, key video, it green, image removal, image background removal, green

Project ID: #4331971

1 freelancer is bidding on average $150 for this job


I can do it for you. I make some site like that. Thank you.

$150 AUD in 2 days
(1 Review)