-
-
Save hongthaiphi/3aa09c91988313ba72adfd76772e88af to your computer and use it in GitHub Desktop.
This file contains 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
import os | |
def list_file(path): | |
list = os.listdir(path) | |
return list | |
base_path = "/Users/phihongthai/Documents/Yicam/" | |
def create_file(list, path): | |
file_path = path + "ffmpeg-sound.txt" | |
with open(file_path, "w") as f: | |
for file in list: | |
if str(file).endswith("mp4"): | |
f.write("file " + file + "\n") | |
list_dir = list_file(base_path) | |
for dir in list_dir: | |
if not str(dir).startswith("."): | |
path = base_path + dir + "/" | |
#get list file mp4 in folder | |
list = list_file(path) | |
#write list file mp4 to a txt file | |
create_file(list, path) | |
#create command | |
out_name = dir + ".mp4" | |
cmd = "/usr/local/bin/ffmpeg -f concat -i ffmpeg-sound.txt -c copy " + out_name | |
print (path) | |
cmd1 = "cd " + path + " && " + cmd + " && mv " + out_name + " ../" | |
#run command to merge files to a file | |
os.system(cmd1) | |
#call API to upload to youtube |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment