【发布时间】:2018-12-06 16:42:23
【问题描述】:
我尝试生成 10 分钟原始 videofile.mp4 的较短版本,其中仅包含原始文件的四个 10 秒子剪辑(即从 10 秒到 20 秒;197 到 207 秒;393 到 403 秒;570 到 580 秒)。到目前为止,我只能生成 4 个复制视频和音频的新文件:
ffmpeg -i videofile.mp4 -vcodec copy -acodec copy -ss 10 -to 20 videofile1.mp4 -vcodec copy -acodec copy -ss 197 -to 207 videofile2.mp4 -vcodec copy -acodec copy -ss 393 -to 403 videofile3.mp4 -vcodec copy -acodec copy -ss 570 -to 580 videofile4.mp4
但是,我在连接这 4 个子剪辑以生成所需的 40 秒 out_videofile.mp4 时遇到了很大的麻烦。我在 ffmpeg 中使用“select”命令找到了this 替代方法,这使我免于“失败”的连接过程。到目前为止,我有:
ffmpeg -i videofile.mp4 -vf "select='between(t,10,20)+between(t,197,207)+between(t,393,403)+between(t,570,580)',setpts=N/FRAME_RATE/TB" -af "aselect='between(t,10,20)+between(t,197,207)+between(t,393,403)+between(t,570,580)" out_videofile.mp4
我猜这最后的代码应该给我我想要的 40s out_videofile.mp4。但是,它给了我一个“SyntaxError:无效语法”。知道我哪里出错了吗?
无论如何,感谢您的宝贵时间。
【问题讨论】:
标签: python-3.x video ffmpeg