/// <summary> /// Gets the last time from convert log file in seconds /// Parsing text "time=00:22:25.05" to 1345 (22*60++25+0.05) s /// </summary> /// <returns> /// The last frame time convert log file (int). /// If value not found, returns -1 /// </returns> /// <param name='outputFileName'> /// log file name. /// </param> public static int GetLastTimeFromConvertLogFile(string outputFileName) { var lastTime = -1; if (File.Exists(outputFileName)) { using (var fs = new FileStream(outputFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (var sr = new StreamReader(fs)) { string line; while ((line = sr.ReadLine()) != null) { if (line != null && line.Contains("time=")) { var pos = line.IndexOf("time="); if (line.Length > pos + 5 + 8) { var lastTimeAsString = line.Substring(pos + 5, 8).Trim(); var hms = lastTimeAsString.Split(':'); if (hms.Length == 3 && SupportMethods.IsNumeric(hms [0]) && SupportMethods.IsNumeric(hms [1]) && SupportMethods.IsNumeric(hms [2])) { lastTime = Convert.ToInt32(hms[0]) * 3600 + Convert.ToInt32(hms[1]) * 60 + Convert.ToInt32(hms[2]); // ignoring ms } } } } } } } return(lastTime); }
/// <summary> /// Gets the last frame from convert log file. /// Parsing text "frame=15" to 15 /// </summary> /// <returns> /// The last frame from convert log file (int). /// If value not found, returns -1 /// </returns> /// <param name='_outputFileName'> /// _output file name. /// </param> public static int GetLastFrameFromConvertLogFile(string outputFileName) { var lastFrame = -1; if (File.Exists(outputFileName)) { using (var fs = new FileStream(outputFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (var sr = new StreamReader(fs)) { string line; while ((line = sr.ReadLine()) != null) { if (line != null && line.Length > 11 && line.StartsWith("frame=")) { var lastFrameAsString = line.Substring(6, 5).Trim(); if (SupportMethods.IsNumeric(lastFrameAsString)) { lastFrame = Convert.ToInt32(lastFrameAsString); } } } } } } return(lastFrame); }
public static decimal ParseDecimalValueFromValue(string value, Dictionary <decimal, string> dict) { var res = 0m; if (SupportMethods.IsNumeric(value)) { res = SupportMethods.ToDecimal(value); } else { foreach (var kvp in dict) { if (kvp.Value == value) { res = kvp.Key; } } } return(res); }
protected void OnEntryWidthChanged(object sender, EventArgs e) { if (checkKeep.Active && MovieInfo.FirstVideoTrack != null && SupportMethods.IsNumeric(entryWidth.Text)) { if (_eventLock.Lock()) { var width = SupportMethods.ToDecimal(entryWidth.Text); var aspectRatio = MovieInfo.FirstVideoTrack.AspectAsNumber; if (aspectRatio != -1) { entryHeight.Text = Convert.ToInt32(width / aspectRatio).ToString(); } _eventLock.Unlock(); } } OnAnyValueChanged(); }
public void ParseFromXmlNode(XmlNode node) { foreach (XmlNode subNode in node.ChildNodes) { if (subNode.Name == "Overall_bit_rate" && (SupportMethods.IsNumeric(subNode.InnerText))) { Bitrate = SupportMethods.ToDecimal(subNode.InnerText); } if (subNode.Name == "Frame_rate" && (SupportMethods.IsNumeric(subNode.InnerText))) { FrameRate = SupportMethods.ToDecimal(subNode.InnerText); } if (subNode.Name == "Sampling_rate" && (SupportMethods.IsNumeric(subNode.InnerText))) { SamplingRateHz = SupportMethods.ToDecimal(subNode.InnerText); } if (subNode.Name == "Bit_rate" && (SupportMethods.IsNumeric(subNode.InnerText))) { Bitrate = decimal.Parse(subNode.InnerText); } if (subNode.Name == "Stream_size" && (SupportMethods.IsNumeric(subNode.InnerText))) { StreamSize = long.Parse(subNode.InnerText); } if (subNode.Name == "Channel_s_" && (SupportMethods.IsNumeric(subNode.InnerText))) { Channels = Int32.Parse(subNode.InnerText); } if (subNode.Name == "Channel_count" && (SupportMethods.IsNumeric(subNode.InnerText))) { Channels = Int32.Parse(subNode.InnerText); } if (subNode.Name == "Pixel_aspect_ratio" && (SupportMethods.IsNumeric(subNode.InnerText))) { PixelAspect = SupportMethods.ToDecimal(subNode.InnerText); } if (subNode.Name == "Width" && (SupportMethods.IsInt(subNode.InnerText))) { Width = Int32.Parse(subNode.InnerText); } if (subNode.Name == "Height" && (SupportMethods.IsInt(subNode.InnerText))) { Height = Int32.Parse(subNode.InnerText); } if (subNode.Name == "Display_aspect_ratio" && (subNode.InnerText.Contains(":"))) { Aspect = subNode.InnerText; } if (subNode.Name == "Codec") { Codec = subNode.InnerText; } if (subNode.Name == "Rotation" && (SupportMethods.IsNumeric(subNode.InnerText))) { decimal angle = 0; var separator = System.Globalization.CultureInfo.CurrentUICulture.NumberFormat.NumberDecimalSeparator; var rotationAsString = subNode.InnerText.Replace(".", separator).Replace(",", separator); if (Decimal.TryParse(rotationAsString, out angle)) { RotatationAngle = angle; } } if (subNode.Name == "Duration" && (subNode.InnerText.Contains(":"))) { Duration = subNode.InnerText; } if (subNode.Name == "Duration" && (SupportMethods.IsNumeric(subNode.InnerText))) { DurationMS = SupportMethods.ToDecimal(subNode.InnerText); } } TrackType = node.Attributes.GetNamedItem("type").Value; }
private void OnAnyValueChanged() { if (Editable && MovieInfo != null && MovieInfo.FirstVideoTrack != null) { if (_eventLock.Lock()) { var m = MovieInfo.FirstVideoTrack; // reactivating disabled? if (chBoxResolution.Active && !MovieInfo.EditResolution) { entryWidth.Text = m.Width.ToString(); entryHeight.Text = m.Height.ToString(); } if (chBoxBitRate.Active && !MovieInfo.EditBitRate) { comboBitRate.Entry.Text = (m.BitrateKbps).ToString(); } if (chBoxAspect.Active && !MovieInfo.EditAspect) { comboAspect.Entry.Text = m.Aspect; } if (chBoxFrameRate.Active && !MovieInfo.EditFrameRate) { comboFrameRate.Entry.Text = m.FrameRate.ToString(); } MovieInfo.EditResolution = chBoxResolution.Active; MovieInfo.EditAspect = chBoxAspect.Active; MovieInfo.EditBitRate = chBoxBitRate.Active; MovieInfo.EditFrameRate = chBoxFrameRate.Active; if (chBoxBitRate.Active) { var bitRateTypedValue = SupportMethods.ParseDecimalValueFromValue(comboBitRate.ActiveText, MediaConvertGUIConfiguration.DefaultVideoBitRates); m.Bitrate = bitRateTypedValue * 1000; } if (chBoxResolution.Active) { if (SupportMethods.IsNumeric(entryWidth.Text)) { m.Width = Convert.ToInt32(entryWidth.Text); } if (SupportMethods.IsNumeric(entryHeight.Text)) { m.Height = Convert.ToInt32(entryHeight.Text); } } if (chBoxFrameRate.Active) { if (SupportMethods.IsNumeric(comboFrameRate.ActiveText)) { m.FrameRate = SupportMethods.ToDecimal(comboFrameRate.ActiveText); } } if (chBoxAspect.Active) { m.Aspect = comboAspect.ActiveText; } if (chBoxRotation.Active) { if (SupportMethods.IsNumeric(comboRotation.ActiveText)) { m.RotatationAngle = SupportMethods.ToDecimal(comboRotation.ActiveText); } } MovieInfo.EditRotation = chBoxRotation.Active; MovieInfo.AutoRotate = checkAutorotate.Active; if (checkAutorotate.Active) { // reseting Rotation angle to 0 m.RotatationAngle = 0; } MovieInfo.TargetVideoCodec = MediaConvertGUIConfiguration.GetVideoCodecByName(comboCodec.ActiveText); comboCodec.TooltipText = MovieInfo.TargetVideoCodec.Title; _eventLock.Unlock(); Fill(); } } }