carsonDB / frameflow

A both speedy and compatible video processing library for Web Browser, based on WebCodecs and FFmpeg (WebAssembly).
https://frameflow.netlify.app/
GNU Lesser General Public License v2.1
45 stars 3 forks source link

duration is always 0 for web recorded media #2

Open nick-delirium opened 3 weeks ago

nick-delirium commented 3 weeks ago
const video = await fflow.source(videoBlob());
console.log(video.duration, video.metadata.tracks);
// 0, then two streams, each has 0 as duration

which later becomes a problem:

const result = await video
      .trim({ start: 5, duration: 5 })
      .exportTo(Blob, { format: "webm" });

Will trim from 5th second to end of the video instead of next 5 seconds, ignoring duration because here it will be Math.min(5 + 0, 0 + 0)

Can you point to any synthetic solution for now on? Otherwise, library is fantastic, thank you.

additional details: I'm trying to trim webm video with vp9+opus codecs, its a basic browser tab recording done via mediaRecorder, then transported as base64 string into another part of the application and back to blob before being put into fflow.source

nick-delirium commented 3 weeks ago

Actually I'm pretty sure this is the same issue that's causing 0 duration mediaRecorder webms in Chrome browser. There are some libraries that fix it, that this just causes more issues with this library, although it parses duration correctly after fixing

image image

carsonDB commented 3 weeks ago

Yes, you are right. It's Chrome's problem. In this library, frameflow can directly receive stream of frames and encode to mp4 file. Like this example: https://github.com/carsonDB/frameflow/blob/main/examples/browser/codec.html#L51