Timecode sync attempt error message

wjauch wrote on 4/7/2024, 5:45 PM

I am attempting to test how to use timecode to sync clips in Vegas Pro 21, but I keep getting an error message "some media did not have valid offset information and were skipped". This is happening with all audio clips, recorded using a Sound Devices 744t 23.98 fps jammed using a Deity TC-1 timecode box. (Red Dragon R3d files, 23.98 fps jammed using a Deity TC-1 timecode box do not give this error). If I put just the R3d files in media pool, no error message and clips are moved to different locations different tracks on timeline. If I put just the wav files in media pool I get the error message and no files change position on the timeline. It does not matter if I drag the wav files to the timeline, or if I do file, import, broadcast wave format. (This is the window of information shown)

Sound Devices Wave Agent shows these 2 screens of information
:

Media info on the same file:

General
Complete name                            : D:\Timecode_test\Wavs\T38.WAV
Format                                   : Wave
File size                                : 3.31 MiB
Duration                                 : 12 s 12 ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 2 308 kb/s
Producer                                 : Sound Dev: 744T S#460706195007
Description                              : sSPEED=023.976-ND / sTAKE=38 / sUBITS=$01081138 / sSWVER=2.67 / sPROJECT= / sSCENE= / sFILENAME=T38.WAV / sTAPE=110108 / sTRK1=Track A / sTRK2=Track B / sNOTE=
Encoded date                             : 2011-01-08 03:24:29
Encoding settings                        : A=PCM,F=48000,W=24,M=stereo,R=48000,T=2 Ch
Producer_Reference                       : USSDV460706195007032501089992101

Audio
Format                                   : PCM
Format settings                          : Little / Signed
Codec ID                                 : 1
Duration                                 : 12 s 12 ms
Bit rate mode                            : Constant
Bit rate                                 : 2 304 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Bit depth                                : 24 bits
Stream size                              : 3.30 MiB (100%)

Google wasn't much help. I can't find anything re offset in the Sound Devices 744t manual (just in case offset meant "delay" I recorded some more wav files with a 0.1 msec delay in the 744t settings, these also gave the error). I put the wav file into Sound Forge 17 and exported them out, this did change the new files to have timecode starting at 0.00, but same error in Vegas.

Am I doing something wrong, or is there a problem in Vegas?

Any help would be gratefully appreciated

 

Comments

mark-y wrote on 4/7/2024, 6:15 PM

BWF support in Vegas has never been 100%. A forum search will bring up some old threads.

A long time ago, Sound Devices had a free utility called Wave Agent. Don't know if it's still around or being developed, but it did the job for us Vegas users a decade ago.

Sorry I can't give you more specific help with this issue.

Sometimes, there is no timecode on the first couple of frames of slaved cameras. Trimming the leading edge back sometimes fixes problems with timecode recognition.

wjauch wrote on 4/7/2024, 7:34 PM

Thank you, researching some of these old threads. Wave Agent is still around, probably unchanged for many years, but it does show the timecode in my audio wav files as correct. One thing I forgot to mention, when I import the broadcast wave files there is an error message "date/and or time is different between broadcast wave format files continue importing files, however importing them one at a time, and then attempting to sync, results in the same "some media did not have valid offset information and were skipped" message

 

wjauch wrote on 4/7/2024, 7:50 PM

Making a little progress: Import broadcast wave file and selecting arrange across timeline and use ruler time actually places the bwf files at correct place on timeline. Adding the R3d video files to another track, selecting them and then syncing them results in them apparently in the correct position relative to each other, but not at correct ruler time, the earliest R3d file starts at 00.00 on timeline. Tomorrows experiment is to start my test with first audio and video recording as close to 00.00 timecode. If importing bwf files gets them to correct timeline position, and Vegas multicam sync gets the R3d files in correct position relative to each other, then I hope moving the R3d files as a block to sync once will sync them all. Of course I hope I have a setting wrong somewhere and Vegas can do the complete job.

mark-y wrote on 4/7/2024, 8:18 PM

Of course I hope I have a setting wrong somewhere and Vegas can do the complete job.

That's a nice wish.

However, I think you are way ahead of the BWF development curve in Vegas, which has been neglected and given only token attention under previous brand owners. The current owners have a lot on their plate, so your contributions toward workarounds are especially appreciated, I'm certain

;?)

 

wjauch wrote on 4/9/2024, 7:53 AM

So to follow up re my comment from 2 days ago "If importing bwf files gets them to correct timeline position, and Vegas multicam sync gets the R3d files in correct position relative to each other, then I hope moving the R3d files as a block to sync once will sync them all. Of course I hope I have a setting wrong somewhere and Vegas can do the complete job." I tested this, however only the first clip, the one I did manually, was perfectly synced, by the last clip 5 minutes later, sync was about 5 frames off. My test was at 23.976 fps, will double check both camera and audio were set correctly, but I think my next step is to try RedCine-X to sync the clips as shown here: https://vimeo.com/36998950

wjauch wrote on 4/9/2024, 9:38 AM

RedCine-X worked. Interestingly as shown at 1.55 https://vimeo.com/36998950 RedCine-X did change the timecode frequency from 48000 to 48048 (I wonder if Vegas needed to do this also but didn't do it?). Is there a setting somewhere in Vegas I can do that manually to test it? All the clips I tested are only a few seconds long, will need to try a 5 minute clip aslo to make sure it stays in sync for a longer time period.

wjauch wrote on 4/10/2024, 3:38 PM

Recorded a 5 minute R3d clip at 23.976 fps with simultaneous audio recorded on camera and on Sound Devices, Timecode lines up perfectly using Vegas, no drift. I then wanted to test multiple clips using 24 fps (instead of 23.976), but unfortunately timecode cable broke.

NoKi wrote on 4/14/2024, 8:30 AM

I wrote a script to read the TC information from my SD MixPre BWF files using Exiftool (https://exiftool.org/) and to add the TC information to the media properties. You have to select all BWFs in the media pool and start the script, that's it.
Exiftool.exe has to be under this path "C:\Program Files\exiftool\exiftool.exe" (see line 57).

Hope it helps,
Nils

using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using ScriptPortal.Vegas;
using System.Diagnostics;
using System.Windows.Forms;



public class EntryPoint
{
    public static Vegas myVegas;
    
    public void FromVegas(Vegas vegas)
    {
        myVegas = vegas;
        Media[] selectedMedia = myVegas.Project.MediaPool.GetSelectedMedia();
    
        foreach (Media media in selectedMedia)
        {
            if (media.HasAudio())
            {
                FileInfo file = new FileInfo(media.FilePath);                                                
                string mediaFilePath = Convert.ToString(file);
                mediaFilePath = mediaFilePath.ToLowerInvariant();
            
                if (mediaFilePath.EndsWith(".wav") || mediaFilePath.EndsWith(".bwf"))
                {
                    string timeRefSampleRate = GetTimeReference(mediaFilePath);
                    // MessageBox.Show(timeRefSampleRate);
                    string[] array = timeRefSampleRate.Split('\n');
                    
                    if (array.Length > 2)
                    {                        
                        double samples = Convert.ToDouble(array[0]);
                        double sampleRate = Convert.ToDouble(array[1]);
                        
                        Timecode newTimeIn = Timecode.FromSeconds(samples / sampleRate);
                                            
                        media.UseCustomTimecode = true;
                        media.RulerFormat = RulerFormat.Time;
                        media.TimecodeIn = newTimeIn;
                        media.Comment = "Timecode from BEXT";
                    }
                }
            }        
        }
        myVegas.Project.MediaPool.OpenAllMedia();
    }    
    
    static string GetTimeReference(string mediaFilePathTmp)
        {
            string exifToolParameter = "\"" + @mediaFilePathTmp + "\"" + @" -s3 -timereference -samplerate";

            Process processExifTool = new Process();
            processExifTool.StartInfo.FileName = @"C:\Program Files\exiftool\exiftool.exe";
            processExifTool.StartInfo.Arguments = exifToolParameter;
            processExifTool.StartInfo.CreateNoWindow = true;
            processExifTool.StartInfo.UseShellExecute = false;
            processExifTool.StartInfo.RedirectStandardOutput = true;
            processExifTool.Start();

            string timeRefSampleRateTmp = processExifTool.StandardOutput.ReadToEnd();          

            return timeRefSampleRateTmp;
        }

}

 

To move all selected timeline events (audio & video) to their correct absolute TC position, you can use this script. I found it somewhere on the internet, and it works perfecly. (thanks to whoever it originally created it :-) )

