所以我使用FFMPEG在Python中创建了多个视频剪辑,然后尝试将它们结合在一起。我创建了多个名为result1000、result1001等的视频,然后我创建了一个过渡效果,我想在这些视频之间分层。结果1000,结果001。。。etc完美地结合在一起,但是在它们之间插入过渡效果会导致第一次过渡后的每个剪辑丢失音频
创建传输
ffmpeg -loop 1 -y -i media/templates/bg.png -i media/swoosh_sound.mp3 -shortest -acodec copy -vcodec libx264rgb output/swoosh.mp4
创建视频剪辑
ffmpeg -loop1 -y -i image_files/image+str(1000+i)+.png -i audio_files/audio+str(1000+i)+.mp3 -shortest -acodec copy -vcodec libx264rgb output/result+str(1000+i)+.mp4
然后,ffmpeg_files.txt看起来像这样
file 'output/result1000.mp4'
file 'output/result1001.mp4'
file 'output/result1002.mp4'
file 'output/result1003.mp4'
file 'output/result1004.mp4'
file 'output/swoosh.mp4'
file 'output/result1005.mp4'
file 'output/result1006.mp4'
我使用的concat命令是
ffmpeg -f concat -safe 0 -i ffmpeg_files.txt output/no_bg_out.mp4
在控制台中运行concat注释时,它会说
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001f289b44c40] Auto-inserting h264_mp4toannexb bitstream filter
对于每个resultXXXX剪辑,一旦它到达一个过渡剪辑,它就会开始滥发垃圾邮件
[mp4 @ 000001aa093ad100] Non-monotonous DTS in output stream 0:1; previous: 13619623, current: 8777816; changing to 13619624. This may result in incorrect timestamps in the output file.
我已经阅读了上面提到的解决方案,但似乎没有一个能解决我的问题。需要注意的是,所有视频剪辑都是从.mp3音频文件和.png图像文件创建的
所有属性都必须匹配,但
swoosh.mp4
与其他属性不同,具有不同的音频采样率和频道布局。重新编码音频并重试:相关问题 更多 >
编程相关推荐