-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmixin.py
77 lines (62 loc) · 1.81 KB
/
mixin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
master
watch MKV file, then upload to ftp server
need curl, alternative ftp or rsync
"""
import os
import json
import hashlib
SRC_audio = "inputAudio"
SRC_video = "inputVideo"
DIST = "output"
FILE_list = None
def load():
pass
# global SRC
# global DIST
# global CURL_cmd
# global FILE_list
# data = None
# with open("info.json", 'r', encoding='utf-8') as f:
# data = json.load(f)
# SRC = data["src"]
# DIST = data["dist"]
# CURL_cmd = data["curlCmd"]
# FILE_list = data["infoArr"]
def launch():
if not os.path.exists(SRC_audio):
raise
if not os.path.exists(SRC_video):
raise
FILE_list = os.listdir(SRC_video)
for file_video in FILE_list:
mainname = file_video.rsplit('.',1)[0] # remove mp4 in the end
file_audio = mainname + ".m4a"
file_output = mainname + ".mp4"
print(SRC_audio + "/" + file_audio)
if not os.path.exists(SRC_audio + "/" + file_audio):
print("Audio is missing!!")
break
audiosafe = " \"" + SRC_audio + "/" + file_audio + "\" "
videosafe = " \"" + SRC_video + "/" + file_video + "\" "
outputsafe = " \"" + DIST + "/" + file_output + "\" "
param = " -c:v copy -c:a copy "
ffmpeg_cmd = "ffmpeg -i " + audiosafe +" -i " + videosafe + param + outputsafe
lumos(ffmpeg_cmd)
def lumos(cmd):
# print(cmd)
# res = 0
print("CMD ➜ " + cmd)
res = os.system(cmd)
return res
def precheck():
global FILE_list
global SRC
for item in FILE_list:
filename = item["file"]
filepath = SRC + "\\" + filename
if not os.path.exists(filepath):
raise Exception("Missing " + filepath)
print("==== Precheck is OK ====")
if __name__ == '__main__':
launch()