Leading edge trim for certain types of events

Jack S wrote on 10/19/2024, 8:30 AM

@jetdv Edward, I wonder if you could help me with a problem.
One of the tools in my extension allows the length and/or leading edge trim to be adjusted for selected events.
During my extensive testing, I found that empty video, empty audio or adjustment events were causing Vegas to crash when the tool was applied. After many hours of debugging, I found that one line of code was causing the crash. This is the line:-

myEvent.ActiveTake.Offset = myEvent.ActiveTake.Offset + timecodeLeadingTrim;            //Trim the leading edge

The code works OK for any other type of event. It's just the three types I've mentioned that gives the problem. I've worked around it by enclosing the code in a try/catch block so I can display an appropriate message.
Is this line of code the correct way of trimming an event at the leading edge (it seems so, as any other event type is trimmed correctly)?
If it is, there's a problem which could affect anyone trying to apply a leading edge trim to one of these types.
That's the background. My question is, do you have a way to test an event to see if it's any of the three events mentioned? If, you do, I could test for these and take the appropriate action.
Many thanks for any help you can give me.

My system
Genshin Infinity Gaming PC
Motherboard Gigabyte H610M H: m-ATX w/, USB 3.2, 1 x M.2
Power Supply Corsair RM750X
Intel Core i7-13700K - 16-Core [8P @ 3.4GHz-5.4GHz / 8E @ 2.50GHz-4.20GHz]
30MB Cache + UHD Graphics, Ultimate OC Compatible
Case Fan 4 x CyberPowerPC Hyperloop 120mm ARGB & PWM Fan Kit
CPU Fan CyberPowerPC Master Liquid LITE 360 ARGB AIO Liquid Cooler, Ultimate OC Compatible
Memory 32GB (2 x 16GB) DDR5/5200MHz Corsair Vengeance RGB
MSI GeForce RTX 4060 Ti 8GB - Ray Tracing Technology, DX12, VR Ready, HDMI, DP
System drive 1TB WD Black SN770 M.2 NVMe PCIe SSD - 5150MB/s Read & 4900MB/s Write
Storage 2 x 2TB Seagate BarraCuda SATA-III 6.0Gb/s 7200RPM
Windows 11 Home (x64)
Monitors
Generic Monitor (PHL 222V8) connected to GeForce RTX 4060 Ti
Generic Monitor (SAMSUNG) connected to iGPU

Camcorder
SONY Handycam HDR-XR550VE

Comments

jetdv wrote on 10/19/2024, 9:08 AM

Yes, that is how you trim the "front" and then you have to shorten the length too. Take a look at myEvent.Takes.Count and if that is zero, there is nothing there to adjust and you can bypass it.

You might also look at the .AdjustStartLength to see if that causes an error. I have not tested to see if this works with empty/adjustment events. Here's an example of reducing the "head" space (OverDist is the time to cut off the front):

                double dStart = MyEvent.Start.ToMilliseconds();
                double dLength = MyEvent.Length.ToMilliseconds();

                dStart = dStart + OverDist.ToMilliseconds();
                dLength = dLength - OverDist.ToMilliseconds();
    
                MyEvent.AdjustStartLength(new Timecode(dStart), new Timecode(dLength), false);

Alternately, you could "split" the event at that point, delete the left part, and move the right part to the left.

Jack S wrote on 10/19/2024, 9:18 AM

I'll have a look at AdjustStartLength, see if it still throws an error. To be honest, I don't see anyone wanting to trim any of these event types, but I have to assume that it will happen sometime.
Thanks

My system
Genshin Infinity Gaming PC
Motherboard Gigabyte H610M H: m-ATX w/, USB 3.2, 1 x M.2
Power Supply Corsair RM750X
Intel Core i7-13700K - 16-Core [8P @ 3.4GHz-5.4GHz / 8E @ 2.50GHz-4.20GHz]
30MB Cache + UHD Graphics, Ultimate OC Compatible
Case Fan 4 x CyberPowerPC Hyperloop 120mm ARGB & PWM Fan Kit
CPU Fan CyberPowerPC Master Liquid LITE 360 ARGB AIO Liquid Cooler, Ultimate OC Compatible
Memory 32GB (2 x 16GB) DDR5/5200MHz Corsair Vengeance RGB
MSI GeForce RTX 4060 Ti 8GB - Ray Tracing Technology, DX12, VR Ready, HDMI, DP
System drive 1TB WD Black SN770 M.2 NVMe PCIe SSD - 5150MB/s Read & 4900MB/s Write
Storage 2 x 2TB Seagate BarraCuda SATA-III 6.0Gb/s 7200RPM
Windows 11 Home (x64)
Monitors
Generic Monitor (PHL 222V8) connected to GeForce RTX 4060 Ti
Generic Monitor (SAMSUNG) connected to iGPU

Camcorder
SONY Handycam HDR-XR550VE

Jack S wrote on 10/20/2024, 9:51 AM

I've used the myEvent.Takes.Count to test for any of the events that were causing the crash and that's solved the problem. If the count is zero, I bypass the trim code.
Thanks for your help with this. I appreciate it.

My system
Genshin Infinity Gaming PC
Motherboard Gigabyte H610M H: m-ATX w/, USB 3.2, 1 x M.2
Power Supply Corsair RM750X
Intel Core i7-13700K - 16-Core [8P @ 3.4GHz-5.4GHz / 8E @ 2.50GHz-4.20GHz]
30MB Cache + UHD Graphics, Ultimate OC Compatible
Case Fan 4 x CyberPowerPC Hyperloop 120mm ARGB & PWM Fan Kit
CPU Fan CyberPowerPC Master Liquid LITE 360 ARGB AIO Liquid Cooler, Ultimate OC Compatible
Memory 32GB (2 x 16GB) DDR5/5200MHz Corsair Vengeance RGB
MSI GeForce RTX 4060 Ti 8GB - Ray Tracing Technology, DX12, VR Ready, HDMI, DP
System drive 1TB WD Black SN770 M.2 NVMe PCIe SSD - 5150MB/s Read & 4900MB/s Write
Storage 2 x 2TB Seagate BarraCuda SATA-III 6.0Gb/s 7200RPM
Windows 11 Home (x64)
Monitors
Generic Monitor (PHL 222V8) connected to GeForce RTX 4060 Ti
Generic Monitor (SAMSUNG) connected to iGPU

Camcorder
SONY Handycam HDR-XR550VE