Skip to content

Instantly share code, notes, and snippets.

@hongthaiphi
Created April 25, 2017 17:49
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 hongthaiphi/3aa09c91988313ba72adfd76772e88af to your computer and use it in GitHub Desktop.
Save hongthaiphi/3aa09c91988313ba72adfd76772e88af to your computer and use it in GitHub Desktop.
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