Skip to content

Commit

Permalink
Release 3
Browse files Browse the repository at this point in the history
Image sequence input support
Structural overhaul
Presets overhaul
  • Loading branch information
keerah committed Feb 13, 2023
1 parent ddfeba7 commit 2c3c189
Show file tree
Hide file tree
Showing 56 changed files with 2,369 additions and 2,290 deletions.
53 changes: 53 additions & 0 deletions sendtoffmpeg_encoder01.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
REM This is one of the SenTo FFmpeg modular transcoders, keep it with the rest of the files

ECHO [----------------------------------------------------------------------------------------]
ECHO [ %argCount% files queued to encode

FOR /L %%i IN (1,1,%argCount%) DO (

ECHO [----------------------------------------------------------------------------------------]

SET "vlen="
FOR /F "tokens=* delims=" %%f IN ('call "%ffpath%ffprobe.exe" -v error -show_entries "format=duration" -of "default=noprint_wrappers=1:nokey=1" "!argFile[%%i].name!"') DO SET "vlen=%%f"

IF !vlen! == N/A (
ECHO [ The source is a single image file with no length

IF !imgseq! GTR 0 (
REM detecting image sequence
IF !frcounter! GTR 0 (
REM detecting the counter in the end of the filename
SET "basename=!argFile[%%i].trname:~0,-%frcounter%!"
SET "countername=!argFile[%%i].trname:~-%frcounter%!"
FOR /F "tokens=* delims=0" %%N IN ("!countername!") DO SET /A frnumber=%%N
IF !frnumber! GTR 0 (
SET "argFile[%%i].name=!argFile[%%i].path!!basename!%%0!frcounter!d!argFile[%%i].ext!"
ECHO [ Image sequence detected ]
ECHO [ Basename: "!basename!" Start frame: !frnumber! Pattern: "!basename!%%0!frcounter!d"
SET "wset.seqfr=-framerate %fps% -start_number !frnumber! -pattern_type sequence"
SET "wset.seqfrout=-r %fps%"
REM No audio assumed
SET "wset.audiocomp="
) ELSE (
SET "wset.seqfr="
SET "wset.seqfrout="
)
) ELSE (
REM detecting the counter after first found dot
REM No implementation yet
)
) ELSE (
SET "wset.seqfr="
SET "wset.seqfrout="
)
) ELSE (
ECHO [ Video length is: !vlen! seconds
)

ECHO [ Transcoding %%i of %argCount%: !argFile[%%i].trname!
"%ffpath%ffmpeg.exe" !wset.params! !wset.seqfr! -i "!argFile[%%i].name!" !wset.videocomp! !wset.audiocomp! !wset.seqfrout! !wset.over! "!argFile[%%i].trname!"!wset.suff!
)

ECHO [----------------------------------------------------------------------------------------]
ECHO [ SERVED ]
ECHO [----------------------------------------------------------------------------------------]
63 changes: 63 additions & 0 deletions sendtoffmpeg_encoder02.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
REM This is one of the SenTo FFmpeg modular transcoders, keep it with the rest of the files

ECHO [----------------------------------------------------------------------------------------]
ECHO [ %argCount% files queued to encode

FOR /L %%i IN (1,1,%argCount%) DO (

ECHO [----------------------------------------------------------------------------------------]

SET "vlen="
FOR /F "tokens=* delims=" %%f IN ('call "%ffpath%ffprobe.exe" -v error -show_entries "format=duration" -of "default=noprint_wrappers=1:nokey=1" "!argFile[%%i].name!"') DO SET "vlen=%%f"

IF !vlen! == N/A (
ECHO [ The source is a single image file with no length

IF !imgseq! GTR 0 (
REM detecting image sequence
IF !frcounter! GTR 0 (
REM detecting the counter in the end of the filename
SET "basename=!argFile[%%i].trname:~0,-%frcounter%!"
SET "countername=!argFile[%%i].trname:~-%frcounter%!"
FOR /F "tokens=* delims=0" %%N IN ("!countername!") DO SET /A frnumber=%%N
IF !frnumber! GTR 0 (
REM overwrite default framerate setting with the preset's one
SET /A fps=%wset.fps%
SET "argFile[%%i].name=!argFile[%%i].path!!basename!%%0!frcounter!d!argFile[%%i].ext!"
ECHO [ Image sequence detected ]
ECHO [ Basename: "!basename!" Start frame: !frnumber! Pattern: "!basename!%%0!frcounter!d"
SET "wset.seqfr=-framerate %fps% -start_number !frnumber! -pattern_type sequence"
REM No audio assumed
SET "wset.audiocomp="
) ELSE (
REM No sequence, no pattern
SET "wset.seqfr="
SET "wset.seqfrout="
)
) ELSE (
REM detecting the counter after first found dot
REM No implementation yet
)
) ELSE (
SET "wset.seqfr="
SET "wset.seqfrout="
)
) ELSE (
echo [ Video length is: !vlen! seconds
)

ECHO [ Encoding file %%i of %argCount%
ECHO [ STAGE 1: Generating a palette ]
"%ffpath%ffmpeg.exe" !wset.params! !wset.seqfr! -i "!argFile[%%i].name!" !wset.prepass! !wset.seqfrout! -y "!argFile[%%i].trname!"palette.png

ECHO [----------------------------------------------------------------------------------------]
ECHO [ Encoding file %%i of %argCount%
ECHO [ STAGE 2: Encoding to Gif using the generatied palette ]
"%ffpath%ffmpeg.exe" !wset.params! !wset.seqfr! -i "!argFile[%%i].name!" -i "!argFile[%%i].trname!"palette.png !wset.videocomp! !wset.over! "!argFile[%%i].trname!"!wset.suff!

IF EXIST "!argFile[%%i].trname!palette.png" DEL /s "!argFile[%%i].trname!palette.png" > nul
)

ECHO [----------------------------------------------------------------------------------------]
ECHO [ SERVED ]
ECHO [----------------------------------------------------------------------------------------]
55 changes: 39 additions & 16 deletions sendtoffmpeg_settings.cmd
Original file line number Diff line number Diff line change
@@ -1,23 +1,46 @@
REM SendTo_FFmpeg is a set of windows batches for effortless and free transcoding
REM Copyright (c) 2018-2022 Keerah, keerah.com. All rights reserved
REM More information at https://keerah.com https://github.com/keerah/SendTo_FFmpeg
REM SendTo_FFmpeg is a set of windows batches for effortless transcoding
REM Download from https://github.com/keerah/SendTo_FFmpeg

REM This is a SendTo_FFmpeg settings file
REM You need to be careful here, cause it's an executable part of the script for each preset
rem You have to be careful here, cause it's an executable part of the scripts
rem Scripts won't be able to run without this file nearby.

REM If you copy of this file to the folder of your source files, then these localized settings
REM will be used for transcoding all files inside this folder instead of the global settings
REM For example, you can disable the pause after processing or reduce verbose level to errors only
REM for a particular folder only.
REM If you copy this file to the folder of your source files
REM then these "localized" settings will be used for transcoding
REM of the files inside this folder instead of the global settings.
REM For example, you can disable the descriptive name suffixes,
REM use another default framerate or even use another FFmpeg version
REM for a particular folder only

rem Path to ffmpeg.exe
set "ffpath=c:\Program Files\ffmpeg\bin\"
SET "ffpath=c:\Program Files\ffmpeg\bin\"
REM Path to ffmpeg.exe
REM will also look for exiftool.exe here when needed

rem FFmpeg verbosity level, use "info" for full verbosity or "error" for errors only
set "vbl=warning"
SET "vbl=warning"
REM FFmpeg verbosity level
REM "info" for full verbosity, "warning" for all important messaes, "error" for errors only

rem Enable pause after encoding, any positive value enables the pause
set /A pse=1
SET /A pse=1
REM Enable pause after encoding
REM Any positive value enables the pause

rem Descriptive naming for output files, any positive value enables description
set /A dscr=1
SET /A dscr=1
REM Descriptive naming for output files
REM Any positive value enables filename suffixes

SET /A quietover=1
REM Quiet overwrite
REM If it is set to 1, the output files will be always overwritten

SET /A fps=30
REM Default framerate for image seuences

SET /A imgseq=1
REM Consider image sequences
REM if 0 then ffmpeg won't look for image sequences containing the selected file

SET /A frcounter=4
REM Frame counter digits
REM The number of digits in the frame counter to detect (leading zeroes assumed)
REM If set to 0, the scripts will search for the counter after the first dot in the filename
REM taking all digits available (future feature)
123 changes: 84 additions & 39 deletions to APNG forever loop.bat
Original file line number Diff line number Diff line change
@@ -1,63 +1,108 @@
@ECHO OFF
REM SendTo_FFmpeg is a set of windows batches for effortless and free transcoding
REM Copyright (c) 2018-2021 Keerah, keerah.com. All rights reserved
REM More information at https://keerah.com https://github.com/keerah/SendTo_FFmpeg
REM SendTo_FFmpeg is a set of windows batches for effortless transcoding
REM Download from https://github.com/keerah/SendTo_FFmpeg

setlocal enabledelayedexpansion

set argCount=0
for %%x in (%*) do (
set /A argCount+=1
set "argVec[!argCount!]=%%~x"
set "argVn[!argCount!]=%%~nx"
SET argCount=0
FOR %%f IN (%*) DO (
SET /A argCount+=1
SET "argFile[!argCount!].name=%%~f"
SET "argFile[!argCount!].trname=%%~nf"
SET "argFile[!argCount!].ext=%%~xf"
SET "argFile[!argCount!].path=%%~dpf"
)

ECHO [---------------------------------------------------------------------------------]
ECHO [--- SendTo FFmpeg encoder v2.2 by Keerah.com ---]
ECHO [--- Multi APNG module has been invoked ---]
ECHO [--- Preset: plain, loop forever ---]
IF %argCount% LEQ 0 (
ECHO [-----------------------------------------------------------------------------------]
ECHO [ NO FILE^(S^) SPECIFIED ]
GOTO :End
)

ECHO [-----------------------------------------------------------------------------------]
ECHO [--- SendTo FFmpeg encoder v3.0 by Keerah ---]
ECHO [--- Preset: APNG plain, loop forever ---]

set "cmdp=%~dp0"
set "argp=%~dp1"
SET "cmdp=%~dp0"
SET "argp=%~dp1"

REM get settings
IF EXIST "%argp%sendtoffmpeg_settings.cmd" (
CALL "%argp%sendtoffmpeg_settings.cmd"
ECHO [--- Settings: LOCAL ---]
ECHO [--- Settings: *LOCAL*, Verbosity: !vbl!
) ELSE (
CALL "%cmdp%sendtoffmpeg_settings.cmd"
ECHO [--- Settings: GLOBAL ---]
IF EXIST "%cmdp%sendtoffmpeg_settings.cmd" (
CALL "%cmdp%sendtoffmpeg_settings.cmd"
ECHO [--- Settings: Global, Verbosity: !vbl!
) ELSE (
ECHO [--- Sorry, the sendtoffmpeg_settings.cmd is unreacheable. Unable to continue! ---]
GOTO :End
)
)

IF %argCount% == 0 (

ECHO [---------------------------------------------------------------------------------]
ECHO [ NO FILE SPECIFIED ]
GOTO End
REM Check for ffmpeg
IF NOT EXIST "%ffpath%ffmpeg.exe" (
ECHO [--- Sorry, the path to ffmpeg.exe is unreacheable. Unable to continue! ---]
GOTO :End
)

IF %argCount% GTR 1 (

ECHO [---------------------------------------------------------------------------------]
ECHO [ %argCount% files queued to encode
)

IF %dscr% GTR 0 (SET "dscrName=_animpng") ELSE (SET "dscrName=")
REM compression settings
SET "wset.params=-v %vbl% -hide_banner -stats"
SET "wset.videocomp=-f apng -plays 0"
SET "wset.audiocomp="
IF %quietover% == 1 (SET "wset.over=-y") ELSE (SET "wset.over=")
IF %dscr% GTR 0 (SET "wset.dscr=_animpng") ELSE (SET "wset.dscr=")
SET "wset.suff=!wset.dscr!.png"

ECHO [-----------------------------------------------------------------------------------]
ECHO [ %argCount% files queued to encode

FOR /L %%i IN (1,1,%argCount%) DO (

ECHO [---------------------------------------------------------------------------------]
ECHO [ Transcoding %%i of %argCount%: !argVn[%%i]!
ECHO [-----------------------------------------------------------------------------------]

for /F "delims=" %%f in ('call "%ffpath%ffprobe.exe" -v error -show_entries "format=duration" -of "default=noprint_wrappers=1:nokey=1" "!argVec[%%i]!"') do echo [ Video length is: %%f
FOR /F "tokens=* delims=" %%f IN ('call "%ffpath%ffprobe.exe" -v error -show_entries "format=duration" -of "default=noprint_wrappers=1:nokey=1" "!argFile[%%i].name!"') DO SET "vlen=%%f"

"%ffpath%ffmpeg.exe" -v %vbl% -hide_banner -stats -i "!argVec[%%i]!" -f apng -plays 0 -y "!argVn[%%i]!%dscrName%.png"
)
IF !vlen! NEQ "N/A" (
ECHO [ The source is a single image file with no length

IF !imgseq! GTR 0 (
REM detecting image sequence
IF !frcounter! GTR 0 (
REM detecting the counter in the end of the filename
SET "basename=!argFile[%%i].trname:~0,-%frcounter%!"
SET "countername=!argFile[%%i].trname:~-%frcounter%!"
FOR /F "tokens=* delims=0" %%N IN ("!countername!") DO SET /A frnumber=%%N
IF !frnumber! GTR 0 (
SET "argFile[%%i].name=!argFile[%%i].path!!basename!%%0!frcounter!d!argFile[%%i].ext!"
ECHO [ Image sequence detected ]
ECHO [ Basename: "!basename!" Start frame: !frnumber! Pattern: "!basename!%%0!frcounter!d"
SET "seqfr=-framerate %fps% -start_number !frnumber! -pattern_type sequence"
SET "seqfrout=-r %fps%"
) ELSE (
SET "seqfr="
SET "seqfrout="
)
) ELSE (
REM detecting the counter after first found dot
REM No implementation yet
)
) ELSE (
SET "seqfr="
SET "seqfrout="
)
) ELSE (
echo [ Video length is: !vlen! seconds
)

:End
ECHO [---------------------------------------------------------------------------------]
ECHO [ SERVED ]
ECHO [---------------------------------------------------------------------------------]
ECHO [ Transcoding %%i of %argCount%: !argFile[%%i].trname!
"%ffpath%ffmpeg.exe" !wset.params! !seqfr! -i "!argFile[%%i].name!" !wset.videocomp! !wset.audiocomp! !seqfrout! !wset.over! "!argFile[%%i].trname!"!wset.suff!
)

if %pse% GTR 0 PAUSE
ECHO [-----------------------------------------------------------------------------------]
ECHO [ SERVED ]
ECHO [-----------------------------------------------------------------------------------]

rem the main settings are defined in file sendtoffmpeg_settings.cmd, read the description inside it
:End
if %pse% GTR 0 PAUSE
Loading

0 comments on commit 2c3c189

Please sign in to comment.