Log in

View Full Version : Any timecode manipulation tools?


Blanchimont
14th June 2008, 00:36
Are there any timecode manipulation tools in existence?
I mean ones that are more meant to work with true vfr and single frame editing, rather than those packed in deinterlacers...
I assume there must be, but frankly, I'm not having luck finding any (working ones).

I'm working on an encode with very old source which forced me to revert to manual manipulation of the timecode. Which...is...sloow....

The source was 29.970 fps cfr, pattern nnncc (three progressive, two interlaced, no hybrid but that's obvious based on its age...)

First I used TDeint to deinterlace/decomb with quite good results, and TDecimate afterwards to remove the unnecessary duplicate left after TDeint thus making playback smooth and bringing it down to 23.976 fps.

Then running that script into an uncompressed avi(video only) in VirtualDub.

As it had a lot of duplicate frames (it's anime) I wanted to make it more efficient and turn it into vfr by dropping the duplicates...it's then it turned hard...real hard...

Trying to use DeDup was a big no-no...
Half the frames contain artifacts, jump up/down in relation to each other, have different brightness...
Setting the threshold too low almost no frames get dropped, any higher and it starts dropping frames you want to keep (unless you'd fancy making overrides for half of them but that would effectively defeat the purpose of DeDup...)

Then I though of trying Yatta. As it was already deinterlaced/etc I chose type3 project and divided it into freedecimate sections.
Now, about the timecodes in Yatta, when first loading the avi and creating the project and those sections, it could output the correct timecodes, but after starting to manually drop frames, any attempt to create the timecodes file through Yatta gives back one that isn't in synch with the video...(I guess I'm doing something wrong but I'm failing to see what, perhaps I should have loaded the avi directly instead of through avs?...)

So I decided to manually edit the timecodes file in regards to the dropped frames (it's doable, but as I said, it's painfully slow...). Here's how;

If you drop only one frame, it's pretty straightforward;
(this assumes v2 timecode file)
(A,B = duplicates)

frame A = 85460.31 => frame A = 85460.31
frame B = 85502.02 => (frame decimated, timecode commented)
frame C = 85543.72 => Frame C =85543.72

This makes frame A extend its duration to the beginning of frame C.

(note; you WANT to keep the 'dropped' timestamp commented for debug purposes/sync issue fixing later...)

If two or more duplicates need to be dropped you need to pay a bit more attention as you will need to make sure the remaining frame occupies the right timeslot;
(A, B, C, D = duplicates)

Frame A = 146521.26 (drop)
Frame B = 146562.97 (drop) => commented
Frame C = 146604.67 (keep) => commented
Frame D = 146646.38 (drop) => commented

Note the order? What this does is it makes Frame C (which you want to keep) to occupy the timeslot for all four, from 146521.26 to end of D's duration...

With 50.000+ frames and corresponding timestamps, you're bound to get out of synch from time to time, however my solution is to load the avs generated by Yatta into AegiSub (after commenting out fielddeinterlace) along with the 'hand-edited' timecodes file, and then compare the frames between Yatta and Aegisub... If the framenumber, time, and what you see in the frame, match, then it's in synch... If not, it's a simple thing to narrow it down and fixing it.

But as I stated, editing a timecodes file in notepad and matching it against individual frames is not a fun thing to do... What I want to know if there are any tools that lets you do some of these things in a more automatic fashion? Or if someone could tell how to make Yatta to produce an accurate timecodes file after dropping frames then that would be at least half the victory...
I assume existing programs/functions I've already come across could do some of these tasks, but I've only got few months experience of encoding so I'm still having hard time sometimes figuring out what could be done with what...

It does however have it's points to be able to choose what frames to drop and keep; Once all duplicates have been dropped (through VDub into uncompressed avi again) I'm extracting that avi into bmp images to edit out any remaining source artifacts/adjust brightness in gimp thus less work as there'll be more good frames than otherwise, and afterwards back into avi before encoding it (in megui)...

x264lover
14th June 2008, 23:42
Have you tried the vfr tool?

http://haali.cs.msu.ru/mkv/MatroskaSplitter.exe

Install it and then try running this command:

C:\Program Files\Haali\MatroskaSplitter\mkv2vfr.exe


See u.

Blanchimont
15th June 2008, 03:08
Well, as far as I understand, mkv2vfr creates a timecodes(v1) file(which is later used when muxing it back into a container that supports vfr) from the input and outputs the video as cfr(which if you would view it would appear slow motion/sped up depending on the original framerate), and the source I'm working with (uncompressed avi from a dv2 processed with TDeint/TDecimate) as well as the source DVD is cfr...
So that would be pointless in this case, or am I missing something? Besides mkv won't appear before it's time to mux it into the final encode in megui (remember I'm working with uncompressed avi at this point)...

Even if the source was vfr/hybrid that fact wouldn't matter for avisynth/VDub/megui as they're 'blind' to it(vfr), they just process it(the video, you might want to keep audio separated if you deal with vfr source...). However you will need the original timecodes, or where the processing changes the number of frames I'd rather keep tab of the points of fps changes and write v1 timecodes manually in notepad later(you can find those values/points easily by calculating with the known framecount/times in any media player that let's you advance frame by frame, or a frameserver that respects timecodes(like Aegis) and examining the extracted timecodes should you have them...), for the final encode...
Alternatively you could use directshowsource with 'convertfps=true' and 'fps=23.976' or 29.970 or whatever to convert the framerate to whatever suits you and then deal with encoding(however the motion might become jerky)...
(for v1 timecode to v2, mux it into mkv(mkvmerge) and extract it, for v2 to v1, use convert-timecodes.exe; to get v1 file (from mkv) use mkv2vfr, v2 use mkvextract(part of mkvmerge/toolnix))

What I'm trying to do is create a vfr from cfr source, which I'd normally probably use DeDup for... and which for the reasons named is impossible in this case forcing me to decimate the frames and editing the timecodes file manually...

Anyway, I don't really mind the extra work even though this part will take at least ten days yet (three minutes a day at best...). With the gimp part, it'll probably take whole month before I'm close to the finish line...
Just generally wondering why there are so few tools for true vfr? The concept itself is quite simple after all; a line of frames with set time for each frame to stay on screen...