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. |
14th June 2020, 23:28 | #1 | Link |
Registered User
Join Date: May 2011
Posts: 321
|
Preview for Vapoursynth scripts as python module
view.py is a python script/module for Python/vapoursynth scripts that previews VideoNode (clip) on screen.
It is a pythonic solution to play or compare vapoursynth clips by using opencv module. For windows, linux. In theory it should work on Mac as well, but keybindings might need to be fixed. More about that on github. links and instruction on github simple usage: Code:
import vapoursynth as vs from view import Preview clip = vs.core.lsmas.LibavSMASHSource('source.mp4') Preview(clip) Code:
import vapoursynth as vs from view import Preview clip = vs.core.lsmas.LibavSMASHSource('source.mp4') changed_clip = clip.std.Expr(['x 20 -','','']) #darken luma Preview([clip, changed_clip]) KEYBINDINGS: Code:
MOUSE LEFT DOUBLECLICK zooms in 2x, centers on mouse position 'Z' - same as above, zooms in 2x as well, again centers on mouse position MOUSE LEFT CLICK and MOVE initiates crop mode, selecting rectangle with mouse, confirm it with ENTER KEY or doubleclick inside of selected area or mouse right click while touching first anchor point, it snaps to to a pixel following subsumpling, also while drawing a rectangle , it snaps to mods (2,4,8 or 16), whatever is passed as argument default modes: mod_x=2, mod_y=2 key 'Z' - zooms 2x in as well, again using mouse to be a center if available key 'R' - RESETs preview to original 1:1 clip on screen key 'I' - prints YUV or RGB values for pixel under mouse pointer in preview window printing is in this format: clip number, _PictType (I,B or P), frame number ,absolute pixel coordinates, original clip YUV or RGB values, preview RGB values key 'P' prints all available frame properties (_PictType, _Matrix, _Primaries ...etc.) key 'W' - save PNG image, what you just preview and it will be saved on hardisk as 8bit PNG as 1:1, ingnoring zoom that you have on screen key 'E' - save PNG image, what you just preview and it will be saved on hardisk as 8bit PNG, it will be saved as you see on screen, respecting zoom, pixel blocks key Spacebar - Play/Pause switch key ',' - '<' step one frame back key '.' - '>' step one frame forward 'Home' - go to first frame 'End' - go to last frame Seeking is source plugin dependant so it could take a time and window could freeze for a while. key 'Esc' returns to PREVIOUS zoom or crop key 'Q' Quits app. key 'S' Slider on/off, Seeking is source plugin dependant, could be major problem, so moving slider might have conciderable delay and freeze key 'F' Fullscreen on/off switch key 'H' help, prints this keybinding text into console Last edited by _Al_; 21st June 2020 at 16:21. |
15th June 2020, 03:38 | #3 | Link |
Registered User
Join Date: May 2011
Posts: 321
|
Treat it as a regular python module with dependencies, which are numpy and opencv in this case. You have to install both.
Then you download view.py and output_window.py (optional). So same rules like any import module, it has to be either in site-packages directory for you installed Python, or have them in a directory where your Python script is. |
15th June 2020, 05:56 | #4 | Link |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
I got it working with normal python.
All the functions seems to work, you can switch between different videos on playback, which is a feature I have never seen before wow. Problem I see is that resizing window doesn't keep with the aspect ratio, as well as crop + zoom. |
16th June 2020, 04:52 | #5 | Link | |
Registered User
Join Date: May 2011
Posts: 321
|
Quote:
If cropping while holding SHIFT, cropping selection while drawing with mouse always snaps to the same aspect ratio as video clip resolution has, so that can help. Cropped image fills current window. Crop is keeping aspect ratio on my Linux though. So at first I did not even noticed. I have openCV version with Qt library on Linux, so that might be the reason, but not sure 100%. After the crop is drawn by mouse it keeps same window but it creates white blocks of letterbox or pillarbox. Not on Windows, where I use openCV build that was compiled without Qt library. It just fills previous window, not keeping aspect ratio. That could be fixed by re-drawing window every time after crop, but I skipped that because then cropping did not work during playback smoothly and there are other smooth issues, maybe will give it some argument for it. Window could be always adjusted manually. Last edited by _Al_; 16th June 2020 at 05:22. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|