我有两组图像,我没有问题与avconv分开组合(使用-r使用不同的速率)一组设置为-r .20(将一个图像延伸到五秒视频),另一组设置为a定期帧率以常规速度组合视频。
当我尝试将这些单独的avi文件与avconv或avimerge组合时,生成的视频只有第一个视频的帧速率(-r .20)
有没有办法将这两个序列组合在一起?两个序列的输出帧速率是什么?
这是我在这里放在一起的草率代码:
try:
p = subprocess.Popen(["avconv" , "-y" , "-r" , ".20" , "-i" , "head%03d.jpg" , "-i" , audio , head_video_filename], universal_newlines=True, stdout=subprocess.PIPE)
out, err = p.communicate()
retcode = p.wait()
except IOError:
pass
else:
print "] ENCODING OF HEADER.AVI FINISHED:" + str(retcode)
try:
p = subprocess.Popen(["avconv" , "-y" , "-i" , "tail%03d.jpg" , "-r" , "25" , tail_video_filename], universal_newlines=True, stdout=subprocess.PIPE)
out, err = p.communicate()
retcode = p.wait()
except IOError:
pass
else:
print "] ENCODING OF TAIL.AVI FINISHED:" + str(retcode)
try:
group_of_videos = "concat:"+head_video_filename+"|"+tail_video_filename
p = subprocess.Popen(["avconv" , "-i" , group_of_videos , "-c" , "copy" , full_video_filename] , universal_newlines=True, stdout=subprocess.PIPE)
out, err = p.communicate()
retcode = p.wait()
except IOError:
pass
else:
print "] ENCODING OF FULL_VIDEO.AVI FINISHED:" + str(retcode)
return
#
答案 0 :(得分:0)
我或多或少想出来了。这些是我采取的步骤虽然更长,它或多或少给了我两个来自不同来源的视频作为图像和帧速率,一起编码它们的机会,并为结束视频添加单独的音乐曲目。它工作得很好,但仍然需要调整帧速率(30,29.X等以获得恰到好处)
编码输入为.2的第一个视频序列,并以30FPS输出try:
p = subprocess.Popen(["avconv" , "-stats" , "0" , "-y" , "-r" , ".2" , "-i" , "first%03d.jpg" , "-crf" , "1" , "-s" , "1280x720" , "-r" , "30" ,first_video_filename], universal_newlines=True, stdout=subprocess.PIPE)
out, err = p.communicate()
retcode = p.wait()
except IOError:
pass
else:
print "] ENCODING OF FIRST VIDEO FINISHED: " + str(retcode)
编码第二个视频序列输入为29.7FPS并以30FPS输出
try:
p = subprocess.Popen(["avconv" , "-stats" , "0" , "-y" , "-i" , "second%03d.jpg" , "-crf" , "1" , "-b" , "65536k" , "-s" , "1280x720" , "-r" , "30" , second_video_filename], universal_newlines=True, stdout=subprocess.PIPE)
out, err = p.communicate()
retcode = p.wait()
except IOError:
pass
else:
print "] ENCODING OF SECOND VIDEO FINISHED: " + str(retcode)
结合avi的
try:
p = subprocess.Popen(["mencoder" , "-forceidx" , "-ovc" , "copy" , "-o" , combined_video_filename , first_video_filename , second_video_filename] , universal_newlines=True, stdout=subprocess.PIPE)
out, err = p.communicate()
retcode = p.wait()
except IOError:
"* FAILED TO MAKE COMBINED VIDEO"
pass
else:
print "] ENCODING OF COMBINED VIDEO FINISHED:" + str(retcode)
#add audio mix track
try:
p = subprocess.Popen(["avconv" , "-stats" , "0" , "-y" , "-i" , combined_video_filename , "-i" , combined_audio , "-c" , "copy" , "-crf" , "1" , "-b" , "65536k" ,"-shortest" , final_video_filename] , universal_newlines=True, stdout=subprocess.PIPE)
out, err = p.communicate()
retcode = p.wait()
except IOError:
"* FAILED TO MAKE FINAL VIDEO"
pass
else:
print "] ENCODING OF FINAL VIDEO FINISHED: " + str(retcode)
火腿吝啬了,但希望有一天能帮助别人
XOXOXOX