Skip to content

Instantly share code, notes, and snippets.

@Albirew
Created December 8, 2023 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Albirew/0cb03b3daace5df287f2ea9eb653f527 to your computer and use it in GitHub Desktop.
Save Albirew/0cb03b3daace5df287f2ea9eb653f527 to your computer and use it in GitHub Desktop.
ffmpeg scripts
@echo off
set binpath=%~dp0
if not exist "%binpath%\ffmpeg.exe" echo ffmpeg not found. exiting... & echo. & pause & exit 1
:do
if [%1]==[] goto noarg
"%binpath%\ffmpeg.exe" -hide_banner -i %1 -vn "%~dpn1.mp3"
IF %ERRORLEVEL% NEQ 0 pause
::"%binpath%\ffmpeg.exe" -i %1 -c:v libaom-av1 -preset 2 -crf 30 "%~dpn1[AV1].mkv"
::"%binpath%\ffmpeg.exe" -hwaccel cuda -hwaccel_output_format cuda -i %1 -c:v hevc_nvenc -map 0 "%~dpn1[HEVC].mkv"
shift /1
if [%1] NEQ [] goto do
exit 0
:noarg
echo Usage: %~nx0 "anything with audio to extract.flv"
echo.
pause
exit
@echo off
set binpath=%~dp0
if not exist "%binpath%\ffmpeg.exe" echo ffmpeg not found. exiting... & echo. & pause & exit 1
:do
if [%1]==[] goto noarg
cd "%1"
IF %ERRORLEVEL% NEQ 0 echo %1 & pause
if not exist "ok\" mkdir ok
IF %ERRORLEVEL% NEQ 0 pause
if not exist "orig\" mkdir orig
IF %ERRORLEVEL% NEQ 0 pause
setlocal EnableDelayedExpansion
for /f "delims=" %%a in ('dir /b *.mkv *.avi *.mp4') do (
:: speed 0.6x
"%binpath%\ffmpeg.exe" -hide_banner -hwaccel_output_format cuda -i "%%a" -c:v libsvtav1 -preset 6 -crf 30 -c:s copy -map 0 -map -v -map V "%%~dpa\ok\%%~na AV1 [AlbiRip].mkv"
IF !ERRORLEVEL! NEQ 0 pause
move "%%a" orig/
echo ----- %%~na OK -----
)
shift /1
if [%1] NEQ [] goto do
::alert, use a wav file with CLI player from https://elifulkerson.com/projects/commandline-wav-player.php
::"%binpath%\sounder.exe" "%binpath%\alert.wav"
exit 0
:noarg
echo Usage: %~nx0 "folder containig videos to convert"
echo.
pause
exit
@echo off
set binpath=%~dp0
if not exist "%binpath%\ffmpeg.exe" echo ffmpeg not found. exiting... & echo. & pause & exit 1
:do
if [%1]==[] goto noarg
::"%binpath%\ffmpeg.exe" -i %1 -c:v libaom-av1 -preset 2 -crf 30 "%~dpn1[AV1].mkv"
"%binpath%\ffmpeg.exe" -hide_banner -hwaccel_output_format cuda -i %1 -c:v libsvtav1 -preset 6 -crf 30 -map 0 -map -v -map V "%~dpn1 AV1 [AlbiRip].mkv"
IF %ERRORLEVEL% NEQ 0 pause
shift /1
if [%1] NEQ [] goto do
::alert, use a wav file with CLI player from https://elifulkerson.com/projects/commandline-wav-player.php
::"%binpath%\sounder.exe" "%binpath%\alert.wav"
exit 0
:noarg
echo Usage: %~nx0 "video to convert.flv"
echo.
pause
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment