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

MediaStream threshold is currently hardcoded #92

Open ggolda opened 2 years ago

ggolda commented 2 years ago

In current implementation of MediaStream, Threshold is being hardcoded and there is no way to override it: https://github.com/radek-k/FFMediaToolkit/blob/master/FFMediaToolkit/Decoding/MediaStream.cs#L23

Threshold = TimeSpan.FromSeconds(0.5).ToTimestamp(Info.TimeBase);

Because of that as I understand, I can not read from 60 fps video with a 30 fps framerate from my reader. I'm trying to call GetFrame with a delta time of 33ms, and GetFrame function from MediaStream ignores my timestamp and just returns a next frame.

As I understand, this threshold parameter should be equal to a frame rate of a video? E.g. for 60 fps video it should be 16.66, for 30 fps its 33.33 and etc.

Am I doing something wrong here?