Skip to content

Instantly share code, notes, and snippets.

@insideClaw
Last active June 25, 2022 00:17
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 insideClaw/2950da89c66625ef9260c49d64c65aca to your computer and use it in GitHub Desktop.
Save insideClaw/2950da89c66625ef9260c49d64c65aca to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import subprocess
import os, shutil
directory = '.'
dir_trash = "processed_DELETEME"
if not os.path.isdir(dir_trash):
os.mkdir(dir_trash)
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
# checking if it is a file
if os.path.isfile(f):
cmd = 'ffmpeg -ss 00:00:04 -i "' + filename + '" -map 0 -c copy "temp-' + filename + '"'
print(cmd)
conversion = subprocess.Popen(cmd,shell=True)
conversion.wait()
print("Conversion for " + filename + " finished")
shutil.move(filename, dir_trash + "/" + filename)
shutil.move("temp-" + filename, filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment