Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 4th January 2025, 15:57   #1  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 324
vspreview: Wrong Length in Time, part 3

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?

Last edited by jay123210599; 4th January 2025 at 16:02.
jay123210599 is offline   Reply With Quote
Old 4th January 2025, 17:22   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,600
Quote:
Originally Posted by jay123210599 View Post
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-Encodi...synth-VFRToCFR
poisondeathray is offline   Reply With Quote
Old 4th January 2025, 21:37   #3  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 324
Quote:
Originally Posted by poisondeathray View Post
How do I use it with vspreview?
jay123210599 is offline   Reply With Quote
Old 5th January 2025, 04:32   #4  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 364
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.
_Al_ is offline   Reply With Quote
Old 5th January 2025, 16:08   #5  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 324
@poisondeathray Do you know how to make or write the timecode filepath for the timecodes?
jay123210599 is offline   Reply With Quote
Old 5th January 2025, 16:10   #6  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,600
Quote:
Originally Posted by jay123210599 View Post
@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
poisondeathray is offline   Reply With Quote
Old 5th January 2025, 19:01   #7  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 324
Quote:
Originally Posted by _Al_ View Post
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?
jay123210599 is offline   Reply With Quote
Old 5th January 2025, 19:56   #8  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,600
Quote:
Originally Posted by jay123210599 View Post
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-Th...rgy/vs-preview
Quote:
standalone previewer for VapourSynth scripts
https://github.com/Jaded-Encoding-Th...-preview#usage
Quote:
Usage
It can be used by running vspreview script.vpy
poisondeathray is offline   Reply With Quote
Old 5th January 2025, 20:28   #9  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 364
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-Th...s/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.
_Al_ is offline   Reply With Quote
Old 6th January 2025, 01:52   #10  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 324
Quote:
Originally Posted by poisondeathray View Post
Which "vspreview" are you referring to ?

The "job" of vs-preview is to open (preview) .vpy scripts

https://github.com/Jaded-Encoding-Th...rgy/vs-preview


https://github.com/Jaded-Encoding-Th...-preview#usage
No, sorry, I mean can it open other .vpy scripts containing videos alongside my other videos?

Last edited by jay123210599; 6th January 2025 at 02:07.
jay123210599 is offline   Reply With Quote
Old 6th January 2025, 02:35   #11  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,600
Quote:
Originally Posted by jay123210599 View Post
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/funct...orizontal.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)
poisondeathray is offline   Reply With Quote
Old 6th January 2025, 02:52   #12  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 324
Quote:
Originally Posted by poisondeathray View Post
If you mean "alongside" as in "side by side", use StackHorizontal
http://www.vapoursynth.com/doc/funct...orizontal.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:

Code:
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")
jay123210599 is offline   Reply With Quote
Old 6th January 2025, 02:59   #13  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,600
Quote:
Originally Posted by jay123210599 View Post
I mean like this:

Code:
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
Code:
stack = core.std.StackHorizontal([clip1,clip2,clip3])

stack.set_output()
poisondeathray is offline   Reply With Quote
Old 6th January 2025, 05:24   #14  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 364
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:

Code:
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()

Last edited by _Al_; 6th January 2025 at 05:27.
_Al_ is offline   Reply With Quote
Old 6th January 2025, 05:31   #15  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,600
Whoops - I meant use the filter(s) directly in the same script (whatever you used in "path to vfr to cfr.vpy")

Code:
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()
poisondeathray is offline   Reply With Quote
Old 6th January 2025, 06:22   #16  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 324
@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.
jay123210599 is offline   Reply With Quote
Old 6th January 2025, 06:45   #17  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,600
Quote:
Originally Posted by jay123210599 View Post
@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

Code:
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

Code:
clip = core.ffms2.Source(r'video.mkv', fpsnum=30000, fpsden=1001)
clip.set_output()
poisondeathray is offline   Reply With Quote
Old 6th January 2025, 07:59   #18  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 324
Quote:
Originally Posted by poisondeathray View Post
Use it directly

Code:
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

Code:
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!
jay123210599 is offline   Reply With Quote
Old 6th January 2025, 09:46   #19  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 364
Quote:
Originally Posted by jay123210599 View Post
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:
Code:
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)

Last edited by _Al_; 6th January 2025 at 09:48.
_Al_ is offline   Reply With Quote
Reply

Tags
vapoursynth, video comparison, video player

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:29.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.