Log in

View Full Version : Create VFR from Avisynth


jmac698
1st August 2012, 18:20
In Avisynth, with the FFMS2 source plugin, there's an option to write a timecodes file. I would then open my various clips in different framerates, join them together, and play through once, linearly.

I suppose I have to do that in one pass, then in another pass send the actual video to mkvtoolnix? together with the timecodes.txt.

Is this about right?
Or totally wrong?

sneaker_ger
1st August 2012, 18:43
What do you want to do exactly?

TheFluff
1st August 2012, 19:09
Timecodes are written when indexing is finished, which, in the Avisynth plugin case, means that they're written upon script creation, not during frame requests. Use the commandline indexer tool if you just want the timecodes and don't care about the video.

jmac698
1st August 2012, 20:59
Hmm.. ok, I want to encode to a VFR file. I've never done this.
I have one source at 24p, a 2nd source at 30p.
The sources have been processed in an Avisynth script.
I want to join the two sources together into a final (and lossles) VFR file. I assume this would be the MKV container format with the codec of my choice, which is HuffyUV.
The sources are being trimmed in Avisynth.

There's immediately a program here, because the timecodes for the entire file are written. How do I edit this? Is the only way to edit the clip exactly first?

sneaker_ger
1st August 2012, 21:20
Just two parts (which are CFR) and only trimmed?
Should be easy. Load and trim both of them in AviSynth, then append them (use AssumeFPS() on the second part to make it the same fps as the first part, then use the ++ operator).
Then create a timecodes_v1 (http://www.bunkus.org/videotools/mkvtoolnix/doc/mkvmerge.html#mkvmerge.external_timecode_files) file manually and load it into the muxing application (e.g. mkvmerge).

TheFluff
1st August 2012, 21:21
I don't understand the question at all.
A general hint, though: if you know the framerate of the respective input clips beforehand and you're not doing too many edits, I strongly suggest you write your own v1 timecodes file by hand instead of trying to process the timestamps generated by FFMS2.

jmac698
1st August 2012, 21:42
@sneaker_ger,
Yes I think that's it.

#final.avs
v1=ffvideosource()#24fps
v2=ffvideosource()#30fps
file1in=0
file1out=999
file2in=500
file2out=1499
v1=v1.trim(file1in,file1out)
v2=v2.trim(file2in,file2out)
v2=v2.assumefps(v1.framerate)
#feed to mkvmerge ... --timecodes 0:timecodesv1.txt final.avs
WriteFile("F:\timecodesv1.txt", "" "assume 29.970029" "","0","file1out-file1in","file1out+1","file2out-file2in+file1out+1" "")#this is probably wrong
v1++v2


# timecode format v1
assume 29.970029
0,999,23.976023
1000,1999,29.970029

Do the frames start at 0? Do you know how to do the quotes on writefile and are the calculations right?
I just realized mkvmerge is probably not an encoder. I suppose it would see an *.avs as an uncompressed file. I can encode the *.avs first and feed to mkvmerge, or re-encode the *.mkv.

sneaker_ger
1st August 2012, 22:10
Are you sure about file2in being 1000? Note that the frame count at this point only refers to the second part, not yet the appended result. The last line would also be wrong, then.
"v2=assumefps(v1.framerate)" should be "v2=v2.assumefps(v1.framerate)"
Also needs v1++v2 and you probably also want to cut the audio and not just the video. (But do not change the audio when doing assumefps)

For the timecode_v1 file you can delete all lines that are the same as the "assume" line.

You cannot feed avs to mkvmerge, of course. You need to encode the script with e.g. VirtualDub to HuffyUV first.

jmac698
1st August 2012, 22:22
>Are you sure about file2in being 1000?
Yes I realize that, but perhaps you didn't see my edit where I made a comment to point that out. I've since chosen a different example to make this clear.

>You cannot feed avs to mkvmerge, of course
Well, usually avs appears as a virtual file, but if not there's some kind of proxy method, called a frameserver. But anyhow I can use the easier method.

That's great! Can't wait to try it out. I'm glad I've learned this now, but the whole purpose was to test VFR on YouTube. I can test this soon.

Overdrive80
4th August 2012, 11:56
Maybe it help you http://forum.doom9.org/showthread.php?t=165287