Thanks - You guys are great

Dan Kazup wrote on 9/19/2014, 4:52 AM
I've been working on a project for my football team and by using this Forum have been able to almost finish it.

I shoot each game from two angles, wide and tight. Each play is a file on the video camera so I'll end up with two sets of files (I use two cameras). The goal is to put these together side by side and then produce.

A typical game has 80 plays so manually matching 80 files is a pain...but here is my script that as long as I shoot correctly....the files will be put into a veg file correctly. Then I can just batch render those veg files and upload to the coaches site.

The last thing I need to work on is some way to synch the audio...since I'm manually starting both cameras I'm a few frames off...nothing too significant maybe 1/15 of a second or so.


//Script to add images in a directory to a new track
// Save as: AddImagesInFolder.cs

using System;
using System.IO;
using System.Text;
using System.Drawing;
using System.Reflection;
using System.Diagnostics;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Sony.Vegas;

public class EntryPoint
{
Vegas myVegas;
VideoTrack myTrackTight = null;
VideoTrack myTrackWide = null;
string BaseFolder = "C:\\Users\\Daniel\\Videos\\Football_2014\\Games"; //change to change the base location to search
Timecode myTC = null;
Timecode myLen = null;
string addimgTight;
string addimgWide;



public void FromVegas(Vegas vegas)
{
myVegas = vegas;
myTC = new Timecode(0);
myLen = Timecode.FromFrames(1);
int intTight =67;
int intWide =105;

//First get the image folder
BaseFolder = GetSaveDir(Path.GetFullPath(BaseFolder));
if (!Directory.Exists(BaseFolder))
{
MessageBox.Show("The Folder still could not be found.");
return;
}

//Now start a new project and add a new track for the images.
myVegas.NewProject(false, false);

myVegas.Project.Video.Width = 1440;
myVegas.Project.Video.Height = 580;

myTrackTight = new VideoTrack(0, "Tight");
myVegas.Project.Tracks.Add(myTrackTight);

myTrackWide = new VideoTrack(1, "Wide");
myVegas.Project.Tracks.Add(myTrackWide);


for (int i = 0; i < 100; i++)
{

if (intTight > 99)
{
addimgTight = BaseFolder+"Tight\\00" + intTight + ".MTS";
}
else
{
addimgTight = BaseFolder+"Tight\\000" + intTight + ".MTS";
}

addimgWide = BaseFolder+"WIDE\\00" + intWide + ".MTS";

//Now add the image "newFile" to the timeline
Media mediaTight = new Media(addimgTight);
MediaStream streamTight = (MediaStream)mediaTight.Streams[0];
myLen = streamTight.Length;


VideoEvent newEventTight = new VideoEvent(myTC, myLen);

myTrackTight.Events.Add(newEventTight);
Take takeTight = new Take(streamTight);
newEventTight.Takes.Add(takeTight);


//Now add the image "newFile" to the timeline
Media mediaWide = new Media(addimgWide);
MediaStream streamWide = (MediaStream)mediaWide.Streams[0];
myLen = streamWide.Length;


VideoEvent newEventWide = new VideoEvent(myTC, myLen);

myTrackWide.Events.Add(newEventWide);
Take takeWide = new Take(streamWide);
newEventWide.Takes.Add(takeWide);

TrackMotionKeyframe trackKeyframeTight = myTrackTight.TrackMotion.MotionKeyframes[0];
trackKeyframeTight.PositionX = -360;
TrackMotionKeyframe trackKeyframeWide = myTrackWide.TrackMotion.MotionKeyframes[0];
trackKeyframeWide.PositionX = 360;

string outputDirectory = BaseFolder+ "veg";
// save the new project to the output directory
myVegas.SaveProject(Path.Combine(outputDirectory, "temp" + i + ".veg"));

myTrackTight.Events.Remove(newEventTight);
myTrackWide.Events.Remove(newEventWide);
intTight =intTight+1;
intWide = intWide+1;
}
}

public string GetSaveDir(string OrgSaveDir)
{
if (OrgSaveDir == null)
{
OrgSaveDir = "";
}
FolderBrowserDialog saveFileDialog = new FolderBrowserDialog();
//OpenFileDialog saveFileDialog = new OpenFileDialog(); // FolderBrowserDialog();
saveFileDialog.Description = "Select the desired folder";
saveFileDialog.ShowNewFolderButton = true;
if (!(OrgSaveDir == ""))
{
string initialDir = OrgSaveDir;
if (Directory.Exists(initialDir))
{
saveFileDialog.SelectedPath = initialDir;
}
}
else
{
saveFileDialog.SelectedPath = "c:\\";
}
if (System.Windows.Forms.DialogResult.OK == saveFileDialog.ShowDialog())
{
return Path.GetFullPath(saveFileDialog.SelectedPath) + Path.DirectorySeparatorChar;
}
else
{
return OrgSaveDir;
}
}


}

Comments

No comments yet - be the first to write a comment...