added optional fast probe fs vapoursynth lsmash installed

This commit is contained in:
Zen 2021-01-06 13:39:56 +02:00
parent 25825bf341
commit 38ddec4954

View file

@ -8,6 +8,7 @@ import cv2
import numpy as np import numpy as np
import hashlib import hashlib
from av1an.commandtypes import Command from av1an.commandtypes import Command
from av1an.ffmpeg import frame_probe_ffmpeg from av1an.ffmpeg import frame_probe_ffmpeg
from av1an.vapoursynth import frame_probe_vspipe, is_vapoursynth from av1an.vapoursynth import frame_probe_vspipe, is_vapoursynth
@ -63,10 +64,13 @@ def frame_probe_fast(source: Path, is_vs: bool = False):
""" """
total = 0 total = 0
if not is_vs: if not is_vs:
video = cv2.VideoCapture(source.as_posix()) try:
total = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) from vapoursynth import core
video.release() total = core.lsmas.LWLibavSource(source.as_posix(), cache=False)
except ImportError:
video = cv2.VideoCapture(source.as_posix())
total = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
video.release()
if is_vs or total < 1: if is_vs or total < 1:
total = frame_probe(source) total = frame_probe(source)
@ -82,4 +86,5 @@ def frame_probe(source: Path):
""" """
if is_vapoursynth(source): if is_vapoursynth(source):
return frame_probe_vspipe(source) return frame_probe_vspipe(source)
return frame_probe_ffmpeg(source) return frame_probe_ffmpeg(source)