feat: update vmaf logic
This commit is contained in:
@@ -90,9 +90,9 @@ class BaseTranscoder:
|
||||
|
||||
def _run_vmaf_psnr(self, new_info):
|
||||
target_samples = 500
|
||||
n_subsample = max(1, (self.orig_info.get("frame_count", 0) if self.orig_info else 0) // target_samples)
|
||||
n_subsample = max(1, (new_info.get("frame_count", 0) if new_info else 0) // target_samples)
|
||||
threads = multiprocessing.cpu_count()
|
||||
fps = self.orig_info.get("fps_str", "0/1") if self.orig_info else "0/1"
|
||||
fps = new_info.get("fps_str", "0/1") if new_info else "0/1"
|
||||
|
||||
print(
|
||||
f"\n[Metrics] Starting VMAF/PSNR test (Subsample interval: {n_subsample}, Threads: {threads}, Forced fps: {fps})..."
|
||||
@@ -102,21 +102,21 @@ class BaseTranscoder:
|
||||
out_h = new_info.get("height") if new_info else None
|
||||
orig_w = self.orig_info.get("width") if self.orig_info else None
|
||||
orig_h = self.orig_info.get("height") if self.orig_info else None
|
||||
orig_fps = self.orig_info.get("fps_str", "0/1") if self.orig_info else "0/1"
|
||||
orig_fps = new_info.get("fps_str", "0/1") if new_info else "0/1"
|
||||
out_fps = new_info.get("fps_str", "0/1") if new_info else "0/1"
|
||||
|
||||
# Use filter chain to align framerate, resolution, and first frame PTS
|
||||
filters_0 = []
|
||||
# Apply identical scaling and framerate conversion to the reference video
|
||||
filters_1 = []
|
||||
if out_fps != orig_fps:
|
||||
filters_0.append(f"fps={orig_fps}")
|
||||
filters_1.append(f"fps={out_fps}")
|
||||
if out_w and out_h and orig_w and orig_h and (out_w != orig_w or out_h != orig_h):
|
||||
filters_0.append(f"scale={orig_w}:{orig_h}:flags=bicubic")
|
||||
filters_0.append("setpts=PTS-STARTPTS")
|
||||
|
||||
filter_0_str = ",".join(filters_0)
|
||||
filters_1.append(f"scale={out_w}:{out_h}:flags=bicubic")
|
||||
filters_1.append("setpts=PTS-STARTPTS")
|
||||
|
||||
filter_1_str = ",".join(filters_1)
|
||||
|
||||
vmaf_filter = (
|
||||
f"[0:v]{filter_0_str}[dist];[1:v]setpts=PTS-STARTPTS[ref];"
|
||||
f"[0:v]setpts=PTS-STARTPTS[dist];[1:v]{filter_1_str}[ref];"
|
||||
f"[dist][ref]libvmaf=feature='name=psnr':log_path='{self.vmaf_log_path.as_posix()}':"
|
||||
f"log_fmt=json:n_subsample={n_subsample}:n_threads={threads}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user