Selur
28th April 2024, 15:24
Using the following script:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# loading plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/d2vSource/DGDecode.dll")
# Source: 'G:\TestClips&Co\files\MPEG-1\SEGALOGO_adpcm.mpg'
# Current color space: YUV420P8, bit depth: 8, resolution: 512x360, frame rate: 29.97fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
# Loading G:\TestClips&Co\files\MPEG-1\SEGALOGO_adpcm.mpg using DGDecode
clip = core.dgdecode.MPEG2Source("J:/tmp/mpg_320eb6e218bb9d250f02c92c33db174a_853323747.d2v", info=3)# 29.97 fps, scanorder: progressive
frame = clip.get_frame(0)
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip, _Matrix=5)
# setting color transfer (170), if it is not set.
if ('_Transfer' not in frame.props) or (frame.props['_Transfer'] == '') or (frame.props['_Transfer'] == 0):
clip = core.std.SetFrameProps(clip, _Transfer=6)
# setting color primaries info (to 470), if it is not set.
if ('_Primaries' not in frame.props) or (frame.props['_Primaries'] == '') or (frame.props['_Primaries'] == 0):
clip = core.std.SetFrameProps(clip, _Primaries=5)
# setting color range to TV (limited) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)
# making sure frame rate is set to 29.97fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
# making sure the detected scan type is set (detected: progressive)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=0)# progressive
# adjusting output color from: YUV420P8 to YUV420P10 for NVEncModel
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited")
# set output frame rate to 29.97fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
frame = clip.get_frame(0)
clip = core.std.BlankClip(clip).text.Text("Matrix: "+str(frame.props['_Matrix'])+"\nTransfer: "+str(frame.props['_Transfer'])+"\nPrimaries: "+str(frame.props['_Primaries']))
# output
clip.set_output()
and calling it multiple time with:
VSPipe.exe --info c:\Users\Selur\Desktop\test_1.vpy
it sometimes (maybe 1 in 20) fails with:
Script evaluation failed:
Python exception: 'No key named _Transfer exists'
Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 3115, in vapoursynth._vpy_evaluate
File "src\cython\vapoursynth.pyx", line 3116, in vapoursynth._vpy_evaluate
File "c:\Users\Selur\Desktop\test_1.vpy", line 32, in <module>
clip = core.std.BlankClip(clip).text.Text("Matrix: "+str(frame.props['_Matrix'])+"\nTransfer: "+str(frame.props['_Transfer'])+"\nPrimaries: "+str(frame.props['_Primaries']))
~~~~~~~~~~~^^^^^^^^^^^^^
File "src\cython\vapoursynth.pyx", line 1074, in vapoursynth.FrameProps.__getitem__
KeyError: 'No key named _Transfer exists'
and other times it works fine. (Using R65, can't switch to R66 atm.)
This is driving me nuts.
Am I doing something wrong? Should I set and get the properties in another way?
Cu Selur
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# loading plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/d2vSource/DGDecode.dll")
# Source: 'G:\TestClips&Co\files\MPEG-1\SEGALOGO_adpcm.mpg'
# Current color space: YUV420P8, bit depth: 8, resolution: 512x360, frame rate: 29.97fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
# Loading G:\TestClips&Co\files\MPEG-1\SEGALOGO_adpcm.mpg using DGDecode
clip = core.dgdecode.MPEG2Source("J:/tmp/mpg_320eb6e218bb9d250f02c92c33db174a_853323747.d2v", info=3)# 29.97 fps, scanorder: progressive
frame = clip.get_frame(0)
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip, _Matrix=5)
# setting color transfer (170), if it is not set.
if ('_Transfer' not in frame.props) or (frame.props['_Transfer'] == '') or (frame.props['_Transfer'] == 0):
clip = core.std.SetFrameProps(clip, _Transfer=6)
# setting color primaries info (to 470), if it is not set.
if ('_Primaries' not in frame.props) or (frame.props['_Primaries'] == '') or (frame.props['_Primaries'] == 0):
clip = core.std.SetFrameProps(clip, _Primaries=5)
# setting color range to TV (limited) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)
# making sure frame rate is set to 29.97fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
# making sure the detected scan type is set (detected: progressive)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=0)# progressive
# adjusting output color from: YUV420P8 to YUV420P10 for NVEncModel
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited")
# set output frame rate to 29.97fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
frame = clip.get_frame(0)
clip = core.std.BlankClip(clip).text.Text("Matrix: "+str(frame.props['_Matrix'])+"\nTransfer: "+str(frame.props['_Transfer'])+"\nPrimaries: "+str(frame.props['_Primaries']))
# output
clip.set_output()
and calling it multiple time with:
VSPipe.exe --info c:\Users\Selur\Desktop\test_1.vpy
it sometimes (maybe 1 in 20) fails with:
Script evaluation failed:
Python exception: 'No key named _Transfer exists'
Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 3115, in vapoursynth._vpy_evaluate
File "src\cython\vapoursynth.pyx", line 3116, in vapoursynth._vpy_evaluate
File "c:\Users\Selur\Desktop\test_1.vpy", line 32, in <module>
clip = core.std.BlankClip(clip).text.Text("Matrix: "+str(frame.props['_Matrix'])+"\nTransfer: "+str(frame.props['_Transfer'])+"\nPrimaries: "+str(frame.props['_Primaries']))
~~~~~~~~~~~^^^^^^^^^^^^^
File "src\cython\vapoursynth.pyx", line 1074, in vapoursynth.FrameProps.__getitem__
KeyError: 'No key named _Transfer exists'
and other times it works fine. (Using R65, can't switch to R66 atm.)
This is driving me nuts.
Am I doing something wrong? Should I set and get the properties in another way?
Cu Selur