using FFMpegCore.Enums;
using FFMpegCore.Helpers;
using FFMpegCore;
using System.IO;
namespace VideoConcat.Common.Tools
{
internal class VideoCombine
{
///
/// 生成所有组合
///
public static void GenerateCombinations(List> videoLists, int index, List currentCombination, List> result)
{
if (index == videoLists.Count)
{
result.Add(new List(currentCombination));
return;
}
foreach (string video in videoLists[index])
{
currentCombination.Add(video);
GenerateCombinations(videoLists, index + 1, currentCombination, result);
currentCombination.RemoveAt(currentCombination.Count - 1);
}
}
///
/// 清理临时文件
///
public static void Cleanup(List pathList)
{
foreach (var path in pathList)
{
if (File.Exists(path))
{
File.Delete(path);
}
}
}
///
/// 将视频文件转换为ts格式
///
public static string ConvertVideos(string videoPath)
{
var video = FFProbe.Analyse(videoPath);
FFMpegHelper.ConversionSizeExceptionCheck(video);
string _tempPath = Path.GetDirectoryName(videoPath) ?? "";
//GlobalFFOptions.Current.TemporaryFilesFolder
var destinationPath = Path.Combine(_tempPath, $"{Path.GetFileNameWithoutExtension(videoPath)}{FileExtension.Ts}");
//Directory.CreateDirectory(GlobalFFOptions.Current.TemporaryFilesFolder);
FFMpeg.Convert(videoPath, destinationPath, VideoType.Ts);
return destinationPath;
}
}
}