musicblocks icon indicating copy to clipboard operation
musicblocks copied to clipboard

Save Mouse Artwork Animation (DRAFT)

Open AndreaGon opened this issue 4 years ago • 11 comments

This fixes #1673 part 1; It saves the artwork animation into WEBM file format.

Sample Video.zip

AndreaGon avatar Feb 29 '20 07:02 AndreaGon

This will be really great.

walterbender avatar Feb 29 '20 20:02 walterbender

Do we also need to save in mp4 (part 2 of #1673 )?

b18050 avatar Mar 01 '20 10:03 b18050

@b18050 Yes. Currently, it only saves the mouse animation (without audio).

AndreaGon avatar Mar 03 '20 07:03 AndreaGon

This draft is great.

sum2it avatar Mar 12 '20 20:03 sum2it

What is left to be done with this?

pikurasa avatar Apr 21 '20 23:04 pikurasa

@pikurasa It can only save the animation video, without the music. I thought of recording the music using the Recorder.js, then mux it together with the WEBM file, but according to another issue, the recorder breaks the synth. Thoughts?

AndreaGon avatar Apr 22 '20 03:04 AndreaGon

This is actually pretty cool I must admit, And, the code is fairly simple.

@walterbender @pikurasa This PR's been here for a while. Time to merge this?

I've better ideas about superimposing the music. But that won't happen the way this has been implemented.

Fixed the merge conflicts, and tried a simple project. nothing fancy ... works fine.

ezgif com-gif-maker

meganindya avatar Dec 01 '20 12:12 meganindya

One tiny issue: this won't record the last instruction's effect.

techincal reason: All our commands are dispatched as asynchronous events, which execute after the main queue. The instruction to stop recording executes after dispatching the last command's event, but it is part of the main queue. So, it executes before the event executes, i.e. the recording is stopped right after the event is dispatched and before the event is executed entirely.

Not really anything we can do about it without creating a mess.

meganindya avatar Dec 01 '20 12:12 meganindya

I suppose we could land this in this cycle. I was waiting for the audio. (Makes more sense for Turtle Blocks than Music Blocks w/o the audio.)

walterbender avatar Dec 01 '20 14:12 walterbender

Well, this recording uses HTMLCanvasElement's captureStream method, generating a MediaStream. This works directly on the canvas element.

Our .wav/.ogg audio download relies on MediaRecorder, which in turn depends on Tone.js's BaseContext.createMediaStreamDestination method.

Another thing to observe is that canvas capturing happens every time the project is played (via Logo.runLogoCommands). Audio recording happens when we decide to record audio. It might be possible to perform the superimposition, but then I'm not sure if it is worth the effort doing it this way at all. Plus, there are issues with codecs. I don't think it's easy to generate .mp4 by ourselves without using any library.

As a matter of fact, I'm opposed to using niche features of a platform without disconnected wrappers, which at the moment, we're doing extensively all throughout — one of the reasons why redesigning the architecture is a necessity.

I understand your motivation, but we probably don't have any easy way out at the moment.

meganindya avatar Dec 01 '20 15:12 meganindya

I think we could either land this as a Turtle Blocks only feature or keep it on hold as we had been doing.

walterbender avatar Dec 01 '20 21:12 walterbender

We landed something similar.

walterbender avatar Jan 13 '24 19:01 walterbender