Single Frame editing. . .

WayneM wrote on 5/13/2011, 7:33 AM
I decided to post this in a new thread, but it came out of the 16mm transfer discussion.

With a transfer of 16mm [SOF] to video, even frame-by-frame, there may be individual frames you want to "Cut and Replace." In my current case the need comes from transfer of a film that was "professionally" cement spliced so along the bottom edge of the frame before the new film segment there is the line from the overlap of film base that had the emulsion scraped off.

What I would like to do is do a frame copy of the frame preceeding the edit-join frame and overwrite the less desirable frame. I don't want to just cut the frame as I have a very tightly synced audio track for this montage of clips.

If there is an easy way to do this with Vegas it is alluding me as trying to do an overlay paste of a single frame seems to add a frame and it is doing things to the already associated audio track. That could be because they are grouped, but I believe I removed the video from the group before my tests.

Reading about some of the clever Open Source tools, I wonder if there is an editor or tweak tool more tuned to the relatively simple changes I want to make to some frames. Either something automatic that could detect a scene change and automatically duplicate the frame one before and edit, or just a visual editor that would allow individual frame copy/paste. Maybe there is even a name for my common problem and a specific solution?

Perhaps there is a list somewhere of the various tools like AVIsynth? I have used VirtualDub years ago. Much of the interesting insights and recommendations about this stuff came from John M.

Wayne

Comments

musicvid10 wrote on 5/13/2011, 8:09 AM
You need to turn off Auto-Ripple first, Ungroup the video from the audio, then select the desired frame, Copy, move the cursor to the beginning of the frame you wish to replace, and Paste it right on top of the old one. Or you can paste to a separate video track above. It's as easy as that.
WayneM wrote on 5/13/2011, 8:36 AM
Thanks, I re-check my settings and try that again.

Auto Ripple. Am I the only person who has had that feature bite their fingers off? :-) I thought it was off but really appreciate you sharing your knowledge. I will give it a shot since I must have something wrong.

I was thinking is the an NLE may not be the right place to do this kind of single-frame editing, so I'm also looking to the open source (OS) tools and have taken John M's referral and registered over at Doom9.

In the five years since I'm been active in digital video it has changed amazingly for the better. I can't believe some of the OS tools and tweaks. Now if I can just trace down a definitive list of the best tool for a specific need and the sources for the tools I'll be all set!
musicvid10 wrote on 5/13/2011, 8:40 AM
Actually, Vegas is very intuitive when doing micro-edits, it's just that you have to tell it not to mess with other stuff.

Be a bit careful and thick-skinned over at Doom9. They have a word for new users there -- "snack."
;?)
WayneM wrote on 5/13/2011, 8:44 AM
Thanks for the heads up about Doom9. So maybe a lot of the Doom FPS (first-person shooter) gamers still hang there :-)
johnmeyer wrote on 5/13/2011, 11:04 AM
If you know how to use scripts, I wrote a script, which I use all the time, which copies the frame preceding the cursor location, and pastes it to the position after the frame location. It cuts the frame after the cursor location prior to pasting so you don't end up with a frame on top of another event: this will work, but heaven help you if you later want to move or edit things and forget to move that single frame. Also, the script groups the single frame with the event immediately before and after the single frame so that no matter what you later do, they will all move together.

The audio track is not moved, cut, or changed by this script.

Simple copy the code below, paste it into Notepad, and then save it with ".js" as the extension.

/** 
* PURPOSE OF THIS SCRIPT:
*
* Fix a bad video frame by deleting bad frame and replacing with previous frame.
*
* A video track must be selected. If an audio track is selected, nothing happens.
*
* To use, select the event that contains the bad frame. Position the cursor so you can
* see the bad frame in the preview window. Then, run the script.
*
* Copyright © John Meyer 2006
* Written: June 23, 2006
*
**/

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;


