`MediaMarker`s not being found through track/event iteration

rmlrmlrmlrml wrote on 2/15/2021, 6:17 AM

Here's a simple test program I wrote to ensure that I can find and read in media markers. Unfortunately I'm not succeeding right now:

using System.Text;
using ScriptPortal.Vegas;
using System.Windows.Forms;namespace TEST
{
    public class EntryPoint
    {
        public void FromVegas(Vegas vegas)
        {
            Project proj = vegas.Project;
            StringBuilder s = new StringBuilder();
            foreach (Track track in proj.Tracks)
            {
                foreach (TrackEvent trackEvent in track.Events)
                {
                    Take activeTake = trackEvent.ActiveTake;
                    if (null == activeTake)
                        continue;
                    Media media = activeTake.Media;
                    if (null == media)
                        continue;                    foreach (MediaMarker mm in media.Markers)
                    {
                        s.Append(mm.Label.ToString());
                    }
                }
            }
            MessageBox.Show(s.ToString());
        }
    }
}

I wrote it in Visual Studio 2019 on top of Vegas18Pro and followed the very helpful debugging steps from VEGASScriptFAQ.html to hit breakpoints. But despite having adding a media marker (manually - by hitting `M`), `media.Markers.length` is 0 for every trackEvent's activeTake's media object.

Is MediaMarker the concept I think it is or should I be reading these in differently?

Comments

jetdv wrote on 2/15/2021, 8:09 AM

Did you add the markers to the media in the trimmer? Did you SAVE the markers? If you don't first save the markers, even though they will appear on the event in the timeline, you won't be able to see them via a script.

I'm working on a tutorial on accessing markers via a script that will come out soon at www.jetdv.com. One of the topics I'm covering is promoting the markers from the event to the timeline. In my test, I put a clip in the trimmer, added the markers, and then added it to the timeline. The markers appear in the timeline event but the script will not see them. Go back to the trimmer, SAVE the markers, and then run the script again, and they will now be seen. So, in the trimmer just press "S" or use the hamburger "More Buttons" list below the trimmer window and choose the "Save Markers" option. You can also edit the visible buttons list and add the "Save markers" icon to appear.

And, yes, it appears you are accessing them correctly!

rmlrmlrmlrml wrote on 2/16/2021, 7:13 AM

Thank you, when I added a marker via the trimmer, it showed up differently on the timeline...clearly within one of the events themselves rather than hanging over the whole timeline:

Before (pressing M in the timeline):

After (adding via the trimmer and saving):

Do you know a way either of:

1) Reading in the former using a script

2) Adding the latter without using the trimmer?

I hope to be able to mark up clips effortlessly in order to read and split using a custom script.

jetdv wrote on 2/17/2021, 8:13 AM

Thank you, when I added a marker via the trimmer, it showed up differently on the timeline...clearly within one of the events themselves rather than hanging over the whole timeline:

That is correct. Once moved from the trimmer to the timeline, they show up INSIDE the event. But you still MUST save them in the trimmer. I believe that is the step you are missing. Add the markers in the trimmer, SAVE them, and then add the event to the timeline. Until you save them, the script won't see them!

Do you know a way either of:

1) Reading in the former using a script

2) Adding the latter without using the trimmer?

I hope to be able to mark up clips effortlessly in order to read and split using a custom script.

After you SAVE it in the trimmer, your script that you listed above will work to see that marker in the event on the timeline.

rmlrmlrmlrml wrote on 2/17/2021, 4:52 PM

Ah so to be clear the script is already working, I was able to accomplish this from your original response.

I was wondering if there was a way to read timeline markers via the script, or more easily add event markers without needing to go to the trimmer.

rmlrmlrmlrml wrote on 2/17/2021, 5:04 PM

Oh I figured it out:

vegas.Project.Markers

Exactly what I wanted. Thanks for helping me get there!

jetdv wrote on 2/17/2021, 5:28 PM

Yes, you can access all four types of markers on the main timeline:

CommandMarkerList commandMarkers = myVegas.Project.CommandMarkers;
MarkerList regMarkers = myVegas.Project.Markers;
RegionList regions = myVegas.Project.Regions;
CDRegionList cdTracks = myVegas.Project.CDTracks;

 

jetdv wrote on 3/1/2021, 10:53 AM

The tutorial to read embedded markers and regions in events on the timeline has now been released. It will read the embedded markers and regions and then create markers and regions on the timeline that matches.