public async Task ExecuteAsync(FFmpegTask ffmpegTask, FFmpegEnviroment enviroment, CancellationToken cancellationToken = default) { var startInfo = new ProcessStartInfo { // -y overwrite output files Arguments = "-y " + ffmpegTask.GetCommandString(), FileName = enviroment.FFmpegPath, CreateNoWindow = true, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden }; await ExecuteAsync(startInfo, ffmpegTask, cancellationToken); }
/// <summary> /// start to convert file /// </summary> /// <param name="task"></param> /// <param name="outputFile"></param> /// <returns></returns> public static async Task <FileInfo> ConvertAsync(this FFmpegConvertTask task, string outputFile, FFmpegEnviroment enviroment, CancellationToken cancellationToken = default) { task.AppendCommand($" \"{outputFile}\" "); var process = new FFmpegProcess(); await process.ExecuteAsync(task, enviroment, cancellationToken : cancellationToken); task.OutputFile = new FileInfo(outputFile); return(task.OutputFile); }
/// <summary> /// start to get thumbnail /// </summary> /// <param name="task"></param> /// <param name="outputFile"></param> /// <returns></returns> public static async Task <FileInfo> GetThumbnailAsync(this FFmpegThumbnailTask task, string outputFile, FFmpegEnviroment enviroment, CancellationToken cancellationToken = default) { task.OutputFile = new FileInfo(outputFile); task.AppendCommand(CultureInfo.InvariantCulture, " -ss {0} ", TimeSpan.FromSeconds(0)); task.AppendCommand(" -vframes {0} ", 1); task.AppendCommand($" \"{outputFile}\" "); var process = new FFmpegProcess(); await process.ExecuteAsync(task, enviroment, cancellationToken : cancellationToken); return(task.OutputFile); }
/// <summary> /// start to get meta data /// </summary> /// <param name="task"></param> /// <returns></returns> public static async Task <MetaData> GetMetadataAsync(this FFmpegMetadataTask task, FFmpegEnviroment enviroment, CancellationToken cancellationToken = default) { task.AppendCommand(" -f ffmetadata - "); var process = new FFmpegProcess(); await process.ExecuteAsync(task, enviroment, cancellationToken : cancellationToken); return(task.MetaData); }