How to increase video's FPS and speed correctly with ffmpeg?

13,573

The order should be reversed,

ffmpeg -i in -filter:v "setpts=PTS/6,fps=30" out

With the fps filter first, ffmpeg will insert 25 duplicate frames each second in order to convert 5 fps to 30, and then speed it up 6x. With the correct order, ffmpeg compresses the stream to have 30 source frames per second, and then all the fps filter ends up doing* is change the stream metadata to 30 fps.

*assuming constant frame-rate source.

Also note that YT re-encodes all videos, so your encoded keyint is not carried over by YT.

If you have audio, you'll need to that speed that up as well,

ffmpeg -i in -vf "setpts=PTS/6,fps=30" -af "atempo=6" out

Note that atempo till recently had a limit of 2, so for older versions of ffmpeg, you would use

ffmpeg -i in -vf "setpts=PTS/6,fps=30" -af "atempo=2,atempo=2,atempo=1.5" out
Share:
13,573

Related videos on Youtube

jstq
Author by

jstq

Updated on September 18, 2022

Comments

  • jstq
    jstq over 1 year

    I have a 5 fps video with keyint 120 2.5 hours long that I want to speed up 6 times, making its fps=30

    I did it with this command that I found somewhere on this website

    ffmpeg -i "...local_Record.mkv"  -filter:v "fps=30, setpts=PTS/6" "...output1.mkv"
    

    The output came laggy, its playing for 3-5 seconds and then freezes. If I jump back or forward it unfreezes for another 3-5 seconds and then freezes again. After uploading it on youtube I found that its not lagging there, however youtube shows its length as original 2.5 hours. It also shows that its processing percent is 95% for 12+ hours already (which means that this video is 100% bugged and wont ever be processed, since its 90 mb and 20 min long, and youtube can process videos that 5 gb and hour long in 10 minutes)

    Then I tried to re-encode the video I got with this command

    ffmpeg -i "...mkv" -c:v libx264 -crf 18 -preset veryfast -max_muxing_queue_size 1024 output.mp4
    

    Which gave me 133 mb result that is also shows on youtube as 2.5 hours long and never finishes processing (can be played, but its invisible, in video manager both videos say its 95% processed)

    How to do it correctly, so that video would not lag and youtube could correctly get its length?

    edit - I found what was the problem - there was some sound in container even though there werent supposed to be any sound at all (I recorded it with obs with no sound enabled). So after I removed that sound with mmg, mpc opened it correctly showing that its 26 minutes long and youtube successfully processed it in couple minutes

  • jstq
    jstq over 5 years
    Unfortunately I had to delete 6 gb of source videos so I cant test your command at the moment, but will do it for future attempts. I updated my question with an attempts to fix this already speed up video. I found some command to re-encode video in hope to fix this endless youtube processing bug that I noticed, but it didnt worked. Do you know a way to 'fix' that video, maybe some other way to re-encode it so that youtube will be able to finish video processing, and maybe even realize that its not 2.5 hours but only 26 minutes?
  • jstq
    jstq over 5 years
    nevermind I found what was the problem - there was some sound in container even though there werent supposed to be any sound at all (I recorded it with obs with no sound enabled). So after I removed that sound with mmg, mpc realized that its 26 minutes and youtube successfully processed it in couple minutes
  • jstq
    jstq over 5 years
    doing this your way (setpts first) gives me this warning after encoding finished: 100000 buffers queued in out_0_0, something may be wrong. and its there for hours loading all my cpu cores for 100% doing nothing. If I cancel it, video is unplayable
  • Gyan
    Gyan over 5 years
    Share full log.