-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
59 lines (56 loc) · 3.33 KB
/
main.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
from os import makedirs, listdir, remove, system
from os.path import isfile, join, exists, splitext, getsize
import ffmpeg
from PyCriCodecs import USM
path = "R:\Downloads\missing"
sofdec2enc = "R:/Documents/Programming/Tools/Sofdec2/sofdec2enc.exe"
for filename in listdir(path):
fullPath = join(path, filename)
if isfile(fullPath) and ".bak" in fullPath:
pathname, extension = splitext(fullPath)
extractPath = f'{pathname}-extract'
if not exists(extractPath):
makedirs(extractPath)
usmObj = USM(fullPath)
usmObj.demux()
usmObj.extract(extractPath)
if not exists(f'{extractPath}/workspace/mov_conv_work/00000.avi'):
stream = ffmpeg.input(f'{extractPath}/workspace/mov_conv_work/00000.ivf', **{"hwaccel": "nvdec"})
stream = ffmpeg.output(stream, f'{extractPath}/workspace/mov_conv_work/00000.avi', **{'qscale:v': 1})
ffmpeg.run(stream)
if exists(f'{extractPath}/workspace/mov_conv_work/audio0.hca'):
system(
f'ffmpeg -i {extractPath}/workspace/mov_conv_work/audio0.hca -filter_complex '
f'"channelmap=map=FL-FL|FR-FR|FC-BL|LFE-BR|BL-FC|BR-LFE:channel_layout=5.1" '
f'{extractPath}/workspace/mov_conv_work/audio0.wav')
if getsize(f'{extractPath}/workspace/mov_conv_work/audio0.wav') == 0:
system(
f'ffmpeg -y -i {extractPath}/workspace/mov_conv_work/audio0.hca '
f'{extractPath}/workspace/mov_conv_work/audio0.wav')
if exists(f'{extractPath}/workspace/mov_conv_work/audio1.hca'):
system(
f'ffmpeg -i {extractPath}/workspace/mov_conv_work/audio1.hca -filter_complex '
f'"channelmap=map=FL-FL|FR-FR|FC-BL|LFE-BR|BL-FC|BR-LFE:channel_layout=5.1" '
f'{extractPath}/workspace/mov_conv_work/audio1.wav')
if getsize(f'{extractPath}/workspace/mov_conv_work/audio1.wav') == 0:
system(
f'ffmpeg -y -i {extractPath}/workspace/mov_conv_work/audio1.hca '
f'{extractPath}/workspace/mov_conv_work/audio1.wav')
if isfile(f'{extractPath}/workspace/mov_conv_work/00000.avi') and isfile(
f'{extractPath}/workspace/mov_conv_work/00000.ivf'):
remove(f'{extractPath}/workspace/mov_conv_work/00000.ivf')
try:
remove(f'{extractPath}/workspace/mov_conv_work/audio0.hca')
except:
pass
try:
remove(f'{extractPath}/workspace/mov_conv_work/audio1.hca')
except:
pass
if isfile(f'{extractPath}/workspace/mov_conv_work/00000.avi') and not isfile(pathname):
if isfile(f'{extractPath}/workspace/mov_conv_work/audio0.wav'):
createUsm = system(
f'{sofdec2enc} -br_range=0,60000000 -video00=\"{extractPath}/workspace/mov_conv_work/00000.avi\" -output=\"{pathname}\" -audio00=\"{extractPath}/workspace/mov_conv_work/audio0.wav\" -audio01=\"{extractPath}/workspace/mov_conv_work/audio1.wav\"')
else:
createUsm = system(
f'{sofdec2enc} -br_range=0,60000000 -video00=\"{extractPath}/workspace/mov_conv_work/00000.avi\" -output=\"{pathname}')