Skip to content

Instantly share code, notes, and snippets.

@VladSem
Last active June 15, 2023 14:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VladSem/c7b5325acda348d03a62 to your computer and use it in GitHub Desktop.
Save VladSem/c7b5325acda348d03a62 to your computer and use it in GitHub Desktop.
Cut 4 seconds of youtube video using Python and ffmpeg
#!/usr/bin/python
from __future__ import print_function
import os
cur_dir = os.path.dirname(os.path.realpath(__file__))
input_folder = "original_clips/"
output_folder = "output/"
os.system("mkdir " + output_folder)
path_to_input_folder = os.path.join(cur_dir, input_folder)
path_to_output_folder = os.path.join(cur_dir, output_folder)
for file in os.listdir(path_to_input_folder):
if file.endswith(".mp4"):
fn = "'" + file + "'"
os.system("ffmpeg -i " + path_to_input_folder + fn +
" -vcodec copy -acodec copy -ss 00:00:04 " + path_to_output_folder + fn)
@VityaSchel
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment