Last active
May 2, 2024 17:48
-
-
Save vkbo/5c072717c06f3b55f06d3193691c0da9 to your computer and use it in GitHub Desktop.
Script used to upscale ST:DS9 from PAL DVD to HD using Topaz Video AI and Iris V1 model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Upscale: Star Trek Deep Space Nine | |
Source: PAL DVD | |
AI Model: Topaz Video AI 3.4, 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": "DS9_1_1_t00.mkv", "crop": "w=702:h=572:x=12:y=2", "params": "S1"}, | |
{"file": "DS9_1_1_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_1_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_2_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_2_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_2_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_2_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_3_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_3_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_3_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_3_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_4_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_4_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_4_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_4_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_5_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_5_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_5_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
{"file": "DS9_1_5_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S1"}, | |
# Season 2 | |
{"file": "DS9_2_1_t00.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_1_t01.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_1_t02.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_1_t03.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_2_t00.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_2_t01.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_2_t02.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_2_t03.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_3_t00.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_3_t01.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_3_t02.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_3_t03.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_4_t00.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_4_t01.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_4_t02.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_4_t03.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_5_t00.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_5_t01.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_5_t02.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_5_t03.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_6_t00.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_6_t01.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_6_t02.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_6_t03.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_7_t00.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
{"file": "DS9_2_7_t01.mkv", "crop": "w=702:h=572:x=11:y=3", "params": "S2"}, | |
# Season 3 | |
{"file": "DS9_3_1_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_1_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_1_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_1_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_2_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_2_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_2_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_2_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_3_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_3_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_3_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_3_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_4_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_4_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_4_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_4_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_5_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_5_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_5_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_5_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_6_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_6_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_6_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_6_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_7_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
{"file": "DS9_3_7_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S3"}, | |
# Season 4 | |
{"file": "DS9_4_1_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_1_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_1_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_2_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_2_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_2_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_2_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_3_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_3_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_3_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_3_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_4_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_4_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_4_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_4_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_5_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_5_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_5_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_5_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_6_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_6_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_6_t02.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_6_t03.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_7_t00.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
{"file": "DS9_4_7_t01.mkv", "crop": "w=702:h=572:x=11:y=2", "params": "S4"}, | |
# Season 5 | |
{"file": "DS9_5_1_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_1_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_1_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_1_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_2_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_2_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_2_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_2_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_3_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_3_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_3_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_3_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_4_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_4_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_4_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_4_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_5_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_5_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_5_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_5_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_6_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_6_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_6_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_6_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_7_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
{"file": "DS9_5_7_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S5"}, | |
# Season 6 | |
{"file": "DS9_6_1_t00.mkv", "crop": "w=712:h=574:x=5:y=2", "params": "S6"}, | |
{"file": "DS9_6_1_t01.mkv", "crop": "w=712:h=574:x=5:y=2", "params": "S6"}, | |
{"file": "DS9_6_1_t02.mkv", "crop": "w=712:h=574:x=5:y=2", "params": "S6"}, | |
{"file": "DS9_6_1_t03.mkv", "crop": "w=712:h=574:x=5:y=2", "params": "S6"}, | |
{"file": "DS9_6_2_t00.mkv", "crop": "w=712:h=574:x=5:y=2", "params": "S6"}, | |
{"file": "DS9_6_2_t01.mkv", "crop": "w=712:h=574:x=5:y=1", "params": "S6"}, | |
{"file": "DS9_6_2_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_2_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_3_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_3_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_3_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_3_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_4_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_4_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_4_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_4_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_5_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_5_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_5_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_5_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_6_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_6_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_6_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_6_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_7_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
{"file": "DS9_6_7_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S6"}, | |
# Season 7 | |
{"file": "DS9_7_1_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_1_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_1_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_1_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_2_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_2_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_2_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_2_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_3_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_3_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_3_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_3_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_4_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_4_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_4_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_4_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_5_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_5_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_5_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_5_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_6_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_6_t01.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_6_t02.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_6_t03.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
{"file": "DS9_7_7_t00.mkv", "crop": "w=720:h=576:x=0:y=0", "params": "S7"}, | |
] | |
AI_PARAMS = { | |
"S1": "compression=0.30:details=0.13:blur=0.28:noise=0.06:halo=0.09:preblur=-0.05:blend=0.2", | |
"S2": "compression=0.30:details=0.15:blur=0.28:noise=0.06:halo=0.09:preblur=-0.05:blend=0.2", | |
"S3": "compression=0.30:details=0.14:blur=0.26:noise=0.06:halo=0.09:preblur=-0.10:blend=0.2", | |
"S4": "compression=0.25:details=0.12:blur=0.20:noise=0.05:halo=0.08:preblur=-0.10:blend=0.2", | |
"S5": "compression=0.25:details=0.12:blur=0.20:noise=0.05:halo=0.08:preblur=-0.10:blend=0.2", | |
"S6": "compression=0.25:details=0.12:blur=0.20:noise=0.05:halo=0.06:preblur=-0.05:blend=0.2", | |
"S7": "compression=0.25:details=0.12:blur=0.20:noise=0.07:halo=0.06:preblur=-0.05:blend=0.2", | |
} | |
DO_FULL = True | |
DO_SAMPLE = True | |
DO_ORIGINAL = True | |
OVERWRITE_SAMPLES = False | |
SAMPLE_TIME = ("00:15: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", # Unknown | |
"colorspace": "2", # Unknown | |
"color_primaries": "2", # Unknown | |
} | |
COMPLEX_FILTER = [ | |
"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