【发布时间】:2023-04-10 12:16:01
【问题描述】:
我正在研究如何将视频分成四个片段。我见过很多解决方案和库。我在看这个库:
https://github.com/AydinAdn/MediaToolkit
这是分割视频的代码
var inputFile = new MediaFile {Filename = @"C:\Path\To_Video.flv"};
var outputFile = new MediaFile {Filename = @"C:\Path\To_Save_ExtractedVideo.flv"};
using (var engine = new Engine())
{
engine.GetMetadata(inputFile);
var options = new ConversionOptions();
// This example will create a 25 second video, starting from the
// 30th second of the original video.
//// First parameter requests the starting frame to cut the media from.
//// Second parameter requests how long to cut the video.
options.CutMedia(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(25));
engine.Convert(inputFile, outputFile, options);
}
代码只分割了一个片段。有没有办法把它分成四个片段?
亲切的问候
PS:解决方案必须是 C# 并且已经看过 Directshow 解决方案。
【问题讨论】:
-
也许这样做 4 次会改变起始秒数?
-
你的意思是我必须做 4 个 var options = new ConversionOptions(); ?我正在考虑这个问题,但这是一个好的解决方案吗?
-
我没用过这个库,但对我来说听起来不错,4
var options和 4engine.Convert我猜