FFmpeg, PHP - script to do Chroma Key (green screen) background removal in video file
$10-100 USD
In Progress
Posted about 3 years ago
$10-100 USD
Paid on delivery
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.
to get started please share us a ffmpeg keyed version of the file shared to you.
provide 2 videos keyed as transparent background and also as white background
ensure:
- professional keying
- no halos
- no phantom hairs
- no unnatural body contours
you do not need to export as frame by frame
run the follow command on your server and done NB "rember to set it for the color"
ffmpeg -i [login to view URL] -vf "chromakey=0x70de77:0.1:0.2" -c copy -c:v png [login to view URL]
if your video file is "H.264 " MP4 it will not support alpha =0 to transparent but then you can always do
ffmpeg -f lavfi -i color=c=black:s=606x1080
-i [login to view URL]
-filter_complex
"[1:v]chromakey=0x70de77:0.1:0.2[ckout];
[0:v][ckout]overlay[out]"
-map "[out]" [login to view URL]
if you need more help let me know.
Thanks
peter
$25 USD in 1 day
5.0 (46 reviews)
6.3
6.3
5 freelancers are bidding on average $85 USD for this job
Hello there
i hope you are doing well, for this problem i suggest you to use ffmpeg with php and i 'll prepare you a script to do it automatically
if you really want to do it please contact me asap
Kindly