Skip to content

Instantly share code, notes, and snippets.

@hongthaiphi
Created Apr 25, 2017
Embed
What would you like to do?
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