Vanilagy / webm-muxer

WebM multiplexer in pure TypeScript with support for WebCodecs API, video & audio.
https://vanilagy.github.io/webm-muxer/demo
MIT License
197 stars 12 forks source link

Variable frame rate #3

Closed KaliaJS closed 1 year ago

KaliaJS commented 1 year ago

Hello,

Before starting I would like to thank you for webm-muxer.

I wanted to know if it is normal that the framerate of your demo has a changing framerate between each file while in the source code it is well marked frameRate: 30 ?

In VLC it's written for both videos "30.000300" but in After Effects I have 29.042 fps for the first file and 30.512 fps for the second.

Is there a possibility to have a video file with a fixed framerate?

Vanilagy commented 1 year ago

Of course! Frame rate in WebM files is a weird concept, as it is not really enforced. The only thing that really matters is which timestamp each video frame has. And there's no limitation when it comes to that, so you could have videos with super wacky variable frame rate and it would still work. If you want a perfectly fixed frame rate, you need to make sure that each video chunk's timestamp is an integer multiple of 1000000/frameRate (the unit is microseconds). I think the code I wrote for the demo computes the timestamp based on the current time spent on the webpage which leads to slight variations in frame rate.

The frameRate: 30 thing in the constructor is merely metadata for the file, it has no impact on playback. It is also entirely optional.

If the not-quite-perfectly-fixed frame rate of my demo is too confusing, I might adjust it to be perfectly fixed. But yes, it's totally possible.