try {

//Global declarations
var dStart : Double;
var dLength : Double;
var dCursor : Double;
var trackEnum : Enumerator;
var evnt : VideoEvent;
var evnt2 : VideoEvent;
var one_frame = Timecode.FromFrames(1);

var track = FindSelectedTrack(); // Use this function to find the first selected track.

if (track.IsVideo()) { // Proceed only if selected track is video track.
var one_frame = Timecode.FromFrames(1);
var eventEnum = new Enumerator(track.Events);
dCursor = Vegas.Cursor.ToMilliseconds(); // Remember the cursor position.

//Go through each event on the track.
while (!eventEnum.atEnd()) {
evnt = (eventEnum.item());

// Get the event's start and length timecode, in milliseconds.
dStart = evnt.Start.ToMilliseconds();
dLength = evnt.Length.ToMilliseconds();

// If the cursor timecode is between the beginning and end of the
// event timecodes, then split the event, delete first frame from event to right of split.
// Copy last frame from event to left of split and put into the one-frame gap.

if ( (dCursor > dStart) && ( dCursor <= (dLength + dStart) ) ) {
var patch_frame : VideoEvent = VideoEvent(evnt.Copy(VideoTrack(track),Vegas.Cursor));

// Make first frame of new event equal frame to left of cursor (for all takes)
for (var i=patch_frame.Takes.Count - 1; i >= 0; i--) {
patch_frame.Takes[i].Offset = patch_frame.Takes[i].Offset + Vegas.Cursor - one_frame - evnt.Start; // Make change for ALL takes.
}

patch_frame.Start = Vegas.Cursor; // Move new event to right of cursor.
patch_frame.Length = one_frame; // Truncate event to only one frame in length.

evnt.Split (Vegas.Cursor - evnt.Start);

// Next several lines truncate start of NEXT event by one frame.
eventEnum.moveNext(); // Go to next event on this timeline.
evnt2 = VideoEvent(eventEnum.item()); // Get next event.
evnt2.AdjustStartLength(evnt2.Start+one_frame, evnt2.Length-one_frame, true);

if (evnt.IsGrouped) { // Add new events to existing grouping.
var grp : TrackEventGroup = evnt.Group;
grp.Add(evnt2);
grp.Add(patch_frame)
}

} // End if dCursor ...

eventEnum.moveNext(); // Go to next event on this timeline.

} // End While

} // End If Track

else {
MessageBox.Show("You must select a video track.");
}

} catch (e) {
MessageBox.Show(e);
}

// End of main program



// Beginning of functions

function FindSelectedTrack() : Track {
trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
if (track.Selected) {
return track;
}
trackEnum.moveNext();
}
return null;
}


WayneM wrote on 5/13/2011, 5:04 PM
Thanks much John.

I put the script in and ran it at a transition. At first I thought it hadn't worked, then I saw the inserted frame had a full frame fade insert. Maybe there is an option I need to fix.

On this one test I actually need to replace two frames. I'm going to peek at the code, which ain't my forte :-) and see if I can figure out how to make another version where I put the cursor between two "bad" frames and have it pull frames two frames to the right and left to replace the adjacent frames, if that makes any sense.

I tried just moving the cursor one frame to the right after the first replace, which worked fine, but it doesn't want to repeat the dupe of the single frame it just put in.
YAUN wrote on 10/2/2014, 9:12 PM
Ya know, there is a lot of old stuff on the Internet. A lot of it is, well, old, and fundamentally useless. Then you find "old" stuff that's an absolute gem. Thank you, Mr. Meyer for the Single Frame Edit script. Made doing exactly what was needed to do a breeze. And I especially like the keeping it all together feature: nice! Thanks again.
johnmeyer wrote on 10/2/2014, 11:00 PM
Thank you!!
DrLumen wrote on 10/2/2014, 11:57 PM
// Nice reminders!

Cool stuff. Thanks.

intel i-4790k / Asus Z97 Pro / 32GB Crucial RAM / Nvidia GTX 560Ti / 500GB Samsung SSD / 256 GB Samsung SSD / 2-WDC 4TB Black HDD's / 2-WDC 1TB HDD's / 2-HP 23" Monitors / Various MIDI gear, controllers and audio interfaces

johnmeyer wrote on 10/3/2014, 4:41 PM
I forgot to mention that since posting that script, I've developed an AVISynth script that will take the video that results from replacing bad frames with the preceding frame(s), and will then take the repeated frame and create a motion estimated "synthesized" frame. This eliminates the slight "hiccup" you get from the repeated frame. The results are often indistinguishable from what the original video (or film) would have looked like if the frame was still intact.

It is great for replacing photographer's flashes, bad splices, dropouts, etc.

This shows the result of using this technique about 100 times in a few seconds of very damaged film: