Skip to content

Instantly share code, notes, and snippets.

@vkbo
Last active October 29, 2023 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vkbo/c5b4cb7c5e4da28f4b81487646e3148c to your computer and use it in GitHub Desktop.
Save vkbo/c5b4cb7c5e4da28f4b81487646e3148c to your computer and use it in GitHub Desktop.
Script used to upscale ST:VOY from PAL DVD to HD using Topaz Video AI and Iris V1 model
"""
Upscale: Star Trek Voyager
Source: PAL DVD (2017 Release)
AI Model: Topaz Video AI 4.0, Iris V1
"""
import sys
import subprocess
from pathlib import Path
if sys.platform == "win32":
BASE = Path("D:/Upscale")
WORK = Path("C:/Program Files/Topaz Labs LLC/Topaz Video AI")
else:
BASE = Path("~/Video/Upscale")
WORK = Path(".")
SRC = BASE / "Input"
DST = BASE / "Output"
EXT = ".mkv"
JOBS = [
# Season 1
{"file": "VOY_1_1_t00.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_1_t01.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_1_t02.mkv", "crop": "w=716:h=572:x=3:y=2", "params": "S1"},
{"file": "VOY_1_2_t00.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_2_t01.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_2_t02.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_2_t03.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_3_t00.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_3_t01.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_3_t02.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_3_t03.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_4_t00.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_4_t01.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_4_t02.mkv", "crop": "w=716:h=572:x=2:y=2", "params": "S1"},
{"file": "VOY_1_4_t03.mkv", "crop": "w=716:h=572:x=3:y=2", "params": "S1"},
# Season 2
{"file": "VOY_2_1_t00.mkv", "crop": "w=702:h=572:x=13:y=2", "params": "S2"},
{"file": "VOY_2_1_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_1_t02.mkv", "crop": "w=702:h=572:x=12:y=2", "params": "S2"},
{"file": "VOY_2_1_t03.mkv", "crop": "w=700:h=572:x=14:y=2", "params": "S2"},
{"file": "VOY_2_2_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_2_t01.mkv", "crop": "w=702:h=572:x=12:y=2", "params": "S2"},
{"file": "VOY_2_2_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_2_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_3_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_3_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_3_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_3_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_4_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_4_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_4_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_4_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_5_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_5_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_5_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_5_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_6_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_6_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_6_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_6_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_7_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
{"file": "VOY_2_7_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S2"},
# Season 3
{"file": "VOY_3_1_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_1_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_1_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_1_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_2_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_2_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_2_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_2_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_3_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_3_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_3_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_3_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_4_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_4_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_4_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_4_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_5_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_5_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_5_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_5_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_6_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_6_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_6_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_6_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_7_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
{"file": "VOY_3_7_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S3"},
# Season 4
{"file": "VOY_4_1_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_1_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_1_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_1_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_2_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_2_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_2_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_2_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_3_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_3_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_3_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_3_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_4_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_4_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_4_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_4_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_5_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_5_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_5_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_5_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_6_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_6_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_6_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_6_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_7_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
{"file": "VOY_4_7_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S4"},
# Season 5
{"file": "VOY_5_1_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_1_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_1_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_1_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_2_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_2_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_2_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_2_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_3_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_3_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_3_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_3_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_4_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_4_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_4_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_5_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_5_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_5_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_5_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_6_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_6_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_6_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_6_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_7_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
{"file": "VOY_5_7_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S5"},
# Season 6
{"file": "VOY_6_1_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_1_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_1_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_1_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_2_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_2_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_2_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_2_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_3_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_3_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_3_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_3_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_4_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_4_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_4_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_4_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_5_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_5_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_5_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_5_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_6_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_6_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_6_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_6_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_7_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
{"file": "VOY_6_7_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S6"},
# Season 7
{"file": "VOY_7_1_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_1_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_1_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_1_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_2_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_2_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_2_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_2_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_3_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_3_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_3_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_4_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_4_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_4_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_4_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_5_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_5_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_5_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_5_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_6_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_6_t01.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_6_t02.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_6_t03.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
{"file": "VOY_7_7_t00.mkv", "crop": "w=702:h=572:x=10:y=2", "params": "S7"},
]
AI_PARAMS = {
"S1": "compression=0.23:details=0.11:blur=0.30:noise=0.04:halo=0.11:preblur=-0.03:blend=0.25",
"S2": "compression=0.24:details=0.17:blur=0.30:noise=0.04:halo=0.13:preblur=-0.10:blend=0.25",
"S3": "compression=0.20:details=0.15:blur=0.25:noise=0.03:halo=0.12:preblur=-0.14:blend=0.25",
"S4": "compression=0.24:details=0.16:blur=0.25:noise=0.04:halo=0.10:preblur=-0.12:blend=0.25",
"S5": "compression=0.18:details=0.17:blur=0.20:noise=0.03:halo=0.10:preblur=-0.14:blend=0.25",
"S6": "compression=0.15:details=0.14:blur=0.15:noise=0.03:halo=0.10:preblur=-0.14:blend=0.25",
"S7": "compression=0.11:details=0.14:blur=0.15:noise=0.03:halo=0.08:preblur=-0.13:blend=0.25",
}
DO_FULL = True
DO_SAMPLE = True
DO_ORIGINAL = True
OVERWRITE_SAMPLES = False
SAMPLE_TIME = ("00:20:00", "00:00:20") # Start, Length
PROCESS = Path(__file__).parent / "process.txt"
# Colours: https://github.com/bbc/qtff-parameter-editor#video-characteristics
INPUT_SPEC = {
"sws_flags": "spline+accurate_rnd+full_chroma_int",
"color_trc": "2",
"colorspace": "2",
"color_primaries": "2",
}
COMPLEX_FILTER = [
"bwdif=mode=0:parity=-1:deint=0",
"crop={crop}",
"scale=w=768:h=576",
"setsar=1",
"tvai_up=model=iris-1:scale=2:{params}:device=0:vram=1:instances=1",
"scale=w=1440:h=1080:flags=lanczos:threads=0",
]
VIDEO_ENC = {
# Apple ProRes LT
"c:v": "prores_ks",
"profile:v": "1",
"vendor": "apl0",
"quant_mat": "lt",
"bits_per_mb": "525",
"pix_fmt": "yuv422p10le",
}
AUDIO_ENC = {
"map": "0:a",
"c:a": "copy",
}
META_DATA = {
"map_metadata": "0",
"map_metadata:s:v": "0:s:v",
"map_metadata:s:a": "0:s:a",
}
def extendArgs(args: list, data: dict) -> None:
args.extend(m for k, v in data.items() for m in [f"-{k}", f"{v}"])
return
sampleDir = DST / "Samples"
sampleDir.mkdir(exist_ok=True)
for n, job in enumerate(JOBS, start=1):
if PROCESS.exists() and PROCESS.read_text().strip().lower() == "stop":
print("")
print("********************")
print("* Stopping job ... *")
print("********************")
print("")
break
inputFile = SRC / job["file"]
origFile = sampleDir / Path(f"{inputFile.stem}_original").with_suffix(EXT)
sampleFile = sampleDir / Path(f"{inputFile.stem}_sample").with_suffix(EXT)
enhancedFile = DST / Path(f"{inputFile.stem}_enhanced").with_suffix(EXT)
if DO_ORIGINAL and (OVERWRITE_SAMPLES or not origFile.exists()):
print("")
print(f"Creating Original Sample {n} of {len(JOBS)}")
print("="*80)
print(f"Output: {origFile}")
args = [
"ffmpeg",
"-ss", SAMPLE_TIME[0], "-t", SAMPLE_TIME[1],
"-i", str(inputFile),
"-map_metadata", "0",
"-vcodec", "copy",
"-acodec", "copy",
str(origFile)
]
command = " ".join(args)
print(f"Command: {command}")
print("")
print("-"*80)
print("")
origFile.unlink(missing_ok=True)
subprocess.run(command, cwd=WORK, shell=True)
print("-"*80)
print("")
if DO_SAMPLE and (OVERWRITE_SAMPLES or not sampleFile.exists()):
print("")
print(f"Creating Enhanced Sample {n} of {len(JOBS)}")
print("="*80)
print(f"Output: {sampleFile}")
args = [
"ffmpeg",
"-ss", SAMPLE_TIME[0], "-t", SAMPLE_TIME[1],
"-i", str(inputFile),
]
extendArgs(args, INPUT_SPEC)
complexFilter = ",".join(COMPLEX_FILTER).format(
crop=job["crop"],
params=AI_PARAMS[job["params"]],
)
args.extend(["-filter_complex", complexFilter])
extendArgs(args, VIDEO_ENC)
extendArgs(args, AUDIO_ENC)
extendArgs(args, META_DATA)
args.append(str(sampleFile))
command = " ".join(args)
print(f"Command: {command}")
print("")
print("-"*80)
print("")
sampleFile.unlink(missing_ok=True)
subprocess.run(command, cwd=WORK, shell=True)
print("-"*80)
print("")
if DO_FULL and not enhancedFile.exists():
print("")
print(f"Enhancing Video {n} of {len(JOBS)}")
print("="*80)
print(f"Output: {enhancedFile}")
args = ["ffmpeg", "-i", str(inputFile)]
extendArgs(args, INPUT_SPEC)
complexFilter = ",".join(COMPLEX_FILTER).format(
crop=job["crop"],
params=AI_PARAMS[job["params"]],
)
args.extend(["-filter_complex", complexFilter])
extendArgs(args, VIDEO_ENC)
extendArgs(args, AUDIO_ENC)
extendArgs(args, META_DATA)
args.append(str(enhancedFile))
command = " ".join(args)
print(f"Command: {command}")
print("")
print("-"*80)
print("")
subprocess.run(command, cwd=WORK, shell=True)
print("-"*80)
print("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment