-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Greenscreen background image #13
Greenscreen background image #13
Conversation
Deploy request for build-a-thing-video pending review. Review with commit 9f823a8 |
Thank you so very much for this @RascalTwo! This is a great contribution, and it's good to see you free up the main thread with a worker. However, when testing, I wasn't able to get the output from the canvas into the publisher - instead it looked like this: Any idea why this might be the case? |
I'm using Chromium 86 in Brave 1.15 😄 |
Has basic settings to adjust position and size of background image Pixel manipulation is done in worker
Decrease performance while increase browser compatability Fix clear button
Add transition to background preferences
5352faf
to
9f823a8
Compare
After testing, I'm quite confident it was due to the fact that I had disabled
Additionally, I've brought it up to date with the latest
|
Hey! I tried this but still couldn't get it to work. This time, I can't see anything except the overlay image, and my chroma min and max are sensible. This is still an excellent piece of work, and I'll mark it as valid for the sake of Hacktoberfest. |
If you want to jump on a call to try and debug this let me know. I'll close this for now unless you want to do any further work 💖 |
I'm glad the initial error was truly solved, wasn't able to be there live but I did watch your VOD.
As for the chroma-keying not working, it appears that's due to the rigidity/inaccuracy of the algorithm I choose, so I've swapped it out for a different one that I can get working on just about any greenscreen video - even yours, even at the low resolution I was able to scrape from the VOD. After seeing how much performance really drops in the VOD, I also decided to make performance a priority, so along with various micro optimizations, it's now much faster - probably as fast as I personally can make it without getting WebAssembly/WebGL involved. Just to be safe though, in case performance is still lackluster, I've added options to allow for customization of the output - turning down the output resolution allows for higher frame rates. Now I'm no Vue expert, so while I've got it all working, It's likely I've broken some Vue rules or missed some things that Vue offers to make certain things much easier, but hopefully not too many though. I personally follow these steps to get each background working:
UI ClarificationI've also attempted to make the UI clearer, so hopefully the options are more obvious, but just in case here's a quick rundown: BackgroundThe
Output
With all the inputs being instantly reactive thanks to Vue, changes are now visible instantly instead of having to wait for focus to leave the input (the change event), so it's now easier and quicker to fine tune all these settings. I appreciate the offer to jump into a call, and the time you've taken for this single issue, perhaps if these latest changes don't work as expected I'll take you up on that offer. |
If bug fixes or new features
You can only publish a raw video source, closes #5.
You can now publish a video source with colors chroma keyed and replaced with a background image.
The user can upload a image of their choice, and once uploaded, customize the X/Y position, width, and height of the image.
To assist with positioning, a
Overlay
option is provided to draw the image on top of the video.Additionally, the user may select a low and high colors as their chroma key color if they wish to use a non-green color.
No
In order to have better performance, the image manipulation is done in a Worker.
I attempted to make it reusable by exposing a
getUserStream
method, so the user can be given another chance to provide a video source by calling this method again.I couldn't come up with a simple way to directly return the native stream when no background image is in use, but have it replaceable with the canvas one when the background image is in use.
Therefore even when there is no background image, the video is still being passed through a canvas.
I avoided actual styling of the form aside from making it collapsible with the
Open
/Close
button.While
requestAnimationFrame()
is used, it's limited to the reported frame rate of the user input video.I had intended to pass the ImageData by reference to the Worker, but I ran out of time - doing this I imagine would further increase performance, with only modifications to sending/receiving portions of the code being required.
My attempt to use the implementation described here did not have positive results in what testing I did - the inability to use a Worker resulted in decreased performance, and this was before I was even able to implement all the existing customization features - you can see it here if you're interested.