Extract Frames from Video C#

后端 未结 3 1634
暖寄归人
暖寄归人 2021-01-31 00:43

I\'m trying to make an app that use the camera to record a video and process the images of the video. Here is what I want. First, my app records a 10 second video with Torch. Se

3条回答
  •  后悔当初
    2021-01-31 01:09

    I ended up using MediaToolkit to solve a similar problem after having a ton of trouble with Accord.

    I needed to save an image for every second of a video:

    using (var engine = new Engine())
    {
        var mp4 = new MediaFile { Filename = mp4FilePath };
    
        engine.GetMetadata(mp4);
    
        var i = 0;
        while (i < mp4.Metadata.Duration.Seconds)
        {
            var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(i) };
            var outputFile = new MediaFile { Filename = string.Format("{0}\\image-{1}.jpeg", outputPath, i) };
            engine.GetThumbnail(mp4, outputFile, options);
            i++;
        }
    }
    

    Hope this helps someone some day.

提交回复
热议问题