Slow and fast motion video using ffpmeg, with music options

Forum Forums General Tips and Tricks Slow and fast motion video using ffpmeg, with music options

  • This topic has 0 replies, 1 voice, and was last updated Apr 7-11:58 am by sleekmason.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #8905
    Member
    sleekmason

      I decided recently to explore the slow motion and fast motion options in ffmpeg. http://ffmpeg.org/
      The idea being that I would/could create a video with music at varying speeds.

      This has turned out to be all sorts of fun. No doubt you have seen videos online of hiking, cycling, etc, at fast speed with some groovy music attached.

      TomTom, and probably GoPro (don’t own one) have proprietary programs you can download and use in order to create such effects if you are so inclined, but they are limited in scope. There are linux programs as well like Openshot and KDELive, though neither have worked for me, Not to mention the bloat.

      Because I want further control over my videos, I use ffmpeg. Using the command line greatly reduces the resources and speeds up the process.


      The command option for changing the speed of your video to a faster rate is:
      filter:v "setpts=0.2*PTS"

      The 0.2 option changes your video to 5 times as fast. 0.5 is twice as fast, and so on.

      The above code should be added to whatever other options you wish to use.

      As an example, To add padding, and set it all up for a dvd I use this:
      ffmpeg -i slow.mkv -vf "pad=5/4*iw:5/4*ih:(ow-iw)/2:(oh-ih)/2" -b:v 8600k -filter:v "setpts=4*PTS" -target ntsc-dvd movievideo.mpg


      Please note that you will need to change “slow.mkv” to whatever file name and video format you are using. (MP4, MPEG, .mov, etc . . .)


      In order to slow down your video, use the same command, changing the 0.2 number to the positive number of times you want the video speed to be:
      filter:v "setpts=2*PTS"

      The above sets the speed to 1/2, while “setpts=4*PTS” would make your video 4 times as slow, and so on.


      One caveat of the slow motion setting is that it will make your video judder.

      There is a way to take care of that as well though the quality suffers greatly.

      Use interpolate to change your slow motion video into a smoother product:

      ffmpeg -i Movievideo.mpg -filter "minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=120'" -an Smoothvideo.mpg
      -

      The above will also remove any audio from the video, while removing the judder. The quality is sorely lacking and I am still exploring a way to fix this. Also note that this takes a long time. Small files are best.


      In order to add music, I have found the program Avidemux to be the easiest method. http://avidemux.sourceforge.net/

      Upon opening avidemux, click “file” –> “open”, and select the video you wish to use.

      Then click on audio –> select track.

      Change the existing track to whatever music you wish.

      *NOTE Avidemux will only add mp3 files from my experience. Ogg, and others won’t work. This is easy to rectify though by using ffmpeg to convert whatever music you want to the mp3 format:
      ffmpeg -i homesoundtrack.ogg homesoundtrack.mp3

      The above command will change .ogg to .mp3. You can do this for any music file/type you wish.


      Once back in the main screen, go to “file”, and save your video. The audio will now be whatever music you listed.

      *NOTE This will replace your audio, not add to it. The options you see in “audio” for different tracks means only that you can specify which one to use during transcoding, not more than one to use.

      To string music together, OR to add music to the existing audio track, you will need to use a program like Audacity to mix your audio. http://www.audacityteam.org/

      Audacity is an awesome program. Earlier today I was able to subtract waterfall noise from the sound of birds in the background, and then add those bird sounds to another audio file. I then added the resultant audio file back to the original waterfall video.

      The learning curve for audacity isn’t all that bad once you get used to it and you will find more options and plugins than you know what to do with!


      For a super simple script to make a dvd using ffmpeg see here: how-to-create-a-dvd-from-the-command-line


      Code source for this post:
      http://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video

      • This topic was modified 6 years, 1 month ago by sleekmason.
      • This topic was modified 6 years, 1 month ago by sleekmason.
      • This topic was modified 6 years, 1 month ago by sleekmason.
    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.