Last active
May 3, 2023 18:36
-
-
Save turbulentie/b081de1696b5fe611810ebeb6220b1b4 to your computer and use it in GitHub Desktop.
Small batch script for converting RIFF WAV files to RF64 using ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
::----------------------------------------------------------------------------- | |
:: Small batch script for converting RIFF WAV files to RF64 using ffmpeg | |
:: Location of ffmpeg binary should be sets globally or via PATH= env ^ | |
::----------------------------------------------------------------------------- | |
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
:Loading | |
if "%1"=="" goto help | |
if "%2"=="" goto help | |
if "%1"=="/?" goto help | |
if "%1"=="-h" goto help | |
goto Start | |
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
:help | |
echo. | |
echo Small batch script for converting RIFF WAV files to RF64 using ffmpeg | |
echo. | |
echo Help. | |
echo Usage: %~n0 -rf64 "inputfile" "outputfile" | |
echo Usage: %~n0 -concat "outputfile" | |
echo Usage: %~n0 -concat --random | |
echo. | |
echo -rf64: Save WAV file with RF64 Header. Output filename can be omitted and name will given based on input file with '-rf64' prefix: "-rf64.wav" | |
echo -concat: Concatenate multiple WAV files into a single WAV file. Script should be executed in same folder where multiple WAV files located. Usage with '--random' generates random name of output file. | |
echo -help: Show this help info. | |
echo. | |
goto end | |
:Start | |
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
if "%1"=="-rf64" goto rf64 | |
if "%1"=="-concat" goto concat | |
goto help | |
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
:rf64 | |
set infile="%2" | |
if "%3"=="" ( | |
set outfile="%~n2-rf64.wav" | |
echo "%~n0: Output file not specified. Using basename of input file: %~n2-rf64.wav" | |
) else ( | |
set outfile="%3" | |
) | |
if exist "%infile%" ( | |
ffmpeg -i "%infile%" -c copy -rf64 auto "%outfile%" | |
) else ( | |
echo %~n0: Input File: %infile% for not found! | |
) | |
goto end | |
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
:concat | |
set tmplist="%RANDOM%.lst" | |
if "%2"=="--random" ( | |
set outfile="%RANDOM%-rand-rf64.wav" | |
echo "%~n0: Output file not specified. Using random name of output file: %outfile%" | |
) else ( | |
set outfile="%2" | |
) | |
(for %%i in (*.wav) do ( | |
@echo file '%%i') | |
) > "%tmplist%" | |
if exist "%tmplist%" ( | |
ffmpeg -f concat -safe 0 -i %tmplist% -c copy -rf64 auto "%outfile%" | |
del /f /q %tmplist% && echo %~n0: Deleting generated list file: %tmplist% | |
) else ( | |
echo "%~n0: List file for concat not found!" | |
) | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment