Skip to content

Instantly share code, notes, and snippets.

@ascpixi
Last active November 29, 2021 02:05
Show Gist options
  • Save ascpixi/50aa8aa1d8a37897c5aaea9339113a0d to your computer and use it in GitHub Desktop.
Save ascpixi/50aa8aa1d8a37897c5aaea9339113a0d to your computer and use it in GitHub Desktop.
🎬 Converts VEGAS Pro markers to YouTube chapters you can put in descriptions
/*
* Markers to YouTube Chapters Script for VEGAS Pro
* by ascpixi (https://github.com/ascpixi)
*
* This script is licenced under the MIT Licence:
* Copyright 2020 ascpixi
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Usage:
* - Go to "Tools > Scripting > Run Script..."
* - Choose this file (MarkersToYouTubeChapters.cs)
* The output will appear in a seperate window with a copyable textbox.
*/
using System;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using ScriptPortal.Vegas;
public class EntryPoint {
public void FromVegas(Vegas vegas)
{
StringBuilder sb = new StringBuilder();
int chapterNo = 0;
foreach (var marker in vegas.Project.Markers) {
chapterNo++;
// YouTube requires a chapter beginning at 0:00
if(chapterNo == 1) {
if(marker.Position.Nanos > 10000000) {
sb.AppendLine("0:00 - Beginning");
}
}
long secs = marker.Position.Nanos / 10000000;
long mins = secs / 60;
long hours = mins / 60;
// Wrap seconds and minutes around (so that they don't go above 60)
long displaySecs = secs % 60;
long displayMins = mins % 60;
// Hours are not required for chapter entries
if (hours != 0)
sb.Append(hours + ":");
// D2 pads the number to two digits (1 becomes 01, etc.)
sb.Append(displayMins + ":" + displaySecs.ToString("D2") + " - ");
// YouTube requires a chapter name - if the marker has no name, resort to a generic one
if (string.IsNullOrWhiteSpace(marker.Label))
sb.AppendLine("Chapter " + chapterNo);
else
sb.AppendLine(marker.Label);
}
if (chapterNo == 0) sb.AppendLine("No chapters to process.");
// Create the output window
Form displayForm = new Form();
displayForm.Text = "VEGAS Pro";
displayForm.Size = new Size(400, 200);
displayForm.BackColor = Color.FromArgb(35, 35, 35);
displayForm.ForeColor = Color.White;
displayForm.ShowIcon = false;
displayForm.MaximizeBox = false;
displayForm.Margin = Padding.Empty;
// Main TextBox
RichTextBox tb = new RichTextBox();
tb.Text = sb.ToString();
tb.Dock = DockStyle.Fill; // Make the text box fill the entire window
tb.Multiline = true;
tb.ReadOnly = true;
tb.BackColor = displayForm.BackColor;
tb.ForeColor = displayForm.ForeColor;
tb.ScrollBars = RichTextBoxScrollBars.Vertical;
displayForm.Controls.Add(tb);
displayForm.ShowDialog();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment