Advertisement
Guest User

Untitled

a guest
May 26th, 2015
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.54 KB | None | 0 0
  1. @echo off
  2. REM Webm Audio + Picture converter Version 1.0
  3. REM Usage: webmMusic.bat <audio> [additional ffmpeg options]
  4. REM The additional options must be provided as one argument e.g. "-s 640x360 -ss 30 -t 50" including quotes.
  5. REM Example:
  6. REM webmMusic.bat audio.mp3 "-s 192x108 -t 30"
  7. REM
  8. REM Alternate usage: Drag and drop audio file onto .bat file.
  9. REM
  10. REM Features automagic title-guessing and album art discovery.
  11.  
  12. REM ------- Tweakable parameters -------
  13.  
  14. REM Edit these to the locations of ffprobe and ffmpeg
  15. set ffmpeg=C:\Users\NAME\Downloads\ffmpeg-2.5.2-win64-static\bin\ffmpeg.exe
  16. set ffprobe=C:\Users\NAME\Downloads\ffmpeg-2.5.2-win64-static\bin\ffprobe.exe
  17.  
  18. REM Audio bitrate parameter
  19. set abr=192k
  20.  
  21. REM ------- Code begins here --------
  22.  
  23. REM Hack to get the time in UTC
  24. for /f %%x in ('wmic path win32_utctime get /format:list ^| findstr "="') do set %%x
  25. set today=%Year%-%Month%-%Day% %Hour%:%Minute%:%Second%
  26.  
  27. REM Hack to get duration
  28. for /f %%x in ('%ffprobe% %1 -loglevel quiet -show_format ^| findstr "="') do set %%x
  29. REM Should now have set %duration%
  30. set title=
  31. set artist=
  32. for /f "tokens=2 delims=:" %%x in ('%ffprobe% %1 -loglevel quiet -show_format ^| findstr "=" ^| findstr TAG') do (set %%x)
  33. REM Should have set %title% and %artist%
  34.  
  35. set image=
  36. for /f %%x in ('%ffprobe% %1 -loglevel quiet -show_streams ^| findstr "mjpeg"') do (set image="-")
  37. REM If audio has album art (an mjpeg stream) try to use it.
  38.  
  39. setlocal enabledelayedexpansion
  40. if ["%image%"]==[""] (
  41. set /p image="Path to background image (Or drag it into this window): "
  42. ) else (
  43. set /p image2="Path to background image [Default - Album art]: "
  44. if not ["!image2!"]==[""] (
  45. set image=!image2!
  46. set pipecmd=
  47. ) else (
  48. REM If we want to use album art, we have to pipe it in as a jpeg so we can use -loop 1
  49. set pipecmd="%ffmpeg%" -i %1 -map 0:v -f image2 -r 1 -c:v mjpeg - ^|
  50. )
  51. )
  52. if ["%title%"]==[""] set /p title="Track Title: "
  53. if ["%artist%"]==[""] set /p artist="Track Artist: "
  54. set options=-metadata title="%title% - %artist%" %~2
  55.  
  56. %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
  57. %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"
  58. DEL /Q /F ffmpeg2pass-0.log
  59. echo Encode complete.
  60. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement