Vegas 18 is maintaining a file lock on media after using the ReplaceWith method in the scripting engine even after the project is closed.
This is similar to the issue described in this bug report.
It occurs whenever the test media use the "compoundplug.dll" decoder. This happens for M2TS files by default and other media files such as MP4 when using a virtual machine for testing. It also happens for MP4 files if you turn on the "Enable legacy AVC decoding" option under File I/O.
If anyone can think of a workaround, it would be greatly appreciated.
I've simplified the steps to reproduce it.
Save the included script as "C:\Program Files\VEGAS\VEGAS Pro 18.0\Script Menu\ReplaceWithLockingIssue.cs"
Copy an m2ts file to "C:\Test\Original.m2ts"
Copy an m2ts file to "C:\Test\Replaced.m2ts"
Open Vegas 18
Run the script | Tools | Scripting | FileLockingIssue
Close the project. There is no need to save.
Try and delete either "C:\Test\Original.m2ts" or "C:\Test\Replaced.m2ts"
The file lock will not be released until Vegas 18 is closed
This does no affect Vegas 9 through 17
using ScriptPortal.Vegas;
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
const string originalMedia = @"C:\Test\Original.m2ts";
const string replacedMedia = @"C:\Test\Replaced.m2ts";
vegas.NewProject(false, false);
var videoTrack = new VideoTrack();
vegas.Project.Tracks.Add(videoTrack);
var media = new Media(originalMedia);
var length = media.Length;
videoTrack.AddVideoEvent().AddTake(media.GetVideoStreamByIndex(0), true);
media.ReplaceWith(new Media(replacedMedia));
}
}