dom-examples icon indicating copy to clipboard operation
dom-examples copied to clipboard

chroma key green screen video pre-requisites

Open inglesuniversal opened this issue 5 years ago • 3 comments

I tried adding a video of my own with green background and it does not turn transparent.

Do I need to follow certain guidelines?

Regards

inglesuniversal avatar Jan 09 '20 22:01 inglesuniversal

I have checked it, and the orginal version words in Chrome/Firefox. You do need to run it through a web server - file:// URLs won't work.

chrisdavidmills avatar Jan 10 '20 08:01 chrisdavidmills

Do you mean it has to be a file on the same server as the script, or that the file has to be on any server? I tried it with image and video o cloudinary public server and it didn't work. Also, is there an sdk or library I need to import?

MerlinOfCode avatar Dec 18 '21 22:12 MerlinOfCode

In other words, I think the issue has to do with the green color I applied to the source video which is equivalent to "lime" web color #00FF00 .... Do I have to generate my videos with a specific hex color for the chroma key effect to work?

Furthermore, my issue was not related to the location of the file (I guess), since I had it stored on the same path as the source code you have in your repository.

Best regards and Happy Holidays!

inglesuniversal avatar Dec 19 '21 19:12 inglesuniversal

It looks like the question is related to the chroma-keyring example.

caugner avatar Oct 12 '23 15:10 caugner

Because this issue is a few years old, I'm going to first try to provide definitive answers to the questions raised in the issue, and then close this issue. If anyone has further trouble with this example, please re-open the issue.

@TheWizardofWikacy asks:

Do you mean it has to be a file on the same server as the script, or that the video file has to be on any server?

The video file does not necessarily need to be on the same server as the script, but the file does need to be accessible by the script.

Because file:// URLs won't work with this example due to security limitations, you can follow this guide on MDN to learn how to set up a local testing server: How do you set up a local testing server?

Also, is there an sdk or library I need to import? No, this example does not require importing any external SDKs or libraries.

@inglesuniversal asks:

Do I have to generate my videos with a specific hex color for the chroma key effect to work?

The example's source contains this code:

        if (g > 100 && r > 100 && b < 43)
          frame.data[i * 4 + 3] = 0;

This information contains the chroma key constraints: If the pixel's "green" channel is above 100/255, the pixel's "red" value is above 100/255, and the pixel's "blue" value is below 43, that pixel will be replaced. You can modify this code to suit your chroma keyed video's needs, or modify your video to fit these existing constraints.

zfox23 avatar Nov 13 '23 16:11 zfox23