private static bool ExecuteFFMpegExtraction(MediaSource source, string path, long position, string tempFile) { var info = new ProcessStartInfo(); info.Arguments = String.Format("-ss {0} -i \"{1}\" -vframes 1 -vf \"yadif,scale=ih*dar:ih\" -f image2 \"{2}\"", position, path, tempFile); info.FileName = Configuration.StreamingProfiles.FFMpegPath; info.CreateNoWindow = true; info.UseShellExecute = false; info.RedirectStandardError = Log.IsEnabled(LogLevel.Trace); info.RedirectStandardOutput = Log.IsEnabled(LogLevel.Trace); TranscoderProcess proc = new TranscoderProcess(); proc.StartInfo = info; if (source.NeedsImpersonation) { proc.StartAsUser(Configuration.Services.NetworkImpersonation.Domain, Configuration.Services.NetworkImpersonation.Username, Configuration.Services.NetworkImpersonation.GetPassword()); } else { proc.Start(); } if (Log.IsEnabled(LogLevel.Trace)) { Log.Trace("ExtractImage: executing path={0} arguments={1}", info.FileName, info.Arguments); StreamCopy.AsyncStreamRead(proc.StandardError, l => Log.Trace("ExtractImage: stderr: {0}", l)); StreamCopy.AsyncStreamRead(proc.StandardOutput, l => Log.Trace("ExtractImage: stdout: {0}", l)); } proc.WaitForExit(); if (!File.Exists(tempFile)) { Log.Warn("Failed to extract image from {0} with {1} {2}", source.GetDebugName(), info.FileName, info.Arguments); return(false); } return(true); }
public static void AsyncStreamCopy(Stream original, Stream destination, string logIdentifier, int bufferSize) { StreamCopy copy = new StreamCopy(original, destination, bufferSize, logIdentifier); copy.CopyStream(); }
public static void AsyncStreamCopy(Stream source, Stream destination, string logIdentifier, int bufferSize) { StreamCopy copy = new StreamCopy(source, destination, bufferSize, logIdentifier); copy.CopyStream(); }