Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums VEGAS Pro Script – add images to track with position specified by a text file

  • Script – add images to track with position specified by a text file

    Posted by Kay Lean on March 1, 2010 at 1:11 am

    Hi Guys!

    I was wondering if it is possible and/or if there was a script floating around that could do (or could be modified to do) the following:

    Place images on the timeline with position and duration specified by a .txt or .csv file. So I will have a text file that would specify

    image1.jpg, time-in, time-out
    image2.jpg, time-in, time-out
    etc

    The script will read the text file and place the images accordingly.

    The one possible way I have come up with is to export the XML file and then use any programming language to insert the images as video events where I need them. But wondering if there was something more elegant that could happen with a Vegas Script.

    thanks
    kay

    Kay Lean replied 16 years, 2 months ago 3 Members · 4 Replies
  • 4 Replies
  • John Rofrano

    March 1, 2010 at 3:06 am

    If you download the Vegas Script SDK and look in the VegasScriptFAQ.html file under 2.4: How do I add media to the timeline? you will find examples that show you everything you need to know. In particular it contains this method that will add an image to the timeline.

    VideoEvent AddVideoEvent(Vegas vegas, String mediaFile, Timecode start, Timecode length)
    {
         Media media = new Media(mediaFile);
         VideoTrack track = vegas.Project.AddVideoTrack();
         VideoEvent videoEvent = track.AddVideoEvent(start, length);
         Take take = videoEvent.AddTake(media.GetVideoStreamByIndex(0));
         return videoEvent;
    }

    All you need to do is add the code to read the csv or xml file.

    ~jr

    http://www.johnrofrano.com
    http://www.vasst.com

  • Kay Lean

    March 1, 2010 at 5:05 pm

    Thanks for the prompt reply, John! Very useful resource. It answered quite a few questions that I had all in one place! Appreciate the help!

    Can anyone point me to a script that reads data off .txt files. I’m not much of a coder (labview is all I do) but probably not a bad “tweaker” of scripts 🙂

    thanks
    kay

  • Edward Troxel

    March 1, 2010 at 8:07 pm

    // Read the file and process it line by line.
    string line;
    System.IO.StreamReader file = new System.IO.StreamReader("myfile.txt");
    while ((line = file.ReadLine()) != null)
    {
    ProcessLine(line);
    }

    file.Close();

    Edward Troxel
    JETDV Scripts

  • Kay Lean

    March 2, 2010 at 2:36 pm

    Awesome! Thanks Edward. This is a great forum. Could not ask for more.

    I’m off to figure this all out. See if I can dive in and get all this to work. If I can get it to work will post it for others to refine and use.

    kay

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy