More settings to allow verbose for ffmpg

This commit is contained in:
2026-07-15 16:22:46 +02:00
parent 456070903c
commit ce9c35c9b2
2 changed files with 37 additions and 14 deletions
+16
View File
@@ -263,9 +263,25 @@ Examples:
dest="search_max",
help="For pexels --search: maximum number of videos to download (default: 200)",
)
parser.add_argument(
"--ffmpeg-log",
type=str,
default=None,
dest="ffmpeg_log",
choices=["quiet", "error", "warning", "info", "verbose", "debug", "trace"],
help="Stream FFmpeg output at this -loglevel (e.g. 'verbose', 'debug') instead of the quiet progress bar",
)
args = parser.parse_args()
# FFmpeg log verbosity for every ffmpeg run: an explicit --ffmpeg-log level
# wins; otherwise -v turns on verbose streaming.
from .preprocessor import set_ffmpeg_verbose, set_ffmpeg_loglevel
if args.ffmpeg_log:
set_ffmpeg_loglevel(args.ffmpeg_log)
elif args.verbose:
set_ffmpeg_verbose(True)
# Resolve project path (optional for 'pexels --search')
action = args.action
if args.project is None:
+21 -14
View File
@@ -305,28 +305,35 @@ def ensure_proxy_files_exist(
import selectors, time, sys, subprocess
# Module-level FFmpeg verbosity switch. When enabled (e.g. via `gnommo -v`),
# run_ffmpeg_with_progress streams FFmpeg's full output at -loglevel verbose
# instead of the quiet progress bar — useful when debugging filter graphs.
_FFMPEG_VERBOSE = False
# Module-level FFmpeg log level. None → the quiet progress-bar path (-loglevel
# warning). A level string (e.g. "verbose", "debug") → stream FFmpeg's full
# output live instead of the bar — useful when debugging filter graphs.
_FFMPEG_LOGLEVEL: Optional[str] = None
def set_ffmpeg_verbose(enabled: bool) -> None:
"""Enable/disable verbose FFmpeg logging for every ffmpeg run in this process."""
global _FFMPEG_VERBOSE
_FFMPEG_VERBOSE = bool(enabled)
"""Turn on (verbose) / off streamed FFmpeg logging for every run in this process."""
global _FFMPEG_LOGLEVEL
_FFMPEG_LOGLEVEL = "verbose" if enabled else None
def run_ffmpeg_with_progress(cmd, duration, description="Processing", verbose=None, loglevel=None):
def set_ffmpeg_loglevel(level: Optional[str]) -> None:
"""Set an explicit FFmpeg -loglevel (info/verbose/debug/trace…) and stream its
output; pass None to restore the quiet progress bar."""
global _FFMPEG_LOGLEVEL
_FFMPEG_LOGLEVEL = level
def run_ffmpeg_with_progress(cmd, duration, description="Processing", loglevel=None):
cmd = cmd.copy()
if verbose is None:
verbose = _FFMPEG_VERBOSE
level = loglevel or ("verbose" if verbose else "warning")
# Explicit call arg wins, else the module-level setting, else the quiet bar.
level = loglevel if loglevel is not None else _FFMPEG_LOGLEVEL
stream = level is not None
# Verbose mode: stream FFmpeg's full output live (no progress bar), still
# Streamed mode: show FFmpeg's full output live (no progress bar), still
# capturing it so the error path keeps the full log.
if verbose:
if stream:
insert_pos = cmd.index("-y") + 1 if "-y" in cmd else 1
cmd[insert_pos:insert_pos] = ["-loglevel", level, "-stats"]
print(f" {description} — FFmpeg (-loglevel {level}):")
@@ -349,7 +356,7 @@ def run_ffmpeg_with_progress(cmd, duration, description="Processing", verbose=No
"pipe:1",
"-nostats",
"-loglevel",
level,
"warning",
]
p = subprocess.Popen(