radek-k / FFMediaToolkit

FFMediaToolkit is a cross-platform video decoder/encoder library for .NET that uses FFmpeg native libraries. It supports video frames extraction, reading stream metadata and creating videos from bitmaps in any format supported by FFmpeg.
MIT License
352 stars 56 forks source link

Adding frames at a variable frame rate #126

Open Miticoval opened 1 year ago

Miticoval commented 1 year ago

Hi!

I'm creating a video frame by frame, so far so good. But I'm trying to add frames not all at once, but time by time as soon as I receive them from the camera. However these frames arrive at a variable rate, so I'm trying to add the new frames using:

_mediaBuilder.Video.AddFrame(bitmapData, _totalTimeElapsed);

That kinda works, but when I playback the video it plays really really slow.

First question: is there a way to declare that the video is going to use a variable framerate? Second question: is it correct to set the parameter "duration" for every frame as the total time elapsed from the beginning of the recording?

Thank you very much!