Video frame compressor

To save memory making videos is a good idea to limit frame rate if you do not need to have a high frame rate, like I do not need it when I make video about coding.

So, you can use ffmpeg to do this. This is how to make a video to have a 10 speed frame rate, woithout losing sync with the audio:

ffmpeg -i input.mp4 -filter:v fps=fps=10 output.mp4

It makes an mp4 to be very light.

A script to automate stuff

import os
from glob import glob

print("go")
mp4 = [(n, f) for n, f in enumerate(glob("*.mp4"))]
print(mp4)
command = os.system("ffmpeg -i {} -filter:v fps=fps=10 {}.mp4".format(mp4[int(input("input:"))][1], input("output: ")))

Graphic user interface for video frame compressor

import os
from glob import glob
from moviepy.editor import VideoFileClip
# print("go")
# mp4 = [(n, f) for n, f in enumerate(glob("*.mp4"))]
# print(mp4)
# command = os.system("ffmpeg -i {} -filter:v fps=fps=10 {}.mp4".format(mp4[int(input("input:"))][1], input("output: ")))


import tkinter as tk
from glob import glob

def launch(movie):
    command = os.system("ffmpeg -i {} -filter:v fps=fps=10 output.mp4".format(movie))
    info(movie)

def info(movie):
    clip = VideoFileClip(movie)
    print(round(clip.duration / 60, 2))


def startfile():
    os.startfile(ls.get(ls.curselection()))
    info(ls.get(ls.curselection()))
# launch("00.mp4")
root = tk.Tk()
root.geometry("400x300")
root.title("Double click to start")
x = tk.StringVar(value=[m for m in glob("*.mp4")])

ls = tk.Listbox(root, listvariable=x)
ls.pack(fill="both", expand=1)
ls.bind("<Double-Button>", lambda x: launch(ls.get(ls.curselection()[0])))

button = tk.Button(root, text="Play movie", command=startfile)
button.pack()

root.mainloop()



# start = input("number movie input: ")
# start = mp4[int(start)]
# output = input("NAME movie output: ") + ".mp4"

# os.system(command.format(start, output))

Coming soon new version

I will make a newer version with also a way to change the frame rate and the name of the output file in the GUI. If you want me to do it faster, subscribe to my youtube channel.

This will be the new GUI.


Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

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.