using System;
using ScriptPortal.Vegas;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Timecode minPosition = vegas.Project.Ruler.StartTime;
        
        foreach (Track theTrack in vegas.Project.Tracks)
        {
            foreach (TrackEvent ev in theTrack.Events)
            {
                if (!ev.Selected) continue;

                Timecode position = ev.ActiveTake.Media.TimecodeIn + ev.ActiveTake.Offset - minPosition;
                ev.Start = position;

                if (ev.Group != null)
                {
                    foreach (TrackEvent groupevent in ev.Group)
                    {
                    groupevent.Start = position;
                    }
                }
            }
        }
    }
}

 

wjauch wrote on 4/15/2024, 8:50 AM

Thank you @NoKi . I have never used scripts or exiftool, but will certainly give it a try likely next week.

 

NoKi wrote on 4/15/2024, 9:40 AM

Scripting is great!

To me, scripting was the only way to use timecode in a lean, productive way. I'm really puzzled, why a video editing software claiming to be "pro" is neglecting timecode so much.

- Vegas is not able to read the correct file TC from my Panasonic cameras at all -> had to write a script
- Vegas cannot read audio based LTC -> had to write a script
- BWF BEXT Timecode can only be read by the import function -> had to write a script
- the Vegas on-board aligning function positions audio events to the absolute TC position, whereas video events are set to relative positions (first event to timeline start). Makes no sense... -> had to write scripts

Nils

Btw, to fool the Vegas internal relative TC positioning of video events, just add a video event with a TC of 00.00.00,00 to the selected media. This one will be put to the timeline start and all other events will end up at their correct absolute TC position.

wjauch wrote on 4/22/2024, 9:06 PM

@Noki I followed your detailed scripting instructions above using 7 test clips, 6 that had simultaneous video and audio, and one each video and audio where I had deliberately not run the other. Result: Only one of the 6 pairs that could be synced was "synced", and that was actually still 7 frames off. I then ran pluraleyes, it synced everything correctly (not surprising as camera audio was a feed from the recorder).
I think I'll give up on this until (hopefully) Vegas timecode gets an overhaul.

wjauch wrote on 5/2/2024, 1:12 PM

@Noki I successfully did some syncing in RedCine-X, but still can't get syncing to work inside Vegas. I am sharing below a cloud link to the set of files I just used, and the resultant Veg file. I created a video track and two audio tracks. Imported the bwf files then ran the first script. Imported the R3d video files, then dragged them to timeline, then ran second script. Selected everything in media pool, then "layout tracks using media timecode". Result moved clips, but didn't sync anything correctly. Am I doing something wrong or is it a Vegas problem? (Also when I import the bwf files at the beginning I always get an error message "Date and/or time is different between bwf files. Continue importing files? I always click yes).

Thanks for all your help up to this point.

https://u.pcloud.link/publink/show?code=kZezth0ZDUsCRQSi8Wznrw4kdvF4ghEDyboy

NoKi wrote on 5/2/2024, 2:03 PM

@wjauch

I made a script for your RED files to read the time code from them (also uses ExifTool).

So, the workflow should look like this:

1. Drag all your audio and video files to the project media

2. Select all BWF WAVs and run the first script above. It only works, if ExifTool is under this path "C:\Program Files\exiftool\exiftool.exe", now there should be a timecode in value

3. Select your R3D files and run the script below. It also only works, if ExifTool is under this path "C:\Program Files\exiftool\exiftool.exe", now there should be a timecode in value

4. Put all your media to timeline tracks, like you want to have it and run the second script above to move all events to their timecode positions

Nils

// Read RED timecode
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using ScriptPortal.Vegas;
using System.Diagnostics;
using System.Windows.Forms;



public class EntryPoint
{
    public static Vegas myVegas;
    
    public void FromVegas(Vegas vegas)
    {
        myVegas = vegas;
        Media[] selectedMedia = myVegas.Project.MediaPool.GetSelectedMedia();
    
        foreach (Media media in selectedMedia)
        {
            if (media.HasVideo())
            {        
                FileInfo file = new FileInfo(media.FilePath);                                        
                string mediaFilePath = Convert.ToString(file);
                mediaFilePath = mediaFilePath.ToLowerInvariant();
                
                //if (mediaFilePath.EndsWith(".mov"))
                {
                    string panaTimecode = GetTimeReference(mediaFilePath);                
                    //MessageBox.Show(panaTimecode);
                    
                    if (panaTimecode != "")
                    {
                        Timecode newTimeIn = Timecode.FromString(panaTimecode, RulerFormat.TimeAndFrames);    
                        //Timecode newTimeIn = Timecode.FromString(panaTimecode, RulerFormat.SmpteEBU);                        
                        media.UseCustomTimecode = true;
                        media.RulerFormat = RulerFormat.TimeAndFrames;
                        //media.RulerFormat = RulerFormat.SmpteEBU;
                        media.TimecodeIn = newTimeIn;    
                        media.Comment = "Timecode from File";
                    }
                }                
            }    
        }        
        myVegas.Project.MediaPool.OpenAllMedia();
    }    
    static string GetTimeReference(string mediaFilePathTmp)
        {
            string exifToolParameter = "\"" + @mediaFilePathTmp + "\"" + @" -s3 -StartTimecode";
            //MessageBox.Show(exifToolParameter);
            Process processExifTool = new Process();
            processExifTool.StartInfo.FileName = @"C:\Program Files\ffmpeg\bin\exiftool.exe";
            processExifTool.StartInfo.Arguments = exifToolParameter;
            processExifTool.StartInfo.CreateNoWindow = true;
            processExifTool.StartInfo.UseShellExecute = false;
            processExifTool.StartInfo.RedirectStandardOutput = true;
            processExifTool.Start();

            string timeRefSampleRateTmp = processExifTool.StandardOutput.ReadToEnd();          

            return timeRefSampleRateTmp;
        }

}

 

wjauch wrote on 5/2/2024, 2:54 PM

@Noki Thank you, when I run the above script I get:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ComponentModel.Win32Exception: The system cannot find the file specified
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at EntryPoint.GetTimeReference(String mediaFilePathTmp)
   at EntryPoint.FromVegas(Vegas vegas)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at ScriptPortal.Vegas.ScriptHost.ScriptManager.Run(Assembly asm, String className, String methodName)
   at ScriptPortal.Vegas.ScriptHost.RunScript(Boolean fCompileOnly)
 

I admit I have no clue what all that means.

Also is there some method I can check, that after running a script there is now a timecode in value? (right clicking on the audio file, then properties, media does have a timecode section but it is greyed out).

 

NoKi wrote on 5/2/2024, 3:02 PM

The path to ExifTools in the script is wrong. I correct it to "C:\Program Files\exiftool\exiftool.exe"

Try this, please:

//read RED timecode

using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using ScriptPortal.Vegas;
using System.Diagnostics;
using System.Windows.Forms;



public class EntryPoint
{
    public static Vegas myVegas;
    
    public void FromVegas(Vegas vegas)
    {
        myVegas = vegas;
        Media[] selectedMedia = myVegas.Project.MediaPool.GetSelectedMedia();
    
        foreach (Media media in selectedMedia)
        {
            if (media.HasVideo())
            {        
                FileInfo file = new FileInfo(media.FilePath);                                        
                string mediaFilePath = Convert.ToString(file);
                mediaFilePath = mediaFilePath.ToLowerInvariant();
                
                //if (mediaFilePath.EndsWith(".mov"))
                {
                    string panaTimecode = GetTimeReference(mediaFilePath);                
                    //MessageBox.Show(panaTimecode);
                    
                    if (panaTimecode != "")
                    {
                        Timecode newTimeIn = Timecode.FromString(panaTimecode, RulerFormat.TimeAndFrames);    
                        //Timecode newTimeIn = Timecode.FromString(panaTimecode, RulerFormat.SmpteEBU);                        
                        media.UseCustomTimecode = true;
                        media.RulerFormat = RulerFormat.TimeAndFrames;
                        //media.RulerFormat = RulerFormat.SmpteEBU;
                        media.TimecodeIn = newTimeIn;    
                        media.Comment = "Timecode from File";
                    }
                }                
            }    
        }        
        myVegas.Project.MediaPool.OpenAllMedia();
    }    
    static string GetTimeReference(string mediaFilePathTmp)
        {
            string exifToolParameter = "\"" + @mediaFilePathTmp + "\"" + @" -s3 -StartTimecode";
            //MessageBox.Show(exifToolParameter);
            Process processExifTool = new Process();
            processExifTool.StartInfo.FileName = @"C:\Program Files\exiftool\exiftool.exe";
            processExifTool.StartInfo.Arguments = exifToolParameter;
            processExifTool.StartInfo.CreateNoWindow = true;
            processExifTool.StartInfo.UseShellExecute = false;
            processExifTool.StartInfo.RedirectStandardOutput = true;
            processExifTool.Start();

            string timeRefSampleRateTmp = processExifTool.StandardOutput.ReadToEnd();          

            return timeRefSampleRateTmp;
        }

}

Nils

NoKi wrote on 5/2/2024, 3:15 PM

Also is there some method I can check, that after running a script there is now a timecode in value? (right clicking on the audio file, then properties, media does have a timecode section but it is greyed out).

Yes, you can see the timecode in values in the media list (might need to scroll to the right).

Nils

wjauch wrote on 5/3/2024, 10:58 AM

I'm afraid it is still not working for me. Tried it 2 different ways, results below. Am I still doing something wrong or is it a Vegas issue?


First Test:

Add 1 video and 2 audio tracks
Import Wav files as BWF, arranged as "add across time"
Move this track to bottom.
Select all in media pool, run 1st script
Import all the R3d files.
Select the R3d files, and run script posted on 5/2/24
(all files do have timecode info listed when viewed as detailed in project media).
Drag the R3d files to track 1
Run the second script from 4/14/24
Result: Only 1 R3d is moved to sync, and it is off by 2 frames.
Then selecting T001_R002 R3d file on timeline, running script again, that clip is synced, but 7 frames off
Then selecting T001_R003 R3d file on timeline, running script again, that clip is synced, but also 7 frames off.
Then selecting T001_R004 R3d file on timeline, running script again, that clip is synced, but 13 frames off.
Then selecting T001_R005 R3d file on timeline, running script again, that clip is synced, but 15 frames off.
(these Veg files are uploaded to https://u.pcloud.link/publink/show?code=kZezth0ZDUsCRQSi8Wznrw4kdvF4ghEDyboy as Results1,2,3,4,5 Veg files

Second Test:

Add 1 video and 2 audio tracks
Import Wav files as BWF, arranged as "add across time"
Move this track to bottom.
Select all in media pool, run 1st script
Import all the R3d files.
Select the R3d files, and run script posted on 5/2/24
(all files do have timecode info listed when viewed as detailed in project media).
Select all in Project Media, then layout tracks by media timecode.
Result: Every R3d and every wav file is on a new track. First clip synced, but off 3 frames, second clip synced but off 9 frames, third clip synced also off 9 frames, 4th clip synced but off 17 frames, 5th frame synced but off 19 frames.
This Veg file is uploaded as Results_layout_by_timecode.veg


 

NoKi wrote on 5/3/2024, 1:38 PM

Just tried it again and it works here. Please try again with these steps:

1. Drag all your audio and video files to the project media window,
but DO NOT use the Vegas import function (just to be sure)

2. Select all BWF WAVs and run the first script from 4/14/24.

3. Select your R3D files, set your Vegas Project settings to match your video files and run the script from 5/2/24.
Do you see the exact same Timecode In values as shown below?

4. Put all your videos to one timeline track, and the WAVs to another track

5. Run the second script from 4/14/24. You should see this layout in the edit details window. You might have to run the script more than one time, to get all events to the right position (never found the reason for this).

Do all Timecode In and event start positions match to this?

Nils

NoKi wrote on 5/3/2024, 2:01 PM

Or do you mean the time offset of those little transients between the video audio and the SD 744 audio?

Looks like a similar problem as in this thread https://www.vegascreativesoftware.info/us/forum/timecode-how-to-sync-audio-only-tracks-how-to-limit-total-tracks--145377/ matching NDF timecode to realtime (BWF).

You can try to use this script für your SD 744 files to compensate for the NDF timecode:

// Read BWF WAV timecode with NDF compensation

using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using ScriptPortal.Vegas;
using System.Diagnostics;
using System.Windows.Forms;



public class EntryPoint
{
    public static Vegas myVegas;
    
    public void FromVegas(Vegas vegas)
    {
        myVegas = vegas;
        Media[] selectedMedia = myVegas.Project.MediaPool.GetSelectedMedia();
    
        foreach (Media media in selectedMedia)
        {
            if (media.HasAudio())
            {
                FileInfo file = new FileInfo(media.FilePath);                                                
                string mediaFilePath = Convert.ToString(file);
                mediaFilePath = mediaFilePath.ToLowerInvariant();
            
                if (mediaFilePath.EndsWith(".wav") || mediaFilePath.EndsWith(".bwf"))
                {
                    string timeRefSampleRate = GetTimeReference(mediaFilePath);
                    // MessageBox.Show(timeRefSampleRate);
                    string[] array = timeRefSampleRate.Split('\n');
                    
                    if (array.Length > 2)
                    {                        
                        double samples = Convert.ToDouble(array[0]);
                        double sampleRate = Convert.ToDouble(array[1]);
                        samples = samples * 29.97/30;
                        
                        Timecode newTimeIn = Timecode.FromSeconds(samples / sampleRate);
                                            
                        media.UseCustomTimecode = true;
                        media.RulerFormat = RulerFormat.Smpte30;
                        media.TimecodeIn = newTimeIn;
                        media.Comment = "Timecode from BEXT - NDF compensation";
                    }
                }
            }        
        }
        myVegas.Project.MediaPool.OpenAllMedia();
    }    
    
    static string GetTimeReference(string mediaFilePathTmp)
        {
            string exifToolParameter = "\"" + @mediaFilePathTmp + "\"" + @" -s3 -timereference -samplerate";

            Process processExifTool = new Process();
            processExifTool.StartInfo.FileName = @"C:\Program Files\exiftool\exiftool.exe";
            processExifTool.StartInfo.Arguments = exifToolParameter;
            processExifTool.StartInfo.CreateNoWindow = true;
            processExifTool.StartInfo.UseShellExecute = false;
            processExifTool.StartInfo.RedirectStandardOutput = true;
            processExifTool.Start();

            string timeRefSampleRateTmp = processExifTool.StandardOutput.ReadToEnd();          

            return timeRefSampleRateTmp;
        }

}

Nils

Robert Johnston wrote on 5/3/2024, 7:16 PM

@NoKi, @wjauch, @mark-y

 I keep getting an error message "some media did not have valid offset information and were skipped". 

I guess due to a bug, the beginning timecode has to be greater than zero, with 00:00:00.001 being the minimum.

For video, you can change the Custom Timecode field on the properties page (or write a script) :

For audio, you can use one of NoKi's scripts and add a certain number of samples, such as 24 for a 48000 sample rate. 24 divided by 48000 is .0005, but it gets rounded up to .001. If the sample rate is different, you would need to calculate: Samples_to_add = Sample_rate * .0005

samples = samples + (sampleRate * .0005);
Timecode newTimeIn = Timecode.FromSeconds(samples / sampleRate);
 

You would probably want to add these extra samples to all audio media even if beginning timecode is already greater than zero just so each media's timecode is offset the same amount.

Intel Core i7 10700K CPU @ 3.80GHz (to 4.65GHz), NVIDIA GeForce RTX 2060 SUPER 8GBytes. Memory 32 GBytes DDR4. Also Intel UHD Graphics 630. Mainboard: Dell Inc. PCI-Express 3.0 (8.0 GT/s) Comet Lake. Bench CPU Multi Thread: 5500.5 per CPU-Z.

Vegas Pro 21.0 (Build 108) with Mocha Vegas

Windows 11 not pro

wjauch wrote on 5/3/2024, 7:56 PM

Just tried it again and it works here. Please try again with these steps:

1. Drag all your audio and video files to the project media window,
but DO NOT use the Vegas import function (just to be sure)

2. Select all BWF WAVs and run the first script from 4/14/24.

3. Select your R3D files, set your Vegas Project settings to match your video files and run the script from 5/2/24.
Do you see the exact same Timecode In values as shown below?

4. Put all your videos to one timeline track, and the WAVs to another track

5. Run the second script from 4/14/24. You should see this layout in the edit details window. You might have to run the script more than one time, to get all events to the right position (never found the reason for this).

Do all Timecode In and event start positions match to this?

Nils

After 3. above I get the same numbers as you. Re number 5 when I selected all clips in media pool, and ran second script from 4/14/24 multiple times, it looked like only 1 clip moved. Somehow I then ended up selecting all the clips on the timeline, ran the second script multiple times, clips were synced but each off a couple of frames, increasing the further along the timeline. Your screengrab now shows 2 entries for each R3d, mine does not. The numbers, for R3D and for wavs, did not match your second screengrab, I got:

(In step 3 I manually set the project properties to match the R3d files, then when I dragged the R3d to timeline VP asked if I wished to set project video settings to match this media, it made no difference whether I accepted or declined).

What am I doing incorrectly?

 

NoKi wrote on 5/4/2024, 9:24 AM

OK, can you try these scripts after dragging the files to the project media and adapting project settings.

This script for the R3d files (nothing changed to this one)

//read RED timecode

using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using ScriptPortal.Vegas;
using System.Diagnostics;
using System.Windows.Forms;



public class EntryPoint
{
    public static Vegas myVegas;
    
    public void FromVegas(Vegas vegas)
    {
        myVegas = vegas;
        Media[] selectedMedia = myVegas.Project.MediaPool.GetSelectedMedia();
    
        foreach (Media media in selectedMedia)
        {
            if (media.HasVideo())
            {        
                FileInfo file = new FileInfo(media.FilePath);                                        
                string mediaFilePath = Convert.ToString(file);
                mediaFilePath = mediaFilePath.ToLowerInvariant();
                
                //if (mediaFilePath.EndsWith(".mov"))
                {
                    string panaTimecode = GetTimeReference(mediaFilePath);                
                    //MessageBox.Show(panaTimecode);
                    
                    if (panaTimecode != "")
                    {
                        Timecode newTimeIn = Timecode.FromString(panaTimecode, RulerFormat.TimeAndFrames);    
                        //Timecode newTimeIn = Timecode.FromString(panaTimecode, RulerFormat.SmpteEBU);                        
                        media.UseCustomTimecode = true;
                        media.RulerFormat = RulerFormat.TimeAndFrames;
                        //media.RulerFormat = RulerFormat.SmpteEBU;
                        media.TimecodeIn = newTimeIn;    
                        media.Comment = "Timecode from File";
                    }
                }                
            }    
        }        
        myVegas.Project.MediaPool.OpenAllMedia();
    }    
    static string GetTimeReference(string mediaFilePathTmp)
        {
            string exifToolParameter = "\"" + @mediaFilePathTmp + "\"" + @" -s3 -StartTimecode";
            //MessageBox.Show(exifToolParameter);
            Process processExifTool = new Process();
            processExifTool.StartInfo.FileName = @"C:\Program Files\exiftool\exiftool.exe";
            processExifTool.StartInfo.Arguments = exifToolParameter;
            processExifTool.StartInfo.CreateNoWindow = true;
            processExifTool.StartInfo.UseShellExecute = false;
            processExifTool.StartInfo.RedirectStandardOutput = true;
            processExifTool.Start();

            string timeRefSampleRateTmp = processExifTool.StandardOutput.ReadToEnd();          

            return timeRefSampleRateTmp;
        }

}

 

This script for the WAVs. This one compensates the increasing timeline shift due to the NDF timecode. I think this solves the problem that audio and video get increasingly out of sync.

// Read BWF WAV timecode with NDF compensation

using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using ScriptPortal.Vegas;
using System.Diagnostics;
using System.Windows.Forms;



public class EntryPoint
{
    public static Vegas myVegas;
    
    public void FromVegas(Vegas vegas)
    {
        myVegas = vegas;
        Media[] selectedMedia = myVegas.Project.MediaPool.GetSelectedMedia();
    
        foreach (Media media in selectedMedia)
        {
            if (media.HasAudio())
            {
                FileInfo file = new FileInfo(media.FilePath);                                                
                string mediaFilePath = Convert.ToString(file);
                mediaFilePath = mediaFilePath.ToLowerInvariant();
            
                if (mediaFilePath.EndsWith(".wav") || mediaFilePath.EndsWith(".bwf"))
                {
                    string timeRefSampleRate = GetTimeReference(mediaFilePath);
                    // MessageBox.Show(timeRefSampleRate);
                    string[] array = timeRefSampleRate.Split('\n');
                    
                    if (array.Length > 2)
                    {                        
                        double samples = Convert.ToDouble(array[0]);
                        double sampleRate = Convert.ToDouble(array[1]);
                        samples = samples * 29.97/30;
                        
                        Timecode newTimeIn = Timecode.FromSeconds(samples / sampleRate);
                                            
                        media.UseCustomTimecode = true;
                        media.RulerFormat = RulerFormat.Smpte30;
                        media.TimecodeIn = newTimeIn;
                        media.Comment = "Timecode from BEXT - NDF compensation";
                    }
                }
            }        
        }
        myVegas.Project.MediaPool.OpenAllMedia();
    }    
    
    static string GetTimeReference(string mediaFilePathTmp)
        {
            string exifToolParameter = "\"" + @mediaFilePathTmp + "\"" + @" -s3 -timereference -samplerate";

            Process processExifTool = new Process();
            processExifTool.StartInfo.FileName = @"C:\Program Files\exiftool\exiftool.exe";
            processExifTool.StartInfo.Arguments = exifToolParameter;
            processExifTool.StartInfo.CreateNoWindow = true;
            processExifTool.StartInfo.UseShellExecute = false;
            processExifTool.StartInfo.RedirectStandardOutput = true;
            processExifTool.Start();

            string timeRefSampleRateTmp = processExifTool.StandardOutput.ReadToEnd();          

            return timeRefSampleRateTmp;
        }

}

And this script for positioning the events on the timeline matching their timecode. You don't need to select the events anymore, it will shift all events automatically (twice, to be sure).

using System;
using ScriptPortal.Vegas;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Timecode minPosition = vegas.Project.Ruler.StartTime;
        
        foreach (Track theTrack in vegas.Project.Tracks)
        {
            foreach (TrackEvent ev in theTrack.Events)
            {
                //if (!ev.Selected) continue;

                Timecode position = ev.ActiveTake.Media.TimecodeIn + ev.ActiveTake.Offset - minPosition;
                ev.Start = position;

                if (ev.Group != null)
                {
                    foreach (TrackEvent groupevent in ev.Group)
                    {
                    groupevent.Start = position;
                    }
                }
            }
            foreach (TrackEvent ev in theTrack.Events)
            {
                //if (!ev.Selected) continue;

                Timecode position = ev.ActiveTake.Media.TimecodeIn + ev.ActiveTake.Offset - minPosition;
                ev.Start = position;

                if (ev.Group != null)
                {
                    foreach (TrackEvent groupevent in ev.Group)
                    {
                    groupevent.Start = position;
                    }
                }
            }
        }
    }
}

Hope this works now!

Nils

wjauch wrote on 5/4/2024, 12:19 PM

@NoKi HUMONGOUS THANKS! These worked beautifully.

wjauch wrote on 5/4/2024, 1:36 PM

This post is to summarize in one post all the steps needed to make this work, for the benefit of anyone reading this in the future.

Credit goes to @NoKi for creating all these.

Note these scripts probably only work for R3d shot at 23.976 fps and Sound Devices (744t was used to develop this) files recorded at framerate of 23.98 fps.

These scripts use Exiftool (https://exiftool.org/). Exiftool.exe has to be under this path "C:\Program Files\exiftool\exiftool.exe.

For each of the three scripts posted by @NOKI earlier today, open Notepad, copy/paste that text, save file as a .cs type (at bottom of notepad change filetype to "all files *.*)

Copy the .cs files to C:\Program Files\Vegas\Vegas Pro 21.0\Script Menu. (note this location is currently not listed in Vegas Help, however it is where all the .cs files that come with Vegas are located).

In Vegas go to tools, scripting and "Rescan script menu folder".

Open a new project in Vegas

Go to File, properties, set framerate to 23.976 and set the resolution (width and height) to match your R3d resolution.

Open a Windows File Explorer window, and drag all the R3D and all the wav files to Vegas Project Media window.

In the project media window, select all the R3d files, and run the first scrip posted by @NoKi.

In the project media window, select all the wav files, and run the second scrip posted by @NoKi.

Drag all the R3d files from project media window to the timeline. (If "do you want to set your project video settings to match this media?" pops up, I select no, although likely it doesn't matter)

Drag all the wav files from project media to a lower track on timeline.

Run the third script posted by @NoKi.

All wav files should now be synced with their corresponding R3d file.