fangfufu icon

ffmpeg cut and merge

fangfufu | PRO | 10/25/14 11:32:45 PM UTC | 0 ⭐ | 343 👁️ | Never ⏰ | []
Bash |

870 B

|

None

|

0 👍

/

0 👎

#!/bin/bash
ffmpeg -i video_a.mp4 -ss 00:00 -to 01:40 -vcodec copy  -acodec copy section1.mp4
ffmpeg -i video_a.mp4 -ss 01:40 -to 17:06 -vcodec copy  -acodec copy section2.mp4
ffmpeg -i video_a.mp4 -ss 17:06 -to 18:04 -vcodec copy  -acodec copy section3.mp4
ffmpeg -i video_b.mp4 -vcodec copy -an section2_video.mp4
ffmpeg -i section2.mp4 -acodec copy -vn section2_audio.mp4
ffmpeg -i section2_audio.mp4 -i section2_video.mp4 -vcodec copy -af atempo=0.97885835 section2_new.mp4
ffmpeg -i section1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i section2_new.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i section3.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate3.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts|intermediate3.ts" -c copy -bsf:a aac_adtstoasc output.mp4
rm section1.mp4 section2*.mp4 section3.mp4

Comments