I need a script that adds opacity keyframes to a track using the composite level, where the track already has composite level activated with an initial opacity of 100%. Throughout the project, there are specific regions where the script should add opacity keyframes at the beginning and end of each region. Within these regions, at the start and end points, the opacity should be set to 51%. Outside of these regions, the opacity should remain at 100%. Essentially, the script should create opacity transitions within these regions while maintaining the rest of the track at full opacity
using System;
using System.Collections.Generic;
using System.Linq;
using ScriptPortal.Vegas;
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
// Verifica se há um projeto aberto
if (vegas.Projects.Count == 0)
{
return;
}
// Obtém a primeira faixa de vídeo do projeto
Track videoTrack = vegas.Projects[0].Tracks.OfType<VideoTrack>().FirstOrDefault();
if (videoTrack == null)
{
return;
}
// Obtém todas as regiões do projeto
List<Region> regions = vegas.Projects[0].Regions.ToList();
// Loop através de todas as regiões
foreach (Region region in regions)
{
// Cria pontos de envelope no início e no final da região
double start = region.Position.ToMilliseconds();
double end = (region.Position + region.Length).ToMilliseconds();
AddEnvelopePoints(videoTrack, start, 51);
AddEnvelopePoints(videoTrack, end, 51);
}
// Cria pontos de envelope para o resto da faixa de vídeo
AddEnvelopePoints(videoTrack, 0, 100);
AddEnvelopePoints(videoTrack, vegas.Projects[0].Length.ToMilliseconds(), 100);
}
// Função para adicionar pontos de envelope
private void AddEnvelopePoints(Track track, double position, double value)
{
Envelope envelope = track.Envelopes[EnvelopeType.CompositeLevel];
EnvelopePoint point = new EnvelopePoint(new Timecode(position), value);
envelope.AddPoint(point);
}
}
My goal with the script is to reduce the opacity of the areas within the regions using the composite level to 51%, and everything else outside of the numerous regions in the project remains with the opacity at 100%
To clarify further, i am trying to make a script that adjusts the opacity of specific areas within defined regions to 51% using a composite level, while leaving everything outside of these regions at full opacity (100%)
This was my failed attempt to make a script that performs this action. Can anyone help me get this result?