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

TryGetFrame set Timeout #127

Open Bedrock99 opened 1 year ago

Bedrock99 commented 1 year ago

Hi,

i try to read Videos for making thumbnails to show in C#. Some of the Videos are broken. This Videos take multiple minutes to fail.

I would like to have the ability to set a Timeout in the TryGetFrame Function of the VideoStream object.

My Function to load the frames looks like this: `public Bitmap GetVideoFrameAtSecond(double s_) { if (MediaInfo == null) return null;

       try
        {
            if (MediaInfo.Video.TryGetFrame(TimeSpan.FromMilliseconds(s_ * 1000), out FFMediaToolkit.Graphics.ImageData imageData1))
            {
                return imageData1.ToBitmap();
            }
        }
        catch (Exception)
        {
            return null;
        }
        return null;
    }`

MediaInfo is a member Variable of the type MediaFile