Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cores/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,5 @@ def addmosaic_video(opt,netS):
print('Step:4/4 -- Convert images to video')
ffmpeg.image2video( fps,
opt.temp_dir+'/addmosaic_image/output_%06d.'+opt.tempimage_type,
opt.temp_dir+'/voice_tmp.mp3',
os.path.join(opt.result_dir,os.path.splitext(os.path.basename(path))[0]+'_add.mp4'))
opt.temp_dir+'/voice_tmp.mkv',
os.path.join(opt.result_dir,os.path.splitext(os.path.basename(path))[0]+'_add.mkv'))
8 changes: 4 additions & 4 deletions cores/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def cleanmosaic_video_byframe(opt,netG,netM):
print('Step:4/4 -- Convert images to video')
ffmpeg.image2video( fps,
opt.temp_dir+'/replace_mosaic/output_%06d.'+opt.tempimage_type,
opt.temp_dir+'/voice_tmp.mp3',
os.path.join(opt.result_dir,os.path.splitext(os.path.basename(path))[0]+'_clean.mp4'))
opt.temp_dir+'/voice_tmp.mkv',
os.path.join(opt.result_dir,os.path.splitext(os.path.basename(path))[0]+'_clean.mkv'))

def cleanmosaic_video_fusion(opt,netG,netM):
path = opt.media_path
Expand Down Expand Up @@ -245,5 +245,5 @@ def write_result():
print('Step:4/4 -- Convert images to video')
ffmpeg.image2video( fps,
opt.temp_dir+'/replace_mosaic/output_%06d.'+opt.tempimage_type,
opt.temp_dir+'/voice_tmp.mp3',
os.path.join(opt.result_dir,os.path.splitext(os.path.basename(path))[0]+'_clean.mp4'))
opt.temp_dir+'/voice_tmp.mkv',
os.path.join(opt.result_dir,os.path.splitext(os.path.basename(path))[0]+'_clean.mkv'))
4 changes: 2 additions & 2 deletions cores/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def video_init(opt,path):

print('Step:1/4 -- Convert video to images')
util.file_init(opt)
ffmpeg.video2voice(path,opt.temp_dir+'/voice_tmp.mp3',opt.start_time,opt.last_time)
ffmpeg.video2voice(path,opt.temp_dir+'/voice_tmp.mkv',opt.start_time,opt.last_time)
ffmpeg.video2image(path,opt.temp_dir+'/video2image/output_%06d.'+opt.tempimage_type,fps,opt.start_time,opt.last_time)
imagepaths = os.listdir(opt.temp_dir+'/video2image')
imagepaths.sort()
step = {'step':2,'frame':0}
util.savejson(os.path.join(opt.temp_dir,'step.json'),step)

return fps,imagepaths,height,width
return fps,imagepaths,height,width
4 changes: 2 additions & 2 deletions cores/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ def styletransfer_video(opt,netG):
print('Step:4/4 -- Convert images to video')
ffmpeg.image2video( fps,
opt.temp_dir+'/style_transfer/output_%06d.'+opt.tempimage_type,
opt.temp_dir+'/voice_tmp.mp3',
os.path.join(opt.result_dir,os.path.splitext(os.path.basename(path))[0]+'_'+suffix+'.mp4'))
opt.temp_dir+'/voice_tmp.mkv',
os.path.join(opt.result_dir,os.path.splitext(os.path.basename(path))[0]+'_'+suffix+'.mkv'))
4 changes: 2 additions & 2 deletions util/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def video2image(videopath, imagepath, fps=0, start_time='00:00:00', last_time='0
run(args)

def video2voice(videopath, voicepath, start_time='00:00:00', last_time='00:00:00'):
args = ['ffmpeg', '-i', '"'+videopath+'"','-async 1 -f mp3','-b:a 320k']
args = ['ffmpeg', '-i', '"'+videopath+'"','-async 1','-vn','-c:a copy']
if last_time != '00:00:00':
args += ['-ss', start_time]
args += ['-t', last_time]
Expand All @@ -53,7 +53,7 @@ def video2voice(videopath, voicepath, start_time='00:00:00', last_time='00:00:00
def image2video(fps,imagepath,voicepath,videopath):
os.system('ffmpeg -y -r '+str(fps)+' -i '+imagepath+' -vcodec libx264 '+os.path.split(voicepath)[0]+'/video_tmp.mp4')
if os.path.exists(voicepath):
os.system('ffmpeg -i '+os.path.split(voicepath)[0]+'/video_tmp.mp4'+' -i "'+voicepath+'" -vcodec copy -acodec aac '+videopath)
os.system('ffmpeg -i '+os.path.split(voicepath)[0]+'/video_tmp.mp4'+' -i "'+voicepath+'" -c:v copy -c:a copy '+videopath)
else:
os.system('ffmpeg -i '+os.path.split(voicepath)[0]+'/video_tmp.mp4 '+videopath)

Expand Down