Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- REM Webm Audio + Picture converter Version 1.0
- REM Usage: webmMusic.bat <audio> [additional ffmpeg options]
- REM The additional options must be provided as one argument e.g. "-s 640x360 -ss 30 -t 50" including quotes.
- REM Example:
- REM webmMusic.bat audio.mp3 "-s 192x108 -t 30"
- REM
- REM Alternate usage: Drag and drop audio file onto .bat file.
- REM
- REM Features automagic title-guessing and album art discovery.
- REM ------- Tweakable parameters -------
- REM Edit these to the locations of ffprobe and ffmpeg
- set ffmpeg=C:\Users\NAME\Downloads\ffmpeg-2.5.2-win64-static\bin\ffmpeg.exe
- set ffprobe=C:\Users\NAME\Downloads\ffmpeg-2.5.2-win64-static\bin\ffprobe.exe
- REM Audio bitrate parameter
- set abr=192k
- REM ------- Code begins here --------
- REM Hack to get the time in UTC
- for /f %%x in ('wmic path win32_utctime get /format:list ^| findstr "="') do set %%x
- set today=%Year%-%Month%-%Day% %Hour%:%Minute%:%Second%
- REM Hack to get duration
- for /f %%x in ('%ffprobe% %1 -loglevel quiet -show_format ^| findstr "="') do set %%x
- REM Should now have set %duration%
- set title=
- set artist=
- for /f "tokens=2 delims=:" %%x in ('%ffprobe% %1 -loglevel quiet -show_format ^| findstr "=" ^| findstr TAG') do (set %%x)
- REM Should have set %title% and %artist%
- set image=
- for /f %%x in ('%ffprobe% %1 -loglevel quiet -show_streams ^| findstr "mjpeg"') do (set image="-")
- REM If audio has album art (an mjpeg stream) try to use it.
- setlocal enabledelayedexpansion
- if ["%image%"]==[""] (
- set /p image="Path to background image (Or drag it into this window): "
- ) else (
- set /p image2="Path to background image [Default - Album art]: "
- if not ["!image2!"]==[""] (
- set image=!image2!
- set pipecmd=
- ) else (
- REM If we want to use album art, we have to pipe it in as a jpeg so we can use -loop 1
- set pipecmd="%ffmpeg%" -i %1 -map 0:v -f image2 -r 1 -c:v mjpeg - ^|
- )
- )
- if ["%title%"]==[""] set /p title="Track Title: "
- if ["%artist%"]==[""] set /p artist="Track Artist: "
- set options=-metadata title="%title% - %artist%" %~2
- %pipecmd% "%ffmpeg%" -y -vn -i %1 -r 1 -loop 1 -i %image% -t %duration% -map 1:v -map 0:a -c:v libvpx-vp9 -b:v 10k -quality good -c:a libopus -b:a %abr% %options% -metadata creation_time="%today%" -threads 0 -f webm -an -pass 1 NUL
- %pipecmd% "%ffmpeg%" -y -vn -i %1 -r 1 -loop 1 -i %image% -t %duration% -map 1:v -map 0:a -c:v libvpx-vp9 -b:v 10k -quality good -c:a libopus -b:a %abr% %options% -metadata creation_time="%today%" -threads 0 -f webm -pass 2 "%~n1.webm"
- DEL /Q /F ffmpeg2pass-0.log
- echo Encode complete.
- pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement