View Full Version : DirectShowSource and VFR
Wilbert
4th March 2005, 00:23
Someone modified DSS (as external plugin) to properly handle VFR in some way. I haven't looked at it, so I'm not really sure how it works yet ...
The DirectShowSource source filter for AviSynth is very useful and powerful: it can read most formats that Windows Media Player supports. The filter enable us to convert, into other formats, Windows Media Video (WMV), Advanced Systems Format (ASF), Real Media (RM) files, etc. which are not supported by VirtualDub (RealMediaSpliter is necessary for reading RM files).
However, current DirectShowSource source filter has a weak point: it cannot handle video streams which use Variable Frame Rate (VFR). Some codecs such as WMV and RM employ VFR technique for higher compression. It causes problems to read VFR files with DirectShowSource, but we have no way to read such files with AviSynth.
The root of this problem is that frame rate of a source stream is variable although AviSynth only supports constant frame rate. It turns out that the problem will be solved only if the DirectShowSource source filter output a proper frame for a given frame number.
"DirectShowSource with ConvertFPS" is a patch to the official DirectShowSource filter to add a routine for frame rate conversion: it determines the position of the #n frame base on media time information and therefore forces to handle VFR files properly.
http://nyaochi.sakura.ne.jp/xoops/modules/mydownloads/index.php
tritical
4th March 2005, 08:04
It looks like an easy way to convert a vfr stream to a cfr stream. Say if you have a vfr file that has a mix of 29.970 and 23.976 it can convert it to 119.88 fps cfr by using directshowsource("file",fps=119.88,convertfps=true). It will duplicate frames in the 23.976 sections 5 times and frames in the 29.970 sections 4 times. Previously you would have had to extract the timecodes separately and then use trim() statements to apply changefps() on each section with a different fps, at least for vfr mkv files.
sh0dan
4th March 2005, 16:23
Looked through the patch, and it seems rather safe to apply and include this in the AviSynth distribution.
Wilbert
4th March 2005, 23:49
Forgive me my ignorance. How do I make those 120 fps?
I got a mkv_vfr somewhere (the famous startrek one), but if I encode straight to XviD (using that modified DSS), I get indeed a clip of 119.88 fps.
But if I play it in WMP or Zoomplayer it plays at ~75 fps (instead of 23.976 and 29.97). So, it doesn't seem to drop frames. Should I use some special setting when setting up the encoder?
lamer_de
5th March 2005, 14:55
Forgive me my ignorance. How do I make those 120 fps?
There's some sort of explanation on how tocreate them in this thread:
http://forum.doom9.org/showthread.php?s=&threadid=49561&highlight=avi60
You need avi60 and some other tools. Most of the documentation is only available in Japanese, though. You definitely can't feed a 120fps stream to vdub and expect it to drop frames on its own.
CU,
lamer_de
Wilbert
5th March 2005, 15:50
You need avi60 and some other tools. Most of the documentation is only available in Japanese, though. You definitely can't feed a 120fps stream to vdub and expect it to drop frames on its own.
Ok, I tried this succesfully.
So how do you use this modified DSS to convert mkv+vfr to something else (meaning mkv_vfr or avi_120+drop_frames)?
lamer_de
5th March 2005, 16:32
As far as I understood it, you don't. It's meant to convert vfr to cfr.
So you use dss to get a "true" 120fps stream and decimate that down to 23.976 or 29.970 (or whatever framerate most of the content is in).
Before the patch, dss would always deliver all frames sequentially and therefore messing up the timecodes. So if you entered 120fps before, it would give you 120 different frames, which would've resulted in a 5xspeedup (assuming most of the source was 24fps, as dss skips the dropframes). At the same time, it would've kept the times from the original source though, so after 1/5th of the time, you only get the last frame feed to vdub. This makes a decimation impossible. Now it gives you 1 frame plus 4 duplicates. (At least that's the way I understood it, I hadn't had time to try this patched dss yet)
I hope I got this point across, kinda hard to describe :scared:
CU,
lamer_de
Actually, in this case, there wouldn't so much as in duplicates but in blended frames, as it is done with ConvertFPS rather than ChangeFPS; this would actually give you "new" frames.
A DSS with ChangeFPS would be better and more ideal.
What this does is making vfr source much more usable with less hassle. Previously it would require you to identify and trim out the different sections, make them into the same framerate and feed a cfr into vdub. Now it removes the first (two) steps (ChangeFPS would be much better in this aspect).
Wilbert
5th March 2005, 19:15
Actually, in this case, there wouldn't so much as in duplicates but in blended frames, as it is done with ConvertFPS rather than ChangeFPS; this would actually give you "new" frames.
Hmmm. So, that's the reason that everything is detected as non-film (after decimation)?
DirectShowSourceVFR_DirectShowSource("F:\Guides\Hybrid\vfr_startrek.mkv", fps=119.88, convertfps=true)
Decimate(4).Decimate(3).Decimate(2)
Decomb521VFR_Decimate(mode=4, threshold=1.0, progress=true, timecodes="F:\Guides\Hybrid\timecodes2.txt",
vfrstats="F:\Guides\Hybrid\video.vfrstats", show=true)
It doesn't work anyway, when playing this (with show=false) it is stuck after 99%.
A DSS with ChangeFPS would be better and more ideal.
I have no idea how to do that. Perhaps Sh0dan can look at this?
tritical
5th March 2005, 21:02
lamer_de is correct. Also, this patch doesn't actually use any internal function (changefps or convertfps). convertfps is just the name of the parameter the person added. The method comes out acting like changefps, i.e. there are no blends.
Originally posted by tritical
convertfps is just the name of the parameter the person added. The method comes out acting like changefps, i.e. there are no blends.
Ah, marvelous :)
This tells me to test the plugin before making a fool of myself next time. :o
thuongshoo
18th July 2006, 12:33
I read VFR page on AviSynth-wiki's site.
http://www.avisynth.org/mediawiki/wiki/VariableFrameRateVideo
I also read as "TIVTC Common Usage Examples.txt" says
pass 1
DirectShowSource("c:\video.wmv", fps = 30 , audio= false , convertfps = true )
tfm(output="matches.txt")
tdecimate(mode=4,output="metrics.txt")
Run this pass by Megui
pass 2
DirectShowSource("c:\video.wmv", fps = 30 , audio= false , convertfps = true )
tfm(input="matches.txt")
tdecimate(mode=5,hybrid=2,vfrDec=1,input="metrics.txt",tfmIn="matches.txt",mkvOut="mkv-timecodesfile.txt")
Encode by Megui
For MPEG file , I add "d2v=.." for tfm .
If I do like this, Will I have a VFR video ?
thank you !
foxyshadis
18th July 2006, 13:08
Unless the wmv is telecined, you don't need tfm though, so you can leave out tfmin from tdecimate. Did I write that? >.> Oh no, good, but I did forget input="tfm.txt", thanks. Usually you'd only use tfm for mpeg-2 and the occasional interlaced xvid.
You might want to check if the wmv is 29.97 or 30fps, it's not huge but it makes a small difference.
Otherwise yes! Remember that these aren't encoding passes though, you have to run 1st and 2nd encoding pass both off the second avisynth script.
thuongshoo
19th July 2006, 07:05
The Wiki guide only discuss about 24/30-material . Some MV are blend by 15 fps and 8 fps . I want to have a method for all case . Actually I don't use above scripts .
At the first, I use MEgui to analyse my MV(wmv, mpeg,....)
And then, I insert these Avisynth commnand into script which is created by Megui. So I sure that MV is inverse-telecined if this thing is necessary .....
foxyshadis
19th July 2006, 13:00
TIVTC only works well on 24/30 hybrid, or 24/30 in 120. If it's anything other than a 1-in-5 decimation, TIVTC doesn't support it, nor does decombvfr to the best of my knowledge. (It's too bad, I'd love it to identify patterns to eliminate judder entirely.) Dedup won't shift frame times, although it'd be a very cool mod if I could figure out how to do it.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.