How to speed a video 2 times

This time I will post the command to make a video to have a double time speed, just in case you could need it, like I think I will, because I will use this command very often in the next posts.

The best way to do it

I tried this code and it works. Try this first, becouse the following commands gave me so strange paused video at the end of them. Maybe for you could be different, so I leave that part, but for me the commands below worked well

ffmpeg -i output14.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output000.mp4

I saved this as a .bat file.

Let’s use the mighty and polished language of Python for this

With Python is all easy, so here is the code to make a right and fast use of ffmpeg:

import os, glob

def menu():
	lst = [str(n) + " " + file for n,file in enumerate(glob.glob("*.mp4"))]
	print(*lst, sep="\n")
	file = glob.glob("*.mp4")[int(input("File n."))]
	return file
#print(file)

# This is what it is executed below using the file input above
file = menu()
output = os.path.splitext(file)[0] + "_2xb" + ".mp4"
cmd = f"""ffmpeg -i {file} -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" {output}
pause
"""

os.system(cmd) # run the ffmpeg command to 4x velocity
os.startfile(f"{output}") # runs the video

Other ways

I do not suggest you to use these other methods, but if the first it is not good for you, try the following.

ffmpeg.exe -i input.mp4 -filter_complex "[0:v]setpts=PTS/1.3[v];[0:a]atempo=1.3[a]" -map "[v]" -map "[a]" output.mp4

It could be always a good Idea to make a script in Python to make this command more flexible, so I think I will post also something about this idea in the next days.

Another way

This is annother way to do it. It makes it faster but not 2 times faster, just 1.3 faster.

ffmpeg.exe -i output1.mp4 -filter_complex "[0:v]setpts=PTS/1.3[v];[0:a]atempo=1.3[a]" -map "[v]" -map "[a]" output_1_3.mp4

A script to trim with ffmpeg via Python

With this script you can choose the video in the folder and make the speed go 4 time faster.

import os

def menu():
	lst = [str(n) + " " + file for n,file in enumerate(os.listdir())]
	print(*lst, sep="\n")
	file = os.listdir()[int(input("File n."))]
	return file
#print(file)

# This is what it is executed below using the file input above
file = menu()
output = os.path.splitext(file)[0] + "_2xb" + ".mp4"
cmd = f"""ffmpeg.exe -i {file} -filter:v "setpts=0.25*PTS" {output}

pause
"""

os.system(cmd) # run the ffmpeg command to 4x velocity
os.startfile(f"{output}") # runs the video

 

Ffmpeg & Python for videos

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.