From 41978e33783823f4a85d20309fdd2d39d6d4eb87 Mon Sep 17 00:00:00 2001 From: you-cant-see-me Date: Sat, 14 Jun 2025 07:37:15 +0100 Subject: [PATCH] [audio-transcodes] Fix paths with spaces and ffmpeg stderr flood (#581) --- plugins/audio-transcodes/audio-transcodes.py | 19 ++++++++++++------- plugins/audio-transcodes/audio-transcodes.yml | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/plugins/audio-transcodes/audio-transcodes.py b/plugins/audio-transcodes/audio-transcodes.py index 6380354..1d88bda 100644 --- a/plugins/audio-transcodes/audio-transcodes.py +++ b/plugins/audio-transcodes/audio-transcodes.py @@ -3,7 +3,7 @@ from stashapi.stashapp import StashInterface import sys import json from pathlib import Path -import os +import subprocess settings = {"hash_type": "oshash", "transcodes_dir": "/generated/transcodes/"} @@ -18,12 +18,18 @@ def run_ffmpeg(file, hash): dest, ) ) - command = ( - "ffmpeg -f lavfi -i color=c=blue:s=1280x720 -i %s -shortest -fflags +shortest %s" - % (file, dest) - ) + command = [ + "ffmpeg", + "-loglevel", "error", + "-f", "lavfi", + "-i", "color=c=blue:s=1280x720", + "-i", file, + "-shortest", + "-fflags", "+shortest", + dest, + ] log.debug("about to run command: %s " % (command,)) - os.system(command) + subprocess.run(command) else: log.debug( "transcode already exists %s - %s" @@ -59,7 +65,6 @@ FRAGMENT_SERVER = json_input["server_connection"] stash = StashInterface(FRAGMENT_SERVER) config = stash.get_configuration() -log.debug(config) settings["transcodes_dir"] = config["general"]["generatedPath"] settings["hash_type"] = config["general"]["videoFileNamingAlgorithm"].lower() log.debug(settings) diff --git a/plugins/audio-transcodes/audio-transcodes.yml b/plugins/audio-transcodes/audio-transcodes.yml index 58f5ae4..55bdedc 100644 --- a/plugins/audio-transcodes/audio-transcodes.yml +++ b/plugins/audio-transcodes/audio-transcodes.yml @@ -1,6 +1,6 @@ name: audio-transcodes description: Generate a transcode video from an audio file -version: 0.1 +version: 0.2 url: https://github.com/stashapp/CommunityScripts/ exec: - python