123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System;
- using System.Diagnostics;
- using System.IO;
- namespace Vinno.IUS.Common.Media.FFmpeg
- {
- public static class FFmpegService
- {
- private static string _ffmpegPath = "ffmpeg";
- static FFmpegService()
- {
- var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Packages");
- var toolPath = "";
- if (Environment.OSVersion.Platform == PlatformID.Win32NT)
- {
- toolPath = Path.Combine(path, "ffmpeg.exe");
- }
- else if (Environment.OSVersion.Platform == PlatformID.Unix)
- {
- toolPath = Path.Combine(path, "ffmpeg");
- }
- _ffmpegPath = toolPath;
- }
- public static void StartFFmpeg(out Process process, string arguments, DataReceivedEventHandler errorDataReceived)
- {
- process = new Process
- {
- StartInfo =
- {
- FileName = _ffmpegPath,
- Arguments = arguments,
- UseShellExecute = false,
- Verb = "runas",
- CreateNoWindow = true,
- RedirectStandardError = true,
- RedirectStandardInput = true
- },
- EnableRaisingEvents = true
- };
- if (errorDataReceived != null)
- {
- process.ErrorDataReceived += errorDataReceived;
- }
- process.Start();
- process.BeginErrorReadLine();
- //process.ErrorDataReceived -= errorDataReceived;
- }
- }
- }
|