Video texture to be reload from local data string?

Still time to wish a happy new year!
Displaying a mesh with a video texture read from an external file works perfectly well like in following “official” PG https://playground.babylonjs.com/#ZMCFYA#83 as in
var ANote0VideoVidTex = new BABYLON.VideoTexture("vidtex","textures/babylonjs.mp4", scene);

How would it be possible to save the video content in a local string, say myVideoStr ?
An then later, recreate the video texture with a call similar to
new BABYLON.VideoTexture("vidtex", myVideoStr, scene) ?

I am afraid everybody knows how to do that but me!
Lot of thanks 4 helping.

Hello Jean-Marie_Laborde,

I think if you want to save the video in a .json-file you can use serialize(). To recreate the video you should be able to Parse().

I would not recommend to read a big binary into a string. You would probably run out of ram pretty fast.
If you still need a string for some reasons you may use this answer as a base - Converting .mp4 link to BLOB in JavaScript - Stack Overflow
The problem with fetching the blob URL again is that this will create a full copy of the blob’s data, and so instead of having it only once in memory, you’ll have it twice. With big blobs this can blow your memory usage quite quickly.

2 Likes