Skip to content
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

Media Recording: Add Background Blur #12067

Merged
merged 40 commits into from
Sep 14, 2022

Conversation

merapi
Copy link
Contributor

@merapi merapi commented Aug 8, 2022

Summary

This version of Background Blur is based on the latest version of the new Trimming flow PR.
The Media Pipe object is very difficult to cooperate and it often throws errors while switching between no effect and blur effect. In this PR I managed to make it work consistently. The recording part is not yet merged into this version (two media recorders one used to get the camera feed, the second for canvas recording when the blur effect is active).

image

Edges are now smooth so it looks a lot better than the first version:
image

Relevant Technical Choices

To-do

User-facing changes

Testing Instructions

  • This is a non-user-facing change and requires no QA

This PR can be tested by following these steps:

Reviews

Does this PR have a security-related impact?

Does this PR change what data or activity we track or use?

Does this PR have a legal-related impact?

Checklist

  • This PR addresses an existing issue and I have linked this PR to it in ZenHub
  • I have tested this code to the best of my abilities
  • I have verified accessibility to the best of my abilities (docs)
  • I have verified i18n and l10n (translation, right-to-left layout) to the best of my abilities
  • This code is covered by automated tests (unit, integration, and/or e2e) to verify it works as intended (docs)
  • I have added documentation where necessary
  • I have added a matching Type: XYZ label to the PR

Fixes #11909
Fixes #12033
Fixes #12245
Fixes #12249
Fixes #12246

@merapi merapi added Type: Enhancement New feature or improvement of an existing feature Group: Media Pod: Prometheus labels Aug 8, 2022
@merapi merapi self-assigned this Aug 8, 2022
@googleforcreators-bot
Copy link
Collaborator

googleforcreators-bot commented Aug 8, 2022

Plugin builds for 5878aaa are ready 🛎️!

Copy link
Contributor

@barklund barklund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works really well, but it's hard to review with the mixed code from multiple PR's. Let's have @felipebochehin87 quickly QA #11988, so we can merge #12022 and rebase this PR.

packages/story-editor/package.json Show resolved Hide resolved
package-lock.json Outdated Show resolved Hide resolved
@barklund
Copy link
Contributor

barklund commented Aug 8, 2022

#12022 has been merged, so this can be updated to main to better reflect that actual changes.

@swissspidy swissspidy mentioned this pull request Aug 8, 2022
8 tasks
@merapi
Copy link
Contributor Author

merapi commented Aug 18, 2022

Summary of the latest updates:
You will see two useMediaRecorder instances in the code: mediaRecorder and canvasRecorder.
When all effects are disabled (default state) we will do the recording in the old way (mediaRecorder will be the currentRecorder) - this is more performant way than always redrawing the camera stream onto the canvas and recording the canvas (with and without effects) - so it will be as snappy as possible on slower devices when you don't use any effects.

I also fixed #12033

@merapi merapi requested review from barklund and miina August 18, 2022 12:33
Copy link
Contributor

@miina miina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Will continue the review on Monday, couldn't go through everything)

@@ -331,6 +340,7 @@ const useQuickActions = () => {
muteAudio: actions.muteAudio,
unMuteAudio: actions.unMuteAudio,
startTrim: actions.startTrim,
setVideoEffect: actions.setVideoEffect,
}));

const enableMediaRecordingTrimming = useFeature('recordingTrimming');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 thought:
Not related to this PR directly but should these actions be disabled during recording? Currently it seems that it's possible to click on it during recording which results in the recording just stopping. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, okay, I'm now trying again and seeing these are disabled generally. Unfortunately I don't know how to reproduce it but somehow I ended up (twice) in a situation where I could click on the Disable Background Blur quick-action while recording -> recording stopped -> when I opened the recorder again, I saw this with neither of the buttons (Pause/Stop) doing anything:
Screenshot 2022-08-19 at 13 36 25

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I tried again and the following seems to break it eventually:

  • Open the recorder
  • Enable background blur
  • Start recording
  • Wait for a couple of seconds -- when testing, the quick-actions became enabled when the blur option was turned on.
  • Now disable the blur while recording. And now the video stops recording.
  • Click X to close the recorder tool.

When I repeat the process a few times, the following occurs:

  • If the video stopped recording because of using quick-actions during recording, and then when opening the recorder tool from the Library again, it starts recording right away when opening.
  • After a few times of doing this, the video starts recording but doesn't really show the video and the Pause/Stop buttons don't do anything (as above on the screenshot).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it would be just a flag change (incorrect status/inputStatus/isReady), but it turned out that I was trying to fix something that was impossible to fix with the current version of the library. It was not possible to use the custom media recorder more than once per instance. Luckily, when I was about to go crazy I checked the library repo and saw this one-liner 🪄

Note to self: always check if you are using the latest version of the library.

@swissspidy swissspidy changed the title Background Blur based on early trim PR Media Recording: Add Background Blur Aug 29, 2022
@spacedmonkey
Copy link
Contributor

Noticed another weird issues with the settings dialog. See video.

Screen.Recording.2022-09-13.at.11.14.03.mov

@merapi
Copy link
Contributor Author

merapi commented Sep 13, 2022

Noticed another weird issues with the settings dialog. See video.

Screen.Recording.2022-09-13.at.11.14.03.mov

What browser is this? any errors in the console?

@spacedmonkey
Copy link
Contributor

What browser is this? any errors in the console?

Chrome 104. Nope.

@merapi
Copy link
Contributor Author

merapi commented Sep 14, 2022

Seeing slow down of image in safari.

That is expected. It will never match the native blur or get close to it, tho it looks better on my Macbook Air.

And other issues in firefox.

That is only happening on 2+ try in the same session, right? Probably fixed? PTAL

@spacedmonkey
Copy link
Contributor

Not seeing device list issue anymore.

@spacedmonkey
Copy link
Contributor

Safari I am seeing this error when I try active blur background.

Screenshot 2022-09-14 at 17 16 29
Screenshot 2022-09-14 at 17 15 57

@spacedmonkey
Copy link
Contributor

Not seeing firefox issues now. 🎉

@merapi
Copy link
Contributor Author

merapi commented Sep 14, 2022

Safari I am seeing this error when I try active blur background.

Yes, it's WASM and some of its memory issues. I added a try/catch there that's the best we can do.

@merapi merapi merged commit 4992f17 into main Sep 14, 2022
@merapi merapi deleted the try/11909-background-blur-early-trim-base branch September 14, 2022 16:28
@spacedmonkey
Copy link
Contributor

Yes, it's WASM and some of its memory issues. I added a try/catch there that's the best we can do.

More testing, I am seeing the slow version in safari. Blur background works but it is very slow in safari.

Screen.Recording.2022-09-14.at.17.28.05.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group: Media Type: Enhancement New feature or improvement of an existing feature
Projects
None yet
7 participants