public static ExecuteAndReturnOutput ( string command, string arguments ) : string | ||
command | string | |
arguments | string | |
Résultat | string |
/// <summary> /// Opens from file. /// </summary> /// <param name='fileName'> /// File name. /// </param> public bool OpenFromFile(string fileName) { try { if (!File.Exists(fileName)) { return(false); } FileName = fileName; var fi = new System.IO.FileInfo(fileName); FileSize = fi.Length; Tracks.Clear(); TargetContainer = MediaInfoBase.DetectContainerByExt(fileName); var mediaInfoXML = SupportMethods.ExecuteAndReturnOutput(MediaConvertGUIConfiguration.MediaInfoPath, "-f --Output=XML \"" + fileName + "\""); RawMediaInfoOutput = mediaInfoXML; var xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(mediaInfoXML); var nodes = xmlDoc.SelectNodes("Mediainfo/File/track"); foreach (XmlNode node in nodes) { var track = new TrackInfo(); track.ParseFromXmlNode(node); Tracks.Add(track); } return(true); } catch (Exception ex) { Console.WriteLine("Error:" + ex.ToString()); return(false); } }
public static string MakeFFMpegScreenShot(MediaInfo sourceMovie, int secondsDelay = 0) { if (sourceMovie.FirstVideoTrack != null && File.Exists(sourceMovie.FileName)) { var ffmpegCommandArgs = String.Empty; var timeSpan = TimeSpan.FromSeconds(secondsDelay); //var timeAsStrig = timeSpan.ToString("hh:mm:ss"); var timeAsString = string.Format("{0}:{1}", timeSpan.Minutes.ToString().PadLeft(2, '0'), timeSpan.Seconds.ToString().PadLeft(2, '0')); var picFileName = sourceMovie.FileName + ".jpg"; var counter = 0; while (File.Exists(picFileName)) { counter++; picFileName = sourceMovie.FileName + "." + counter.ToString().PadLeft(2, '0') + ".jpg"; } // https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video // ffmpeg -i input.flv -ss 00:00:14.435 -f image2 -vframes 1 out.png ffmpegCommandArgs = " -i {filename} -ss {time} -f image2 -vframes 1 {pic}"; ffmpegCommandArgs = ffmpegCommandArgs.Replace("{filename}", "\"" + sourceMovie.FileName + "\""); ffmpegCommandArgs = ffmpegCommandArgs.Replace("{time}", timeAsString); ffmpegCommandArgs = ffmpegCommandArgs.Replace("{pic}", "\"" + picFileName + "\""); SupportMethods.ExecuteAndReturnOutput(MediaConvertGUIConfiguration.FFMpegPath, ffmpegCommandArgs); return(picFileName); } return(null); }