Advertisement
zefie

create video from audio with ffmpeg

Apr 30th, 2017
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. set ztmp_ffmpeg=C:\bin\ffmpeg64.exe
  3. setlocal EnableExtensions
  4. setlocal EnableDelayedExpansion
  5. set ztmp_res=%~dp0
  6. set ztmp_font=%ztmp_res:\=\\%segoesc.ttf
  7. set ztmp_font=%ztmp_font::=\:%
  8. set ztmp_src=%1
  9. set ztmp_dest=%~n1.mp4
  10. set ztmp_fps=60
  11. set ztmp_text=%2
  12. set ztmp_text=%ztmp_text:"=%
  13. set ztmp_fontsize=48
  14. set ztmp_filter="[0:a]showwaves=s=1920x220:mode=line:r=%ztmp_fps%:colors=0x6441A4|0x6441A4|0x6441A4|0x6441A4:scale=lin:split_channels=1,colorkey=black,fps=%ztmp_fps%[sw]; "
  15. set ztmp_filter="%ztmp_filter:"=%[0:a]showcqt=text=0:s=1920x820:r=%ztmp_fps%:cscheme=0.390625|0.25390625|0.640625|0.390625|0.25390625|0.640625:bar_t=0.5:bar_h=200:bar_v=5:sono_v=8:axis_h=2,colorkey=black,fps=%ztmp_fps%[sc]; "
  16. set ztmp_filter="%ztmp_filter:"=%[0:a]showvolume=r=60:w=1920:f=0.5:c=0xFFA44164[sv]; "
  17. set ztmp_filter="%ztmp_filter:"=%[sv][sw]vstack,fps=%ztmp_fps%[fs]; "
  18. set ztmp_filter="%ztmp_filter:"=%[fs][sc]vstack,fps=%ztmp_fps%[fo]; "
  19. set ztmp_filter="%ztmp_filter:"=%[3:v]alphaextract[a]; "
  20. set ztmp_filter="%ztmp_filter:"=%[2:v][a]alphamerge[bg]; "
  21. set ztmp_filter="%ztmp_filter:"=%[1:v][bg]overlay,fps=60[bgo]; "
  22. set ztmp_filter="%ztmp_filter:"=%[bgo][fo]overlay,fps=%ztmp_fps%"
  23.  
  24. set ztmp_extrafilter="[vo]; "
  25. set ztmp_extrafilter="%ztmp_extrafilter:"=%[vo][4:v]overlay,fps=%ztmp_fps%[vo2]; "
  26. set ztmp_extrafilter="%ztmp_extrafilter:"=%[vo2]drawtext=fontcolor=white@0.8:fontsize=%ztmp_fontsize%:box=0:x=(w-text_w)/2:y=(h-text_h)-14:fontfile='%ztmp_font%':text='%ztmp_text%'"
  27.  
  28. set ztmp_images=-f lavfi -i color=c=black:s=1920x1080:r=60:d=0.5
  29. set ztmp_images=%ztmp_images% -f lavfi -i color=c=0x0F0C1B:s=1920x1080:r=60:d=0.5
  30. set ztmp_images=%ztmp_images% -i "%ztmp_res%bg_alpha.png"
  31.  
  32. if not [%2]==[] (
  33.   set ztmp_images=%ztmp_images% -i "%ztmp_res%overlay.png"
  34.   set ztmp_filter="%ztmp_filter:"=%%ztmp_extrafilter:"=%"
  35. q)
  36.  
  37. if exist "%ztmp_src%" (
  38.   %ztmp_ffmpeg% -i "%ztmp_src%" %ztmp_images% -filter_complex "%ztmp_filter:"=%[out]" -map "[out]" -map 0:a -c:v libx264 -b:v 10240k -b:a 192k -g 15 -r %ztmp_fps% -c:a aac -f mp4 "%ztmp_dest%"
  39. ) else (
  40.     echo Could not find file %ztmp_src%
  41.     goto :failed
  42. )
  43.  
  44. goto :cleanup
  45.  
  46. :cleanup
  47. set "ztmp_res="
  48. set "ztmp_font="
  49. set "ztmp_fontsize="
  50. set "ztmp_src="
  51. set "ztmp_dest="
  52. set "ztmp_fps="
  53. set "ztmp_text="
  54. set "ztmp_filter="
  55. set "ztmp_images="
  56. goto :eof
  57.  
  58. :failed
  59. echo This stage of the encoding has failed...
  60. goto :cleanup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement