Hi all,
This has been prompted by this discussion in the video forum.
I am trying to write a script to export a Womble MPEG Video Wizard Trim List (.tls) file from a Vegas timeline that contains a single track of HDV .m2t files. The files have been trimmed but any effects have been removed. The purpose is to archive the best part of the trimmed events as .m2t files using Womble's smart rendering capability (no re-rendering of the bulk of the file), without making the cuts a 2nd time manually.
A typical Womble MPEG Video Wizard Trim List (.tls) file is pretty simple and looks like this:
Note that my slightly strange input filenames are like they are so that they play nice with my Sclive / Gearshift method.
I have made a half-baked start at this by modifying the "Export EDL.js" script that is bundled with Vegas in the scripts folder:
To anyone who knows what they're doing, it will be obvious that I don't know what I'm doing. Needless to say the script doesn't run yet. But I'm hoping it might be fairly straightforward for someone to knock into shape or at least give me some pointers???
Any help anyone can give would be hugely appreciated.
A 30-day trial of Womble MPEG Video Wizard is available at www.womble.com.
Thanks! Nick
This has been prompted by this discussion in the video forum.
I am trying to write a script to export a Womble MPEG Video Wizard Trim List (.tls) file from a Vegas timeline that contains a single track of HDV .m2t files. The files have been trimmed but any effects have been removed. The purpose is to archive the best part of the trimmed events as .m2t files using Womble's smart rendering capability (no re-rendering of the bulk of the file), without making the cuts a 2nd time manually.
A typical Womble MPEG Video Wizard Trim List (.tls) file is pretty simple and looks like this:
[TRIM LIST HEADER INFO]
List Count: 4
[LIST ITEM 0]
Checked: 1
Selected: 0
InputFile: G:\capture\'20061101 15.54.19.m2t
IsFrameFormat: 0
FrameRate: 25.000000
Start: 1.520000
End: 2.640000
OutputFile: E:\trimmed\'20061101 15.54.19trimmed.m2t
[LIST ITEM 1]
Checked: 1
Selected: 0
InputFile: G:\capture\'20061101 15.55.20.m2t
IsFrameFormat: 0
FrameRate: 25.000000
Start: 1.200000
End: 3.840000
OutputFile: E:\trimmed\'20061101 15.55.20trimmed.m2t
[LIST ITEM 2]
Checked: 1
Selected: 0
InputFile: G:\capture\'20061101 15.55.57.m2t
IsFrameFormat: 0
FrameRate: 25.000000
Start: 1.720000
End: 4.520000
OutputFile: E:\trimmed\'20061101 15.55.57trimmed.m2t
[LIST ITEM 3]
Checked: 1
Selected: 0
InputFile: G:\capture\'20061104 11.37.27.m2t
IsFrameFormat: 0
FrameRate: 25.000000
Start: 22.120000
End: 54.680000
OutputFile: E:\trimmed\'20061104 11.37.27trimmed.m2t
Note that my slightly strange input filenames are like they are so that they play nice with my Sclive / Gearshift method.
I have made a half-baked start at this by modifying the "Export EDL.js" script that is bundled with Vegas in the scripts folder:
/**
* Sample script that exports the top-most video track as a
* Womble MPEG Video Wizard trim list file (.tls).
*
*
* Limitations:
* - supports only 1 video track.
* - supports cuts and cross fades (dissolves) only.
*
* By Nick Hope, based on the Export EDL.js script included with Vegas 7
*
* Revision Date: Dec. 05, 2006
**/
import System;
import System.Text;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;
var writer : StreamWriter = null;
try {
var noTime = new Timecode();
// find selected tracks
var videoTrack = FindTopTrackOfType(MediaType.Video);
if (null == videoTrack) {
throw "no tracks to export";
}
var projPath = Vegas.Project.FilePath;
var outputFilename = Path.ChangeExtension(projPath, ".tls");
var outputFilename = ShowSaveFileDialog("tls Files (*.tls)|*.tls", "Save tls", title);
if (null != outputFilename) {
writer = new StreamWriter(outputFilename, false, System.Text.Encoding.UTF8, 512);
// write the header stuff
writer.WriteLine("[TRIM LIST HEADER INFO]");
// don't know how to get the total number of events in the next line
writer.Writeline(" List Count:" + ???);
var editCount : int = 1;
// do video track
if (null != videoTrack) {
editCount = ExportTrack(new Enumerator(videoTrack.Events), editCount, null);
}
writer.Close();
}
} catch (e) {
if (null != writer)
writer.Close();
MessageBox.Show(e);
}
function ExportTrack(events, editIndex, prevMediaPath) {
if (events.atEnd()) return editIndex;
var currentEvent = events.item();
// look ahead to see if we need to do a dissolve.
var nextEvent = null;
events.moveNext();
if (!events.atEnd()) {
nextEvent = events.item();
}
// compute parameters for current event
var activeTake = currentEvent.ActiveTake;
var mediaPath = activeTake.MediaPath;
var extFileName = Path.GetFileName(mediaPath);
var baseFileName = Path.GetFileNameWithoutExtension(extFileName);
var inputFileName = ((baseFilename) + ".m2t");
var sourceOut = activeTake.Offset + currentEvent.Length;
var outputFolder = (E:\trimmed\); // would be great to make this inputtable when script is run
var outputFile = ((outputFolder) + (baseFileName) + "trimmed.m2t");
// write information for each edited event
writer.WriteLine("[LIST ITEM ", editIndex, "]");
writer.WriteLine(" Checked: 1");
writer.WriteLine(" Selected: 0");
writer.WriteLine(" InputFile: " (inputFileName);
writer.WriteLine(" IsFrameFormat: 0");
writer.WriteLine(" FrameRate: 25.000000");
writer.WriteLine(" Start: " + (activeTake.Offset);
writer.WriteLine(" End: " + (sourceOut);
writer.WriteLine(" OutputFile: " + (outputFile);
return ExportTrack(events, editIndex+1, null);
}
function FindTopTrackOfType(mediaType) : Track {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
if (track.MediaType == mediaType) {
return track;
}
trackEnum.moveNext();
}
return null;
}
// an example filter: "PNG File (*.png)|*.png|JPEG File (*.jpg)|*.jpg"
function ShowSaveFileDialog(filter, title, defaultFilename) {
var saveFileDialog = new SaveFileDialog();
if (null == filter) {
filter = "All Files (*.*)|*.*";
}
saveFileDialog.Filter = filter;
if (null != title)
saveFileDialog.Title = title;
saveFileDialog.CheckPathExists = true;
saveFileDialog.AddExtension = true;
if (null != defaultFilename) {
var initialDir = Path.GetDirectoryName(defaultFilename);
if (Directory.Exists(initialDir)) {
saveFileDialog.InitialDirectory = initialDir;
}
saveFileDialog.DefaultExt = Path.GetExtension(defaultFilename);
saveFileDialog.FileName = Path.GetFileName(defaultFilename);
}
if (System.Windows.Forms.DialogResult.OK == saveFileDialog.ShowDialog()) {
return Path.GetFullPath(saveFileDialog.FileName);
} else {
return null;
}
}
To anyone who knows what they're doing, it will be obvious that I don't know what I'm doing. Needless to say the script doesn't run yet. But I'm hoping it might be fairly straightforward for someone to knock into shape or at least give me some pointers???
Any help anyone can give would be hugely appreciated.
A 30-day trial of Womble MPEG Video Wizard is available at www.womble.com.
Thanks! Nick