How to make slow video with ffmpeg and sox command

OS: Windows, MacOS X, Linux  

OpenSource software: ffmpeg, sox

Optional software: youtube-dl 
    (to download Youtube video)
   Simple usage: youtube-dl YouTubeVideoURL

Command Line Example

half speed (easy)


  ffmpeg  -i input.mp4 -filter_complex \
        "setpts=2*PTS;atempo=0.5" \
        -codec:a aac -strict -2 -q:v 0 output.mp4

  (sox command is not used)

Note: Range of atempo value is 0.5 to 2.0 

quarter speed (need to process audio separately)


  in 4 steps

  1) process video

     ffmpeg  -i input.mp4 -filter_complex \
        "setpts=4*PTS" -an -q:v 0 video.mp4

  2) extract PCM audio

    ffmpeg  -i input.mp4 -filter_complex -vn audio.wav

  3) process PCM audio

  sox audio.wav slow.wav tempo 0.25

  4) join video and audio

  ffmpeg -i video.mp4 -i slow.wav \
        -vcodec copy -acodec aac -strict -2 output.mp4

  Note: Audio quality becomes really bad but better than nothing. 

How to get the software

ffmpeg
   MacOS X: search with "ffmpeg MacOS"
   Windows: search with "ffmpeg Windows"
   Linux: with standard package manager (apt-get, synaptic etc.) 
     or compile the latest version from source
     (If ffmpeg version in the package is too old.)
sox
  All OS: http://sourceforge.net/projects/sox/files/sox/14.4.1/
  (Old package should work for tempo.)

youtube-dl
  http://rg3.github.io/youtube-dl/ (Any platform) 

  Linux, Mac OS: get the Phython source code.
  Windows: get an executable file includes Python is available
  

goto at kmgoto.jp
Feel free to use/modify the contents. Credits are welcome.