ffmpeg-spectogram.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. ffmpeg -i "$1" -filter_complex "[0:a]showwaves=s=1280x720:mode=line:rate=25, format=yuv420p[v]" -map "[v]" -map 0:a "${1%.*}.${2:-mp4}"
  4. # https://blog.grio.com/2016/07/fractals-and-music-visualization-with-ffmpeg.html
  5. # [code language=”bash”]ffmpeg -i spectrum.mkv -vf drawtext="fontsize=50:fontfile=/Library/Fonts/Arial.ttf:text=’Wolf-e-Wolf – Purple Planet’:fontcolor=black:x=(w-text_w)/2:y=h-(2*text_h)" -b 2048k text-hd.avi[/code]
  6. # [code language=”bash”]ffmpeg -i high-adventure.mp3 -filter_complex "[0:a]showspectrum=s=hd1080[v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy spectrum.mkv[/code]
  7. # [code language=”bash”]ffmpeg -i high-adventure.mp3 -filter_complex "[0:a]showspectrum=s=1280×720,format=yuv420p[v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy spectrum.mkv[/code]
  8. # [code language=”bash”]FFmpeg -i Imagine\ The\ Future.mp3 -i mandelbrot.mkv -b 2048k -to 03:57 mandelbrot-imagine-short.avi[/code]
  9. # [code language=”shell”]ffmpeg -f lavfi -i mandelbrot mandelbrot.mkv[/code]
  10. # # https://video.stackexchange.com/questions/9644/how-do-i-turn-audio-into-video-that-is-show-the-waveforms-in-a-video
  11. # You can use ffmpeg to create video from audio using several filters.
  12. # ahistogram
  13. # Convert input audio to a video output, displaying the volume histogram.
  14. # ahistogram
  15. # ffmpeg
  16. # ffmpeg -i input.flac -filter_complex \
  17. # "[0:a]ahistogram,format=yuv420p[v]" \
  18. # -map "[v]" -map 0:a output.mp4
  19. # ffplay
  20. # ffplay -f lavfi "amovie=input.flac, asplit [a][out1]; [a] ahistogram [out0]"
  21. # See the ahistogram documentation for more options and examples.
  22. # aphasemeter
  23. # Convert input audio to a video output, displaying the audio phase.
  24. # aphasemeter
  25. # ffmpeg
  26. # ffmpeg -i input.wav -filter_complex \
  27. # "[0:a]aphasemeter=s=1280x720:mpc=cyan,format=yuv420p[v]" \
  28. # -map "[v]" -map 0:a output.mp4
  29. # ffplay
  30. # ffplay -f lavfi "amovie=input.wav, asplit [a][out1]; [a] aphasemeter=s=1280x720:mpc=cyan [out0]"
  31. # See the aphasemeter documentation for more options and examples.
  32. # avectorscope
  33. # avectorscope filter
  34. # Convert input audio to a video output, representing the audio vector scope.
  35. # ffmpeg
  36. # ffmpeg -i input.mp3 -filter_complex \
  37. # "[0:a]avectorscope=s=1280x720,format=yuv420p[v]" \
  38. # -map "[v]" -map 0:a output.mp4
  39. # ffplay
  40. # ffplay -f lavfi "amovie=input.mp3, asplit [a][out1]; \
  41. # [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]"
  42. # See the avectorscope documentation for more options and examples.
  43. # showcqt
  44. # showcqt filter
  45. # Convert input audio to a video output representing frequency spectrum with musical tone scale.
  46. # ffmpeg
  47. # ffmpeg -i input.mp4 -filter_complex \
  48. # "[0:a]showcqt,format=yuv420p[v]" \
  49. # -map "[v]" -map 0:a output.mp4
  50. # ffplay
  51. # ffplay -f lavfi "amovie=input.mp4, asplit [a][out1]; [a] showcqt [out0]"
  52. # See the showcqt documentation for more options and examples.
  53. # showfreqs
  54. # Convert input audio to video output representing the audio power spectrum. Audio amplitude is on Y-axis while frequency is on X-axis.
  55. # showfreqs
  56. # ffmpeg
  57. # ffmpeg -i input.mp4 -filter_complex \
  58. # "[0:a]showfreqs=mode=line:fscale=log,format=yuv420p[v]" \
  59. # -map "[v]" -map 0:a output.mp4
  60. # ffplay
  61. # ffplay -f lavfi "amovie=input.mp4, asplit [a][out1]; [a] showfreqs=mode=line:fscale=log [out0]"
  62. # See the showfreqs documentation for more options and examples.
  63. # showspectrum
  64. # showspectrum image
  65. # Convert input audio to a video output, representing the audio frequency spectrum.
  66. # ffmpeg
  67. # ffmpeg -i input.oga -filter_complex \
  68. # "[0:a]showspectrum=s=1280x720,format=yuv420p[v]" \
  69. # -map "[v]" -map 0:a output.mp4
  70. # ffplay
  71. # ffplay -f lavfi "amovie=input.oga, asplit [a][out1]; \
  72. # [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]"
  73. # See the showspectrum documentation for more options and examples.
  74. # showwaves
  75. # showwaves filter
  76. # Convert input audio to a video output, representing the samples waves.
  77. # ffmpeg
  78. # ffmpeg -i input.m4a -filter_complex \
  79. # "[0:a]showwaves=s=1280x720:mode=line:rate=25,format=yuv420p[v]" \
  80. # -map "[v]" -map 0:a output.mp4
  81. # ffplay
  82. # ffplay -f lavfi "amovie=input.m4a, asplit [a][out1]; [a] showwaves [out0]"
  83. # See the showwaves documentation for more options and examples.
  84. # showvolume
  85. # showvolume filter
  86. # Convert input audio volume to a video output.
  87. # ffmpeg
  88. # ffmpeg -i input.mka -filter_complex \
  89. # "[0:a]showvolume=f=1:b=4:w=720:h=68,format=yuv420p[vid]" \
  90. # -map "[vid]" -map 0:a output.mp4
  91. # ffplay
  92. # ffplay -f lavfi "amovie=input.mka, asplit [a][out1]; [a] showvolume=f=255:b=4:w=720:h=68 [out0]"
  93. # See the showvolume documentation for more options and examples.