Problem adding a 3D subclip to a video event

BruceDale wrote on 1/9/2011, 12:26 AM
I'm trying to create a new stereo3D video event using the scripting interface. This is the code I'm using:
var subclip3D = proj.MediaPool.CreateStereo3DSubclip(leftMedia, rightMedia);
VideoStream stream3D = (VideoStream) subclip3D.Streams.GetItemByMediaType(MediaType.Video, 0);
if (null == stream3D) throw new ApplicationException("media contains no video streams");
stream3D.Stereo3DMode = Stereo3DInputMode.TopBottomFull;
var event3D = new VideoEvent();
var take3D = new Take(stream3D);
track3D.Events.Add(event3D);
event3D.Takes.Add(take3D);

The last line causes the error "Illegal characters in path"

How do I add a stereo3D subclip to a video event by scripting?

Comments

ForumAdmin wrote on 1/19/2011, 2:32 PM
You have discovered a bug and we will try to fix it for the next update. In the meantime, you can work around the bug by using an offline Media object to create the Take and then call the Media.Replace method with the 3D subclip.


using System;
using Sony.Vegas;

class EntryPoint
{
public void FromVegas(Vegas vegas)
{
Media leftMedia = new Media(@"D:\Media\3D\SampleLeft.avi");
Media rightMedia = new Media(@"D:\Media\3D\SampleRight.avi");
leftMedia.TimecodeIn = Timecode.FromNanos(0);
rightMedia.TimecodeIn = Timecode.FromNanos(0);
Media subclip3D = vegas.Project.MediaPool.CreateStereo3DSubclip(leftMedia, rightMedia);
VideoStream stream3D = (VideoStream) subclip3D.Streams.GetItemByMediaType(MediaType.Video, 0);
if (null == stream3D) throw new ApplicationException("media contains no video streams");
stream3D.Stereo3DMode = Stereo3DInputMode.TopBottomFull;
VideoTrack track3D = vegas.Project.AddVideoTrack();
VideoEvent event3D = track3D.AddVideoEvent();

Media offlineMedia = new Media(@"Z:\DoesNotExist.avi");
offlineMedia.TimecodeIn = subclip3D.TimecodeIn;
offlineMedia.TimecodeOut = subclip3D.TimecodeOut;
MediaStream offlineStream = offlineMedia.CreateOfflineStream(MediaType.Video);

Take take3D = event3D.AddTake(offlineStream);
offlineMedia.ReplaceWith(subclip3D);
}
}