因此,我有很多音频和视频文件正在尝试合并。几个组合似乎工作正常,然后无法关闭。这是我的代码:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="input-group col-10">
<input type="text" class="form-control search-bar" id="search-bar" placeholder="Type to search course">
<div class="input-group-append">
<button class="btn btn-primary form-control btn-search">Search</button>
</div>
</div>
这是我不断收到的错误:
from moviepy.editor import *
from time import sleep as sleep
import shutil
src = 'C:\\videodir\\'
fullFiles = [os.path.join(path, name) for path, subdirs, files in os.walk(src) for name in files]
for fullFile in fullFiles:
if 'm3u8' in fullFile and 'Audio' not in fullFile and 'used' not in fullFile:
name = '.'.join(fullFile.split('.')[0:-1])
mp3name = name+'.mp3'
mp4name = name+'.mp4'
if os.path.isfile(mp4name) and os.path.isfile(mp3name):
try:
videoclip = VideoFileClip(mp4name)
videoclip.audio = AudioFileClip(mp3name)
videoclip.write_videofile(name+" - Final.mp4")
cUsedDIR = '\\'.join(name.split('\\')[0:-1])+'\\used\\'
if not os.path.isdir(cUsedDIR):
os.mkdir(cUsedDIR)
shutil.move(mp4name,cUsedDIR)
shutil.move(mp3name,cUsedDIR)
shutil.move(name+'.m3u8',cUsedDIR)
if os.path.isfile(name+' - Audio.m3u8'):
shutil.move(name+' - Audio.m3u8',cUsedDIR)
sleep(1)
except:
print("couldn't combine: "+name)
我已经多次运行了此程序,它似乎是在成功组合后出现.mp3失败的情况下发生的。当我重新运行此文件时,由于所有成功的文件都会被移动,因此它会跳过无法打开的文件并继续运行而不会出错。
任何解决此问题的帮助将不胜感激。平均花一些组合完成所有组合将花费20个小时,我真的不想在下周开始做这件事。 ?谢谢!