PasteRack.org
Paste # 97543
2020-04-01 12:07:10

Fork as a new paste.

Paste viewed 191 times.


Embed:

ffmpeg for videos

  1. #lang racket
  2.  
  3. (define (make-ffmpeg-command infile outfile textfile)
  4.   (string-join (list
  5.                 ;; Input
  6.                 "ffmpeg -i" infile "-i" WATERMARK_PATH
  7.  
  8.                 ;; Filter
  9.                 (string-append
  10.                  "-filter_complex \""
  11.  
  12.                  ;; Spectrogram
  13.                  "[0:a]showspectrum=s=1280x720:mode=combined:slide=scroll:color=fruit:fps=15:scale=log,format=yuv420p[spectrogram];"
  14.  
  15.                  ;; Watermark
  16.                  "[spectrogram][1:v]overlay[spectrogram];"
  17.  
  18.                  ;; Waveform
  19.                  "[0:a]showwaves=mode=line:s=1280x720:split_channels=1:colors=#ffaaffbb:rate=15:scale=sqrt[waveform];"
  20.  
  21.                  ;; Combine
  22.                  "[spectrogram][waveform]overlay[viz];"
  23.  
  24.                  ;; Text
  25.                  "[viz]drawtext="
  26.                  "textfile=" textfile
  27.                  ":expansion=none"
  28.                  ":font=Linux Libertine O"
  29.                  ":fontsize=28"
  30.                  ":fontcolor=White"
  31.                  ":x=240:y=(h/2 - text_h/2 + 15)"
  32.                  "[out]"
  33.  
  34.                  "\"")
  35.  
  36.                 ;; Output map
  37.                 "-map [out]" "-map 0:a"
  38.  
  39.                 ;; Codecs
  40.                 "-codec:v libx264"
  41.                 "-codec:a aac"
  42.                 "-b:a 128k"
  43.                 "-crf 20"
  44.                 "-preset slow"
  45.  
  46.                 ;; Testing
  47.                 ;; "-preset ultrafast"
  48.                 ;; "-t 30"
  49.  
  50.                 ;; Output
  51.                 outfile)))

=>