FFmpeg remove 2 sec from middle of video and concat the parts. Single line solution

走远了吗. 提交于 2021-02-08 10:13:58

问题


I have a video file that is 22 seconds long.
I want to remove the segment from 10 seconds to 12 seconds.
Then return a concatenated video file of seconds 1-10 and 12-22.

I want to do this in a single FFmpeg command.

This is the easy way

Source https://www.labnol.org/internet/useful-ffmpeg-commands/28490/

ffmpeg -i input.mp4 -ss 00:00:00.0 -codec copy -t 10 output_1.mp4

and

ffmpeg -i input.mp4 -ss 00:00:12.0 -codec copy -t 10 output_2.mp4

then create an input file with all the source file names and run

ffmpeg -f concat -i file-list.txt -c copy output.mp4



But I'm looking for a one line solution

Any help would be appreciated.


回答1:


For exact trimming, you'll have to re-encode

Use

ffmpeg -i input.mp4 -vf select='not(between(t,10,12))',setpts=N/FRAME_RATE/TB -af aselect='not(between(t,10,12))',asetpts=N/SR/TB out.mp4


来源:https://stackoverflow.com/questions/54189099/ffmpeg-remove-2-sec-from-middle-of-video-and-concat-the-parts-single-line-solut

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!