View Full Version : vspreview: Wrong Length in Time, part 3
jay123210599
4th January 2025, 15:57
I think I finally found a solution to my problem. When I insert my video to VirtualDub2, it inserted duplicate frames where timestamps have gaps to convert variable frame rate videos to constant frame rate. How do I do that in vspreview?
poisondeathray
4th January 2025, 17:22
I think I finally found a solution to my problem. When I insert my video to VirtualDub2, it inserted duplicate frames where timestamps have gaps to convert variable frame rate videos to constant frame rate. How do I do that in vspreview?
Convert VFR to CFR
https://github.com/Irrational-Encoding-Wizardry/Vapoursynth-VFRToCFR
jay123210599
4th January 2025, 21:37
Convert VFR to CFR
https://github.com/Irrational-Encoding-Wizardry/Vapoursynth-VFRToCFR
How do I use it with vspreview?
_Al_
5th January 2025, 04:32
You do not use it with vspreview. You have to stop that nonsense that blocks you to reason yourself. :-)
You are constructing a vapoursynth/python script. The needed line for vapoursynth script is on that page you were recommended.
All you need is to have:
-download that dll that you find on release page and put it in vapoursynth/plugin directory
-come up with a clip in vapoursynth using a source plugin
-timecode filepath, that some source plugin can make, not sure now, I thing ffms2 (look in options) or some other app.
After you construct your vapoursynth/python script, you choose vspreview, OR ANY OTHER vapoursynth previewer, and play that script's set output.
jay123210599
5th January 2025, 16:08
@poisondeathray Do you know how to make or write the timecode filepath for the timecodes?
poisondeathray
5th January 2025, 16:10
@poisondeathray Do you know how to make or write the timecode filepath for the timecodes?
You can extract timecodes with mkvextract. There are instructions in the mkvtoolnix documentation. Timecodes are sometimes called "timestamps" - they refer to the same thing
jay123210599
5th January 2025, 19:01
After you construct your vapoursynth/python script, you choose vspreview, OR ANY OTHER vapoursynth previewer, and play that script's set output.
Wait, vspreview can open script .vpy files? How?
poisondeathray
5th January 2025, 19:56
Wait, vspreview can open script .vpy files? How?
Which "vspreview" are you referring to ?
The "job" of vs-preview is to open (preview) .vpy scripts
https://github.com/Jaded-Encoding-Thaumaturgy/vs-preview
standalone previewer for VapourSynth scripts
https://github.com/Jaded-Encoding-Thaumaturgy/vs-preview#usage
Usage
It can be used by running vspreview script.vpy
_Al_
5th January 2025, 20:28
Yes, there are more versions , from original author, and some fork as well? Guessing that Jaded-Encoding-Thaumaturgy fork, but it might be the same with original version.
There is always a chance that a docs directory is included od github website, written by author, if not in detail on that main page, so you dig in its structure, finding this page:
https://github.com/Jaded-Encoding-Thaumaturgy/vs-preview/tree/master/docs/installation
There is a detail workflow how to use it with notepad++, vim and Visual Studio Code. Where if you have any of those, you can associate *.vpy extension to run it from within those softwares.
Or you use some other software for editing, you can look into manual for that software how to associate execution of that created text file/ your script to what executable.
That could be done using other editors out there.
Or you can just use command line: python vspreview script.vpy, I guess that would work as well
Or you can use a python editor, like Pycharm, my favourite, but not straight forward, especially starting it first time to set up things or IDLE, simple, easy to start first time.
Naming your file script.py (not vpy), and juat runnin a command line using that edited script after saving it first.
Dedicated python editors are custom tailored to python language and you can see many corrections and hints what to do, what is wrong , mainly advanced versions, especially PyCharm. But you'd have to give it a time to start with PyCharm.
jay123210599
6th January 2025, 01:52
Which "vspreview" are you referring to ?
The "job" of vs-preview is to open (preview) .vpy scripts
https://github.com/Jaded-Encoding-Thaumaturgy/vs-preview
https://github.com/Jaded-Encoding-Thaumaturgy/vs-preview#usage
No, sorry, I mean can it open other .vpy scripts containing videos alongside my other videos?
poisondeathray
6th January 2025, 02:35
No, sorry, I mean can it open other .vpy scripts containing videos alongside my other videos?
If you mean "alongside" as in "side by side", use StackHorizontal
http://www.vapoursynth.com/doc/functions/video/stackvertical_stackhorizontal.html
You don't need to open a vpy, you can reference the video(s) directly with source filter(s)
If you wanted to import a vpy directly , you could use SourceFileLoader
https://forum.doom9.org/showthread.php?t=175098
All this is done in the script. vs-preview is just a preview for the script (that's it's main job)
jay123210599
6th January 2025, 02:52
If you mean "alongside" as in "side by side", use StackHorizontal
http://www.vapoursynth.com/doc/functions/video/stackvertical_stackhorizontal.html
You don't need to open a vpy, you can reference the video(s) directly with source filter(s)
If you wanted to import a vpy directly , you could use SourceFileLoader
https://forum.doom9.org/showthread.php?t=175098
All this is done in the script. vs-preview is just a preview for the script (that's it's main job)
I mean like this:
clip1 = core.lsmas.LWLibavSource(r"path to clip1.mkv")
clip2 = core.lsmas.LWLibavSource(r"path to clip2.mkv")
clip3 = core.lsmas.LWLibavSource(r"path to vfr to cfr.vpy")
poisondeathray
6th January 2025, 02:59
I mean like this:
clip1 = core.lsmas.LWLibavSource(r"path to clip1.mkv")
clip2 = core.lsmas.LWLibavSource(r"path to clip2.mkv")
clip3 = core.lsmas.LWLibavSource(r"path to vfr to cfr.vpy")
Yes.
If you want to stack them side by side by side, use StackHorizontal. They must be the same dimensions and pixel format, otherwise you have to convert them in the script so they share common characteristics before stacking
e.g
stack = core.std.StackHorizontal([clip1,clip2,clip3])
stack.set_output()
_Al_
6th January 2025, 05:24
As was recomended, you'd need SourceFileLoade. It is possible to use just module attributes or other ways, but most comfortable is using that SourceFileLoader.
Last post in that link, regarding SourceFileLoader, Selurs post, that was provided explains that. Just the end is a bit different, because vs.get_output() gets VideoOutputTuple object now in latest vapoursynth versions, that post is much older. Now, that vs.get_output() has three items (clip, alpha, alt_output),
so to get clip, you'd need something:
import vapoursynth as vs
from vapoursynth import core
from importlib.machinery import SourceFileLoader
clip1 = core.lsmas.LWLibavSource(r"path to clip1.mkv")
clip2 = core.lsmas.LWLibavSource(r"path to clip2.mkv")
SourceFileLoader("my_clip", r"path to vfr to cfr.vpy").load_module()
clip3 = vs.get_output().clip
stack = core.std.StackHorizontal([clip1,clip2,clip3])
stack.set_output()
poisondeathray
6th January 2025, 05:31
Whoops - I meant use the filter(s) directly in the same script (whatever you used in "path to vfr to cfr.vpy")
clip1 = core.lsmas.LWLibavSource(r"path to clip1.mkv")
clip2 = core.lsmas.LWLibavSource(r"path to clip2.mkv")
clip3 = core.lsmas.LWLibavSource(r"path to clip3.mkv")
clip3 = vfrtocfr.VFRToCFR(clip3....)
clip3 = #whatever other filters like resize etc....
stack = core.std.StackHorizontal([clip1,clip2,clip3])
stack.set_output()
jay123210599
6th January 2025, 06:22
@poisondeathray @_Al_ I do not want to stack them horizontally or vertically, I just want to open the vfr to cfr script inside vspreview the same way you open a video inside it.
poisondeathray
6th January 2025, 06:45
@poisondeathray @_Al_ I do not want to stack them horizontally or vertically, I just want to open the vfr to cfr script inside vspreview the same way you open a video inside it.
Use it directly
clip = core.lsmas.LWLibavSource(r'video.mkv')
clip = core.vfrtocfr.VFRToCFR(clip, timecodes=r'yourtimecodes.txt' ,fpsnum=30000, fpsden=1001)
clip.set_output()
You probably want fpsnum=30000, fpsden=1001 for VFRtoCFR for that specific case
ffms2 can do CFR conversion too using fpsnum,fpsden, but I think it's slightly less accurate in some cases. This will be what vdub2 is doing
clip = core.ffms2.Source(r'video.mkv', fpsnum=30000, fpsden=1001)
clip.set_output()
jay123210599
6th January 2025, 07:59
Use it directly
clip = core.lsmas.LWLibavSource(r'video.mkv')
clip = core.vfrtocfr.VFRToCFR(clip, timecodes=r'yourtimecodes.txt' ,fpsnum=30000, fpsden=1001)
clip.set_output()
You probably want fpsnum=30000, fpsden=1001 for VFRtoCFR for that specific case
ffms2 can do CFR conversion too using fpsnum,fpsden, but I think it's slightly less accurate in some cases. This will be what vdub2 is doing
clip = core.ffms2.Source(r'video.mkv', fpsnum=30000, fpsden=1001)
clip.set_output()
They both worked! I finally got the correct number of frames! Thanks for everything!
_Al_
6th January 2025, 09:46
I just want to open the vfr to cfr script inside vspreview the same way you open a video inside it.
You make a vapoursynth script, any script, with whatever in it, with whatever source, whatever filtering, it could be 1000 lines long. As long as you set somewhere inside of that script output using:
whatever_clip.set_output(), you can load it in vspreview because vspreview just looks for that thing. It does nothing else, it just loads that vapoursynth output in your script. It might read some clip props or even more, not sure now, but that is the basic.
Btw. (even though never tested vspreview) I might have seen some images somewhere, you can load more index outputs and compare them there just changing indexes. For example trying:
clip1 = core.lsmas.LWLibavSource(r"path to clip1.mkv")
clip2 = core.lsmas.LWLibavSource(r"path to clip2.mkv")
clip3 = core.lsmas.LWLibavSource(r"path to clip3.mkv")
clip3 = vfrtocfr.VFRToCFR(clip3....)
clip3 = #whatever other filters like resize etc....
clip1.set_output()
clip2.set_output(1)
clip3.set_output(2)
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.