Quickly Truncate Original Source Media - How To?

Mikee wrote on 12/19/2015, 3:08 PM
Basically, when viewing video source media (AVCHD and MP4) in the Trimmer, I'd like to permanently clip/truncate a section from the original source file and permanently discard it, never to see it again. Any efficient ways of doing this?

Ideally:
- it'll be simple and quick
- pick a section of the media via highlighting it
- truncation doesn't modify the source date create/modified dates
- the duration is updated in the media manager

Scenario:
Wife records long hunk of video (eg 30 seconds). I want to keep 3 seconds in the middle. I'm keeping the media long term, so I'd rather not waste the HD space, yet I don't want to waste more than five seconds truncating the video.

Comments

john_dennis wrote on 12/19/2015, 3:36 PM
The forum members need to know the type of video and audio you're shooting to say anything meaningful.

What kind of camera?

DV, HDV, AVCHD, MP4, MOV?

This thread is a current attempt at just that type of thing.
Mikee wrote on 12/19/2015, 4:24 PM
Original post updated (AVCHD, MP4). Thanks for the idea...I kinda figured I'd have to roll a custom script or the like...those seem like a good starting point.
PeterDuke wrote on 12/19/2015, 6:03 PM
You might look at VideoRedo (TVsuite or Pro versions) to trim AVC coded clips without unnecessary recoding. That is just what it is designed to do.
musicvid10 wrote on 12/19/2015, 6:11 PM
Vegas would need to re-encode your source.
A muxer as suggested above is the way to pre-trim Long-GOP source.
Mikee wrote on 12/19/2015, 7:59 PM
Answering my own question, since I got sick of editing video and needed to write some proof on concept code.

Theory:
Use TXMuxer http://www.videohelp.com/software/tsMuxeR (on a ACVHD file only.) Txmuxer seems to have a clipping function that seems to skip recoding.

Trying to make it quick for myself:
1) In trimmer, create subclip, name it "z"
2) Hit keyboard shortcut to run my hacky script below.
3) script searches media pool for media named "z".
4) script uses the start/length properties of the subclip. Build a file to feed to txmuxer that it can digest with proper params.
5) Wait a few moments (seems to depend on the speed of my disk)
6) Txmuxer outputs file.
7) Do some renaming/moving.
8) Run a SQL update query on media manager.
9) Profit.

NOTE - script is not complete. Doesn't do 7/8/9.

warning, cobbled-together in 1 hour code ahead

using System;
using System.IO;
using System.Windows.Forms;
using System.Text;
using System.Collections;
using System.Windows.Forms;
using System.Globalization;
using System.Diagnostics;
using Sony.Vegas;

class EntryPoint
{
public void FromVegas(Vegas vegas)
{

foreach (Media media in vegas.Project.MediaPool)
{
// only add the effect if the media object has video
if (!media.HasVideo())
continue;

//first, create a subclip named "z"
//probably only works with MTS files
if (media.IsSubclip() && media.FilePath == "z")
{
Subclip s = (Subclip)media;
Media parent = s.ParentMedia;
//MessageBox.Show(parent.FilePath + " " + s.Start.ToMilliseconds().ToString() + " " + s.Length.ToMilliseconds().ToString());

//dunno if this is all right
string muxtemplate = string.Format(@"MUXOPT --no-pcr-on-video-pid --new-audio-pes --vbr --cut-start={1}ms --cut-end={2}ms --vbv-len=500
V_MPEG4/ISO/AVC, ""{0}"", insertSEI, contSPS, track=4113
A_AC3, ""{0}"", track=4352", parent.FilePath, s.Start.ToMilliseconds(), s.Start.ToMilliseconds() + s.Length.ToMilliseconds()); //probably some track= params here may not work for every file.

//MessageBox.Show(muxtemplate);

string muxfilename = @"E:\Vegas\Scripting\tsMuxeR\muxtemplate.meta";
File.WriteAllText(muxfilename, muxtemplate);

//fire the tsmuxer process
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = false;
psi.FileName = @"E:\Vegas\Scripting\tsMuxeR\tsMuxeR.exe";
psi.Arguments = muxfilename + @" C:\temp\foo.ts"; //TODO: move this the source directory, overwrite chubby media, and hope this didn't screw up royally
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;
Process p = new Process();
p.StartInfo = psi;
p.Start();
string line = string.Empty;
while (!p.StandardOutput.EndOfStream)
{
line += p.StandardOutput.ReadLine();
}
MessageBox.Show(line);

if (p.ExitCode == 0)
{
MessageBox.Show("clipped clip created");
MediaPool mp = vegas.Project.MediaPool;
MessageBox.Show(s.KeyString);
//mp.Remove(s.KeyString); //remove the "z" subclip
}
else
{
MessageBox.Show("boom");
}

//move the file around, update media manager SQL database,
//SQL: update property set valuelong=SOMENUMBERTHATLOOKSLIKEMICROSECONDS where itemid=(select itemid from item where fullpath='the media path') and propertytypeid=34 ---34 is the duration property
//probably no way to refresh MM programmatically
//probably can do some creative file management to rename the original file safely, etc.

return;



}

}
}

}

wwaag wrote on 12/19/2015, 8:11 PM
The latest version of Vegasaur (2.4) supports Smart Trimming. Worth a try to see if it works for your footage. It makes use of FFmpeg.

wwaag

AKA the HappyOtter at https://tools4vegas.com/. System 1: Intel i7-8700k with HD 630 graphics plus an Nvidia RTX4070 graphics card. System 2: Intel i7-3770k with HD 4000 graphics plus an AMD RX550 graphics card. System 3: Laptop. Dell Inspiron Plus 16. Intel i7-11800H, Intel Graphics. Current cameras include Panasonic FZ2500, GoPro Hero11 and Hero8 Black plus a myriad of smartPhone, pocket cameras, video cameras and film cameras going back to the original Nikon S.

Mikee wrote on 12/19/2015, 8:18 PM
Thanks wwaag. I'm a long time Vegas User, but only use it 40hrs a year or less for a yearly personal project...so I won't invest the dollars....though I should to save my time! ...The scripting is fun though.
wwaag wrote on 12/19/2015, 10:16 PM
The scripting is fun though.

Agreed. Here is a thread (actually current) that you may find of interest. http://www.sonycreativesoftware.com/forums/showmessage.asp?messageid=932826

wwaag

AKA the HappyOtter at https://tools4vegas.com/. System 1: Intel i7-8700k with HD 630 graphics plus an Nvidia RTX4070 graphics card. System 2: Intel i7-3770k with HD 4000 graphics plus an AMD RX550 graphics card. System 3: Laptop. Dell Inspiron Plus 16. Intel i7-11800H, Intel Graphics. Current cameras include Panasonic FZ2500, GoPro Hero11 and Hero8 Black plus a myriad of smartPhone, pocket cameras, video cameras and film cameras going back to the original Nikon S.

astar wrote on 12/20/2015, 2:29 AM
In Vegas select the 3 seconds, and render the 3 secs to a new file matching the original format. You could also move the clip to an intermediate codec that will reduce the generational loss. No way in Vegas to get around the date time issue.

If you are skilled with FFMPEG, you can create a command to copy the section you want via time index. This will keep you from suffering generational loss, if it even matters.

Speed of these operations is determined by your PC performance.