示例#1
0
        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);
        }
示例#2
0
        /// <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);
        }
示例#3
0
        /// <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);
        }
示例#4
0
        /// <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);
        }