Skip to content

Commit e7f6cd1

Browse files
committed
tools/ffmpeg-sg: Add show-graph wrapper script for Windows
Signed-off-by: softworkz <softworkz@hotmail.com>
1 parent 6f370ed commit e7f6cd1

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

tools/ffmpeg-sg.cmd

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@echo off
2+
setlocal EnableDelayedExpansion
3+
REM
4+
REM ffmpeg-sg - FFmpeg Show-Graph Wrapper (aka killer feature)
5+
REM Show the FFmpeg execution graph in default browser
6+
REM
7+
REM Copyright (c) 2025 softworkz
8+
REM
9+
REM This file is part of FFmpeg.
10+
REM
11+
REM FFmpeg is free software; you can redistribute it and/or
12+
REM modify it under the terms of the GNU Lesser General Public
13+
REM License as published by the Free Software Foundation; either
14+
REM version 2.1 of the License, or (at your option) any later version.
15+
REM
16+
REM FFmpeg is distributed in the hope that it will be useful,
17+
REM but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19+
REM Lesser General Public License for more details.
20+
REM
21+
REM You should have received a copy of the GNU Lesser General Public
22+
REM License along with FFmpeg; if not, write to the Free Software
23+
REM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24+
REM
25+
26+
REM Check for ffmpeg.exe in folder
27+
if not exist "ffmpeg.exe" (
28+
echo Error: ffmpeg.exe not found in current directory.
29+
exit /b 1
30+
)
31+
32+
REM Check params
33+
set "conflict_found="
34+
for %%i in (%*) do (
35+
if /i "%%i"=="-print_graphs_file" set "conflict_found=1"
36+
if /i "%%i"=="-print_graphs_format" set "conflict_found=1"
37+
)
38+
39+
if defined conflict_found (
40+
echo Error: -print_graphs_file or -print_graphs_format parameter already provided.
41+
echo This script manages graph file generation automatically.
42+
exit /b 1
43+
)
44+
45+
REM Validate temp dir
46+
if not exist "%TEMP%" (
47+
echo Error: Temp directory not accessible
48+
exit /b 1
49+
)
50+
51+
REM Generate HTML filename
52+
set "date_part=%date:~-4,4%-%date:~-10,2%-%date:~-7,2%"
53+
set "time_part=%time:~0,2%-%time:~3,2%-%time:~6,2%"
54+
set "date_part=%date_part:/=-%"
55+
set "time_part=%time_part: =0%"
56+
57+
set "html_file=%TEMP%\ffmpeg_graph_%date_part%_%time_part%_%RANDOM%.html"
58+
59+
REM Execute ffmpeg
60+
REM Use start /wait /b to avoid "Terminate batch job" prompt on Ctrl-C
61+
start /wait /b ffmpeg.exe -print_graphs_file "%html_file%" -print_graphs_format mermaidhtml %*
62+
set "ffmpeg_exit_code=%ERRORLEVEL%"
63+
64+
REM Open browser if HTML file was created
65+
if exist "%html_file%" (
66+
echo "Execution graph opened in browser: %html_file%
67+
start "FFmpeg Graph" "%html_file%"
68+
) else (
69+
echo Warning: FFmpeg completed but no graph file was generated.
70+
)
71+
72+
REM Exit with ffmpeg exit code
73+
exit /b %ffmpeg_exit_code%

0 commit comments

Comments
 (0)