private void AddError(Exception e, Marker marker, Timecode position) { myErrors.Add(String.Format("Failed to add marker '{0}' at {1}: {2}", marker.Label, position.ToString(), e.Message)); }
private void tbPaddingAmount_TextChanged(object sender, EventArgs e) { Timecode tc = Timecode.FromString(tbPaddingAmount.Text, RulerFormat.Seconds); if (tc == null) return; lbPaddingPreview.Text = tc.ToString(); }
String TimeToString(Timecode time) { String[] decimalSeparators = new String[] { CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator }; Int64 nanosPerCentisecond = 100000; // first round the time to the nearest centisecond Int64 nanos = time.Nanos; Double tmp = ((Double)nanos / (Double)nanosPerCentisecond) + 0.5; nanos = (Int64)tmp * nanosPerCentisecond; time = Timecode.FromNanos(nanos); // {"hh:mm:ss", "ddd"} String[] rgTime = time.ToString(RulerFormat.Time).Split(decimalSeparators, StringSplitOptions.None); StringBuilder sbRes = new StringBuilder(); sbRes.Append(rgTime[0]); sbRes.Append(':'); int iCentiseconds = (int)Math.Round(Double.Parse(rgTime[1]) / 10.0); sbRes.Append(((iCentiseconds / 10) >> 0) % 10); sbRes.Append(((iCentiseconds / 1) >> 0) % 10); return(sbRes.ToString()); }
private void Update() { time += Time.deltaTime; running = !(time > stayThresholdSeconds); _dropFrameText.text = currentTimecode.dropFrame ? "Drop Frame" : "Non-Drop Frame"; label.text = $"{currentTimecode.ToString()}"; label.color = running ? runningColor : stayingColor; }
string GetSRTLine(int lineNumber, Timecode start, Timecode end, string text) { string line = string.Empty; line += lineNumber + Environment.NewLine; string fromMilliseconds = Timecode.FromMilliseconds(start.ToMilliseconds()).ToString(SRT_TIME_FORMAT); string toMilliseconds = end.ToString(SRT_TIME_FORMAT); line += fromMilliseconds + " --> " + toMilliseconds + Environment.NewLine; line += Regex.Replace(text, "\\[br\\]", Environment.NewLine); return(line); }
private void Update() { time += Time.deltaTime; timecodeDecoder.ParseAudioData(_selector.AudioDataSpan); CurrentTimecode = timecodeDecoder.LastTimecode; _dropFrameText.text = CurrentTimecode.dropFrame ? "Drop Frame" : "Non-Drop Frame"; label.text = $"{CurrentTimecode.ToString()}"; if (time > (1f / framerate)) { TargetFrameratedUpdate(CurrentTimecode); time = 0; } label.color = running ? runningColor : stayingColor; }
private void Update() { time += Time.deltaTime; _decoder.ParseAudioData(_selector.AudioDataSpan); CurrentTimecode = _decoder.LastTimecode; var drop = CurrentTimecode.dropFrame ? " (drop frame)" : " (non-drop frame)"; _label.text = $"{CurrentTimecode.ToString()}"; if (time > (1f / framerate)) { TargetFrameratedUpdate(CurrentTimecode); time = 0; } _label.color = running ? runningColor : stayingColor; }
private string CalculateDuration(VideoReel videoReel) { Timecode timeCode = Timecode.FromString("00:00:00:00", videoReel.VideoStandard.FrameRate().ToFrameRate()); foreach (var videoClip in videoReel.VideoClips) { if (timeCode != null) { timeCode = Timecode.Add(timeCode, Timecode.Subtract( Timecode.FromString(videoClip.EndTime, videoClip.VideoStandard.FrameRate().ToFrameRate()), Timecode.FromString(videoClip.StartTime, videoClip.VideoStandard.FrameRate().ToFrameRate()))); } else { timeCode = Timecode.Subtract( Timecode.FromString(videoClip.EndTime, videoClip.VideoStandard.FrameRate().ToFrameRate()), Timecode.FromString(videoClip.StartTime, videoClip.VideoStandard.FrameRate().ToFrameRate())); } } return(videoReel.TotalDuration = timeCode.ToString()); }
// perform the render. The Render method returns a member of the // RenderStatus enumeration. If it is anything other than OK, // exit the loops. This will throw an error message string if the // render does not complete successfully. RenderStatus DoRender(String filePath, RenderItem renderItem, Timecode start, Timecode length) { ValidateFilePath(filePath); // make sure the file does not already exist if (!OverwriteExistingFiles && File.Exists(filePath)) { throw new ApplicationException("File already exists: " + filePath); } // perform the render. The Render method returns // a member of the RenderStatus enumeration. If // it is anything other than OK, exit the loops. RenderStatus status = myVegas.Render(filePath, renderItem.Template, start, length); switch (status) { case RenderStatus.Complete: case RenderStatus.Canceled: break; case RenderStatus.Failed: default: StringBuilder msg = new StringBuilder("Render failed:\n"); msg.Append("\n file name: "); msg.Append(filePath); msg.Append("\n Renderer: "); msg.Append(renderItem.Renderer.FileTypeName); msg.Append("\n Template: "); msg.Append(renderItem.Template.Name); msg.Append("\n Start Time: "); msg.Append(start.ToString()); msg.Append("\n Length: "); msg.Append(length.ToString()); throw new ApplicationException(msg.ToString()); } return(status); }
// perform the render. The Render method returns a member of the // RenderStatus enumeration. If it is anything other than OK, // exit the loops. This will throw an error message string if the // render does not complete successfully. RenderStatus DoRender(String filePath, RenderItem renderItem, Timecode start, Timecode length) { ValidateFilePath(filePath); // make sure the file does not already exist if (!OverwriteExistingFiles && File.Exists(filePath)) { throw new ApplicationException("File already exists: " + filePath); } // perform the render. The Render method returns // a member of the RenderStatus enumeration. If // it is anything other than OK, exit the loops. RenderStatus status = myVegas.Render(filePath, renderItem.Template, start, length); switch (status) { case RenderStatus.Complete: case RenderStatus.Canceled: break; case RenderStatus.Failed: default: StringBuilder msg = new StringBuilder("Render failed:\n"); msg.Append("\n file name: "); msg.Append(filePath); msg.Append("\n Renderer: "); msg.Append(renderItem.Renderer.FileTypeName); msg.Append("\n Template: "); msg.Append(renderItem.Template.Name); msg.Append("\n Start Time: "); msg.Append(start.ToString()); msg.Append("\n Length: "); msg.Append(length.ToString()); throw new ApplicationException(msg.ToString()); } return status; }
void ExportchaptersToXML(String exportFile) { XmlDocument doc = null; try { doc = new XmlDocument(); XmlProcessingInstruction xmlPI = doc.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); doc.AppendChild(xmlPI); XmlElement root = doc.CreateElement("Selection"); root.SetAttribute("FrameRate", myVegas.Project.Video.FrameRate.ToString()); System.Text.Encoding myCharacterEncoding = System.Text.Encoding.UTF8; doc.AppendChild(root); XmlElement trackEventElem; int count = 0; foreach (Track track in myVegas.Project.Tracks) { if (track.IsValid()) { foreach (TrackEvent trackEvent in track.Events) { if (trackEvent.Selected && trackEvent.IsVideo()) { trackEventElem = doc.CreateElement("TrackEvent"); trackEventElem.SetAttribute("Track", track.Name); trackEventElem.SetAttribute("Name", trackEvent.Name); trackEventElem.SetAttribute("Start", trackEvent.Start.ToString()); trackEventElem.SetAttribute("Length", trackEvent.Length.ToString()); trackEventElem.SetAttribute("End", trackEvent.End.ToString()); trackEventElem.SetAttribute("PlaybackRate", trackEvent.PlaybackRate.ToString()); XmlElement takeElem = doc.CreateElement("ActiveTake"); string currentMediaPath = trackEvent.ActiveTake.MediaPath; Timecode takeOffset = trackEvent.ActiveTake.Offset; takeElem.SetAttribute("Name", trackEvent.ActiveTake.Name); takeElem.SetAttribute("MediaPath", currentMediaPath); takeElem.SetAttribute("Offset", takeOffset.ToString()); trackEventElem.AppendChild(takeElem); root.AppendChild(trackEventElem); count += 1; } } } } root.SetAttribute("Count", count.ToString()); XmlTextWriter writer = new XmlTextWriter(exportFile, myCharacterEncoding); writer.Formatting = Formatting.Indented; writer.Indentation = 2; writer.IndentChar = ' '; doc.WriteTo(writer); writer.Close(); } catch { doc = null; } finally { if (null != doc) { System.Windows.Forms.MessageBox.Show("Export successful. File name: " + exportFile, "Chapter File Export"); } } }
String TimecodeToString(Timecode timecode) { return(timecode.ToString(myTimecodeFormat)); }