Saving animations to video #7187
Replies: 5 comments 2 replies
-
Can the animation of TEXT be saved in Video also? While have taken plain Text to create and animate A help will be great appreciated. |
Beta Was this translation helpful? Give feedback.
-
@i-prikot this is amazing stuff. |
Beta Was this translation helpful? Give feedback.
-
very awesome! this is what im looking for, but even if how many times i work around to make it work with animated text, i cant make it working. would you mind share how do you use that with animated text. thanks! |
Beta Was this translation helpful? Give feedback.
-
Hello @i-prikot. I am relatively new to fabric.js and have a smiliar issue. I have multiple images on a canvas and trying to save them in a single pdf file. I tried to use jspdf from cdn for my problem. When there is a single image it works fine but when there are multiple images on the canvas it throws an error (canvas is tainted). Can you please help me with my problem. Your help would be much appreciated. |
Beta Was this translation helpful? Give feedback.
-
hey @i-prikot, thanks for this example. But i am wondering for me the video length is shorter than the real video. The example says in its properties that the video is 0 seconds. Opening it with a video player is giving me a scroll bar of 0-1 seconds and i can not scroll through the whole video only the first second. If i play the video it will show the full 2 seconds of the video. Any idea why this happens i used your example container from your post. |
Beta Was this translation helpful? Give feedback.
-
https://jsfiddle.net/i_prikot/o2zmtkfq/
Saving animation to video file using
Promise
,MediaRecorder
andStaticCanvas
. Onfabric.StaticCanvas
transfer the objects from thefabric.Canvas
and use the canvascaptureStream()
to capture video content canvas in real time.The animation start method must be async. It's easy to do this with a
Promise
and callback functiononComplete
fromfabric.Object.animate(property, value)
. We need this so that after the animation has played, we stop recording the video.The
MediaRecorder.ondataavailable
event handler handles the dataavailable event, letting you run code in response toBlob
data being made available for use. We just have to collect all the parts of theBlob
that theMediaRecorder
will return and save it to a file.Demo
ice_video_20210706-003857.mp4
Final video
sample.mp4
http://fabricjs.com/fabric-intro-part-2#animation
https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/captureStream
https://developer.mozilla.org/en-US/docs/Web/API/Blob
Beta Was this translation helpful? Give feedback.
All reactions