_Al_
14th June 2020, 23:28
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 (https://github.com/UniversalAl/view)
simple usage:
import vapoursynth as vs
from view import Preview
clip = vs.core.lsmas.LibavSMASHSource('source.mp4')
Preview(clip)
or comparing clips example:
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])
It uses keybindings to get informations (pixel values in YUV or RGB, props, real cropping values). Mouse is used to crop or to just quickly 2x zoom in. That was the main purpose for this project to quickly zoom in on mouse position after double click and then pressing '1' to '9' numerical keys to compare clips.
KEYBINDINGS:
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
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 (https://github.com/UniversalAl/view)
simple usage:
import vapoursynth as vs
from view import Preview
clip = vs.core.lsmas.LibavSMASHSource('source.mp4')
Preview(clip)
or comparing clips example:
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])
It uses keybindings to get informations (pixel values in YUV or RGB, props, real cropping values). Mouse is used to crop or to just quickly 2x zoom in. That was the main purpose for this project to quickly zoom in on mouse position after double click and then pressing '1' to '9' numerical keys to compare clips.
KEYBINDINGS:
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