core icon indicating copy to clipboard operation
core copied to clipboard

VideoClip toJSON does not include source filename and cannot recreate the clip

Open arose26 opened this issue 1 year ago • 3 comments

To recreate:

const video = await VideoSource.from('/assets/demo.mp4');
const clip0 = await new VideoClip(video)
console.log(clip0.toJSON())

This gives back all the features of clip (start, stop, translate, anchor, etc) but doesn't hold the video filename, thus cannot be used to recreate the clip. For example, clip0.copy(), which internally uses toJSON and fromJSON, results in a clip that doesn't play. I believe this to be a missing feature in the code.

arose26 avatar Oct 30 '24 10:10 arose26

toJSON is already recursive, so it should work such that clip.toJSON internally calls clip.source.toJSON, which is in the code @ serializer.ts line 13:

		properties.forEach(({ propertyKey, serializer }: any) => {
			const value = (this as any)[propertyKey];
			if (serializer && value instanceof serializer) {
				obj[propertyKey] = value.toJSON();
			} else {
				obj[propertyKey] = value;
			}
		});

But the problem is that clip.source is not included in clip._serializableProperties and so is skipped over. The solve would be to make VideoSource a serializable property.

arose26 avatar Oct 31 '24 11:10 arose26

It's not implemented yet because we don't officially support persisting compositions just yet. Though the architecture is built in a way that allows for this feature. Will tackle the ability to serialize/deserialize the composition soon.

k9p5 avatar Oct 31 '24 19:10 k9p5

That makes sense! Thank you for the response

arose26 avatar Oct 31 '24 19:10 arose26