本文整理汇总了C#中Media.GetVideoStreamByIndex方法的典型用法代码示例。如果您正苦于以下问题:C# Media.GetVideoStreamByIndex方法的具体用法?C# Media.GetVideoStreamByIndex怎么用?C# Media.GetVideoStreamByIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Media
的用法示例。
在下文中一共展示了Media.GetVideoStreamByIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Import
private void Import(Config config, Vegas vegas)
{
// Load XML file
if (!File.Exists(config.XmlFile)) {
throw new Exception("XML file does not exist.");
}
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(config.XmlFile);
// Determine image file names
XmlNodeList mouthCueElements = xmlDocument.SelectNodes("//mouthCue");
List<string> shapeNames = new List<string>();
foreach (XmlElement mouthCueElement in mouthCueElements) {
if (!shapeNames.Contains(mouthCueElement.InnerText)) {
shapeNames.Add(mouthCueElement.InnerText);
}
}
Dictionary<string, string> imageFileNames = GetImageFileNames(config.OneImageFile, shapeNames.ToArray());
// Create new project
bool promptSave = !config.DiscardChanges;
bool showDialog = false;
Project project = new Project(promptSave, showDialog);
// Set frame size
Bitmap testImage = new Bitmap(config.OneImageFile);
project.Video.Width = testImage.Width;
project.Video.Height = testImage.Height;
// Set frame rate
if (config.FrameRate < 0.1 || config.FrameRate > 100) {
throw new Exception("Invalid frame rate.");
}
project.Video.FrameRate = config.FrameRate;
// Set other video settings
project.Video.FieldOrder = VideoFieldOrder.ProgressiveScan;
project.Video.PixelAspectRatio = 1;
// Add video track with images
VideoTrack videoTrack = vegas.Project.AddVideoTrack();
foreach (XmlElement mouthCueElement in mouthCueElements) {
Timecode start = GetTimecode(mouthCueElement.Attributes["start"]);
Timecode length = GetTimecode(mouthCueElement.Attributes["end"]) - start;
VideoEvent videoEvent = videoTrack.AddVideoEvent(start, length);
Media imageMedia = new Media(imageFileNames[mouthCueElement.InnerText]);
videoEvent.AddTake(imageMedia.GetVideoStreamByIndex(0));
}
// Add audio track with original sound file
AudioTrack audioTrack = vegas.Project.AddAudioTrack();
Media audioMedia = new Media(xmlDocument.SelectSingleNode("//soundFile").InnerText);
AudioEvent audioEvent = audioTrack.AddAudioEvent(new Timecode(0), audioMedia.Length);
audioEvent.AddTake(audioMedia.GetAudioStreamByIndex(0));
}