[FFmpeg-user] replace several lines by one using the filter_complex

Gyan Doshi ffmpeg at gyani.pro
Fri Jul 10 07:37:18 EEST 2020



On 10-07-2020 01:01 am, Leonardo via ffmpeg-user wrote:
> $ ffmpeg -i video.mp4 -vf "trim=start=7:end=1173,setpts=PTS-STARTPTS" -af "atrim=start=7:end=1173,asetpts=PTS-STARTPTS" part1.mp4
>
>
> $ ffmpeg -i video.mp4 -vf "trim=start=1260:end=1430,setpts=PTS-STARTPTS" -af "atrim=start=1260:end=1430,asetpts=PTS-STARTPTS" part2.mp4
>
>
> After this I create a file input.txt (duration found with ffprobe):
> file 'part1.mp4'
> duration 1166.02file 'part2.mp4'duration 170.02
>
>
> And finish with
>
>
> $ ffmpeg -f concat -i input.txt -c copy video_final.mp4
>
>
> This sequence of steps work as expected but I would like to know if it is possible to use the filter_complex with only "one line command" to achieve same result ?

Yes, using the concat filter.

     ffmpeg -i video.mp4 -filter_complex "[0:v]trim=start=7:end=1173,setpts=PTS-STARTPTS[v1];[0:v]trim=start=1260:end=1430,setpts=PTS-STARTPTS[v2];[0:a]atrim=start=7:end=1173,asetpts=PTS-STARTPTS[a1];[0:a]atrim=start=1260:end=1430,asetpts=PTS-STARTPTS[a2];[v1][a1][v2][a2]concat=n=2:v=1:a=1" merged.mp4

Gyan



More information about the ffmpeg-user mailing list