Skip to content

Instantly share code, notes, and snippets.

@97997
Created February 14, 2021 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 97997/b170e8dc282788f59a945d22ad21ee14 to your computer and use it in GitHub Desktop.
Save 97997/b170e8dc282788f59a945d22ad21ee14 to your computer and use it in GitHub Desktop.
ffmpeg tool.py
#Makes a trim of video using fmmpeg
import os
import tkinter as tk
from tkinter import filedialog
def filePick():
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename()
return file_path
#Unused function
def fileSave():
root = tk.Tk()
root.withdraw()
file_path = filedialog.asksaveasfilename()
return file_path
input("Press enter to select file to trim")
filepath = filePick()
startTime = input("Write start time, in format hh:mm:ss (00:00:00 for example): ")
endTime = input("Write end time, in format hh:mm:ss (00:00:00 for example): ")
#editedName = os.path.basename(filepath)
editedName = os.path.splitext(filepath)[0] + "_trim" + os.path.splitext(filepath)[1]
shortVid = input("Is the trimmed section less than 10 seconds? [y/n]")
if shortVid == "y":
wizardry = 'ffmpeg -i \"' + filepath + '\" -ss ' + startTime + ' -to ' + endTime + ' \"' + editedName + '\"'
if shortVid == "n":
wizardry = 'ffmpeg -i \"' + filepath + '\" -ss ' + startTime + ' -to ' + endTime + ' -c copy \"' + editedName + '\"'
#print(wizardry)
os.system(wizardry)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment