VapourSynth preview script for Jupyter Notebook
Project description
vsquickview
vsquickview is a VapourSynth preview script designed to be used together with Jupyter Notebook with these advantages:
- Less waiting. vsquickview will run alongside Jupyter Notebook. Everytimes you make an adjustment, you can switch to the vsquickview window to view the result immediately.
- Easier comparing between two clips with a right click similar to that of slow.pics. Blind comparing is also possible.
Thanks to
- Setsugen no ao and Zewia for helping with VapourSynth magics.
- witchymary and others for helping with the UX.
Install vsquickview
Install vsquickview from pip:
python3 -m pip install vsquickview
Using vsquickview's Python interface
Create a new Jupyter Notebook and import vsquickview:
import vsquickview as vsqv
After this cell is executed, a fullscreen vsquickview window should open, showing an ARIB STD-B66 colour bar.
On Windows as of Qt 6.7, this fullscreen window would be opened in the background and won't take the focus from Jupyter Notebook. If this behaviour is different on your OS and troubles you, please create an issue and we will see how we can address it.
We will be looking at the GUI in the next section. Before that, let's see how we can add clips to vsquickview:
vsqv.View(src16, 0, "Source")
vsqv.View(compare16, 1, "Compare")
vsquickview.View() is defined as below:
View(clip: vs.VideoNode, index: int, name: Optional[str]=None)
- The first parameter is the clip to preview. vsquickview accepts
vs.YUV,vs.RGBandvs.GRAYformats. vsquickview usescore.resize.Spline36internally to convert the clip to either 16-bitvs.RGB, 8-bitvs.RGB, 16-bitvs.GRAYor 8-bitvs.GRAYformat. You may supply vsquickview with clips of these formats to avoid conversions. For HDR source or calibrated display, see Colour management. - Similar to vspreview, vsquickview has 10 video slots from 0 to 9. This is specifed using the second parameter
index. - You can also pass a third parameter to specify a name for the clip. This will be displayed in vsquickview window alongside the clip's index.
Clip on an index can be updated using the same vsquickview.View() function:
vsqv.View(new_compare16, 1, "New Compare")
To remove a clip with a specific index:
vsqv.RemoveView(1)
If you prefer a VapourSynth-style call to vsquickview, you could call the functions like:
vsqv.View(compare16, index=1, name="Compare")
vsqv.RemoveView(None, index=1)
Here is a short list of basic functions and their definitions in vsquickview:
View(clip: vs.VideoNode, index: int, name: Optional[str]=None, color_space_in: QColorSpace=QColorSpace(QColorSpace.SRgb), color_space: QColorSpace=QColorSpace(QColorSpace.SRgb)) -> None
RemoveView(clip: Union[vs.VideoNode, int, None]=None, index: Optional[int]=None) -> None
SetFrame(clip: Union[vs.VideoNode, int, None]=None, frame: Optional[int]=None) -> None
SetIndex(clip: Union[vs.VideoNode, int, None]=None, index: Optional[int]=None) -> None
Show(clip: Optional[vs.VideoNode]=None) -> None
Hide(clip: Optional[vs.VideoNode]=None) -> None
After previewing, you may directly export Jupyter Notebook to Python file for VSPipe. vsquickview will be automatically disabled when run in VSPipe. If this detection fails to work, please create an issue.
Using vsquickview's GUI
On startup, vsquickview displays the first frame of the clip at index 0 on startup. Press Alt or AltGr key and you will see a label on the bottom-left corner of the screen that reads Index 0: [Name of the clip] / Frame 0.
You can switch to another frame using G key. Press G key and type in the frame number, then press Enter to switch to a new frame. You can also use the Left or Right key to go to previous or next frame.
You can cycle between clips using Right Mouse Button or Space key. Press Shift with the Right Mouse Button or Space key to cycle the clips backwards.
Other usages are listed below:
Left Mouse ButtonorMiddle Mouse Button: Pan the clip preview.Scroll Wheel: Zoom the preview.AltorAltGr: Toggle the label at the bottom-left corner of the screen.Right Mouse ButtonorSpace: Switch to the next available clip.ShiftandRight Mouse ButtonorSpace: Switch to the previous available clip.0,1,2…9: Switch to the clip at the specific index, similar to the control of vspreview.UporDown: Go to the next or previous clip, but not cycling the clips.Gor`: PressGor`key and type the frame number followed byEnterkey to go to a specific frame.CtrlandC: Copy current frame number to clipboard.CtrlandV: Read from clipboard, and go to the frame if the clipboard content is an integer.LeftKey orRightKey: Go to the previous or the next frame.ShiftandLeftKey orRightKey: Jump 12 frames backwards or forwards.ForF11: Toggle fullscreen.Q: Close vsquickview window.
vsquickview will not quit when vsquickview window are closed. You can reopen the window by calling function vsquickview.Show(). vsquickview will only quit when you terminate or restart Jupyter Notebook session.
Using preview group
Additionally, you can also create preview group for a selected list of frames you want to compare.
Set preview group using the vsquickview.SetPreviewGroup() function:
vsqv.SetPreviewGroup([1934, 6849, 13226, 21647, 25374, 26811, 28499, 29111])
In the vsquickview GUI, use Ctrl key with Left or Right key to go to the previous or next frame in the set preview group.
You can add frame to or remove frame from the preview group using R Key from GUI.
You can retrieve the current preview group using the vsquickview.PreviewGroup() function.
pg = vsqv.PreviewGroup()
Here is a short list of functions and their definitions for preview group:
SetPreviewGroup(clip: Union[vs.VideoNode, list[int], None]=None, group: Optional[list[int]]=None) -> None
ClearPreviewGroup(clip: Optional[vs.VideoNode]=None) -> None
PreviewGroup(clip: Optional[vs.VideoNode]=None) -> list[int]
Save image
You can save the current frame as image by pressing key S in the GUI. These options are available:
os.environ["VSQV_SAVE_IMAGE_DIRECTORY"]: The directory where the image will be saved. Default:QStandardPaths.standardLocations(QStandardPaths.PicturesLocation)[0].os.environ["VSQV_SAVE_IMAGE_FORMAT"]: The format the image will be saved in. Default:PNG.os.environ["VSQV_SAVE_IMAGE_QUALITY"]: The quality the image will be saved with. Default:100.
Colour management
QtQML doesn't currently support colour management as of Qt 6.7. However, you may manually convert colours by passing two QColorSpace instances alongside the clip to vsquickview.View().
from PySide6.QtCore import QFile, QIODevice
from PySide6.QtGui import QColorSpace
# (1) Previewing SDR videos with a calibrated display.
icc_profile = QFile("/path/to/calibrated.icc")
icc_profile.open(QIODevice.ReadOnly)
color_space = QColorSpace.fromIccProfile(icc_profile.readAll())
vsqv.View(compare16, index=1, name="Compare", color_space=color_space)
# (2) Previewing HDR videos with an uncalibrated Display P3 display.
# See https://doc.qt.io/qt/qcolorspace.html#public-functions for more
# ways to construct QColorSpace, including using custom primaries and
# transfer function or transfer function table.
color_space_in = QColorSpace(QColorSpace.Bt2020)
color_space = QColorSpace(QColorSpace.DisplayP3)
# Only supports clips of vs.RGB or vs.GRAY format for HDR sources,
# the reason being clips with vs.YUV format will be converted
# internally to vs.RGB assuming BT.709 primaries, transfer and matrix.
vsqv.View(compare16, index=1, name="Compare", color_space_in=color_space_in, color_space=color_space)
# Both `color_space_in` and `color_space` are optional and default to
# `QColorSpace(QColorSpace.SRgb)`.
View(clip: vs.VideoNode, index: int, name: Optional[str]=None, color_space_in: QColorSpace=QColorSpace(QColorSpace.SRgb), color_space: QColorSpace=QColorSpace(QColorSpace.SRgb)) -> None
Additional vsquickview options
- Set
os.environ["VSQV_FORCE_8_BIT"] = "1"before callingvsqv.View()or importing vsquickview to force 8-bit preview instead of preferring 16-bit. This may improve frame loading performance on slower machines. - vsquickview should always scale the preview against the device's physical pixels. This is implemented based on QML's Screen.devicePixelRatio and should automatically work on most platforms. However, if the bottom right corner of the ARIB STD-B66 colour bar shown at the start of vsquickview does not display a cyclone pattern (Fig. 2-4 in the standard), set
os.environ["VSQV_SCREEN_DEVICE_PIXEL_RATIO"]to a proper value beforeimport vsquickview as vsqvor before callingvsqv.View().
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vsquickview-1.1.7.tar.gz.
File metadata
- Download URL: vsquickview-1.1.7.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be38b5e3c664fbd7e280cc38e14007588cc68333332b2f748c6e191214b87323
|
|
| MD5 |
ff3fab4280de3b9ec36ab8187053261c
|
|
| BLAKE2b-256 |
2ba26079d6e5d2e64de6dbbe845a0c476c998542efed4c1140c216aa91d9d272
|
File details
Details for the file vsquickview-1.1.7-py3-none-any.whl.
File metadata
- Download URL: vsquickview-1.1.7-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02ce3e948f3838dac8467f77f86d6851430d316bb2e92095a8148938e6005dd9
|
|
| MD5 |
f49aa816655ad4c9bb64dad1fc2f54d5
|
|
| BLAKE2b-256 |
ea886995722f7482e559e419679693b64a697020c0722185538bf54f691bc3f9
|