问题
I did something like this
ffmpeg -i video1.mp4 -ss 00:01:00 -to 00:03:00 -i video2.mp4 -ss 00:05:00 -to 00:02:00 -c copy cut.mp4
Apparently muxing didnt happen.
How can I make it work?
回答1:
You have to tell ffmpeg that you want to concatenate each video and audio stream:
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex
"[0:v]trim=start=60:end=180,setpts=PTS-STARTPTS[v0];
[0:a]atrim=start=60:end=180,asetpts=PTS-STARTPTS[a0];
[0:v]trim=start=300:end=420,setpts=PTS-STARTPTS[v1];
[0:a]atrim=start=300:end=420,asetpts=PTS-STARTPTS[a1];
[v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a]"
-map "[v]" -map "[a]" output.mp4
(a)trimcreates each segment,(a)setptsresets the segment timestamps (recommended forconcat), andconcatconcatenates each segment. See FFmpeg Filters for documentation on each filter.I broke up the command into separate lines for readability. Reconstitute into a single line or add whatever line-break characters are suitable for your environment.
This will re-encode the video but cutting will be accurate. If you want to avoid re-encoding see the concat demuxer but cutting may not be accurate and results may not be satisfactory.
The
-tovalue cannot be smaller than the-ssvalue, so I'm going to assume you meant-ss 00:05:00 -to 00:07:00instead of-ss 00:05:00 -to 00:02:00.
来源:https://stackoverflow.com/questions/48882568/how-to-cut-from-multiple-input-videos-and-concat-to-single-video-using-ffmpeg