fix: add av1/hevc vaapi encoders, simplify welcome UI, truncate output path

This commit is contained in:
fiatcode 2026-02-28 09:19:58 +07:00
parent 09084b9b59
commit ce8288ca7a
2 changed files with 57 additions and 5 deletions

View file

@ -92,7 +92,7 @@ class WelcomeScreen(Screen):
} }
#logo { #logo {
color: $text; color: $accent;
text-style: bold; text-style: bold;
margin-bottom: 2; margin-bottom: 2;
width: auto; width: auto;
@ -144,7 +144,7 @@ class WelcomeScreen(Screen):
with Middle(): with Middle():
with Vertical(id="app-container"): with Vertical(id="app-container"):
with Center(): with Center():
yield Static(LOGO, id="logo") yield Label("PyFaceBlur", id="logo")
with Horizontal(classes="form-row"): with Horizontal(classes="form-row"):
yield Label("Video file:", classes="form-label") yield Label("Video file:", classes="form-label")
@ -644,7 +644,7 @@ class EncodingScreen(Screen):
yield Label("Encoding video with face blur...", id="encoding-phase") yield Label("Encoding video with face blur...", id="encoding-phase")
yield ProgressBar(total=100, id="encoding-progress") yield ProgressBar(total=100, id="encoding-progress")
yield Label("", id="encoding-status") yield Label("", id="encoding-status")
yield Label(f"Output: {self.output_path}", id="output-label") yield Label(f"Output: {self.output_path.name}", id="output-label")
yield Button("Done — Exit", id="done-btn", variant="success") yield Button("Done — Exit", id="done-btn", variant="success")
def on_mount(self) -> None: def on_mount(self) -> None:

View file

@ -116,7 +116,59 @@ def find_best_encoder() -> Tuple[str, List[str], List[str]]:
if subprocess.run(cmd, capture_output=True, timeout=5).returncode == 0: if subprocess.run(cmd, capture_output=True, timeout=5).returncode == 0:
return "h264_nvenc", [], [] return "h264_nvenc", [], []
# 2. Linux VA-API (AMD/Intel) # 2. Linux VA-API (AV1)
cmd = [
"ffmpeg",
"-v",
"quiet",
"-vaapi_device",
"/dev/dri/renderD128",
"-f",
"lavfi",
"-i",
"nullsrc=s=64x64:d=0.1",
"-vf",
"format=nv12,hwupload",
"-c:v",
"av1_vaapi",
"-f",
"null",
"-",
]
if subprocess.run(cmd, capture_output=True, timeout=5).returncode == 0:
return (
"av1_vaapi",
["-vaapi_device", "/dev/dri/renderD128"],
["-vf", "format=nv12,hwupload"],
)
# 3. Linux VA-API (HEVC/H.265)
cmd = [
"ffmpeg",
"-v",
"quiet",
"-vaapi_device",
"/dev/dri/renderD128",
"-f",
"lavfi",
"-i",
"nullsrc=s=64x64:d=0.1",
"-vf",
"format=nv12,hwupload",
"-c:v",
"hevc_vaapi",
"-f",
"null",
"-",
]
if subprocess.run(cmd, capture_output=True, timeout=5).returncode == 0:
return (
"hevc_vaapi",
["-vaapi_device", "/dev/dri/renderD128"],
["-vf", "format=nv12,hwupload"],
)
# 4. Linux VA-API (H.264)
cmd = [ cmd = [
"ffmpeg", "ffmpeg",
"-v", "-v",
@ -142,7 +194,7 @@ def find_best_encoder() -> Tuple[str, List[str], List[str]]:
["-vf", "format=nv12,hwupload"], ["-vf", "format=nv12,hwupload"],
) )
# 3. AMD AMF (Windows/Proprietary Linux) # 5. AMD AMF (Windows/Proprietary Linux)
cmd = [ cmd = [
"ffmpeg", "ffmpeg",
"-v", "-v",