Last active
June 15, 2023 14:31
-
-
Save VladSem/c7b5325acda348d03a62 to your computer and use it in GitHub Desktop.
Cut 4 seconds of youtube video using Python and ffmpeg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bash version: https://gist.github.com/VityaSchel/7779dea70d0eafa4c5ecc6bf6a970231