Sample Header Ad - 728x90

FFmpeg: To trim a video using 'trim' and specify time using HH:MM:SS format

1 vote
1 answer
172 views
FFmpeg 7.0.1. I want to understand whether it is possible to trim a video using trim and to specify start and end time using the HH:MM:SS format instead of just seconds. That is, the following command trims a video from 5s to 10s:
ffmpeg -y -i input.mp4 -vf trim=5:10,setpts=PTS-STARTPTS output.mp4
But if I try to specify start and end time using HH:MM:SS format, FFmpeg returns an error:
ffmpeg -y -i input.mp4 -vf trim='00:00:05':'00:00:15',setpts=PTS-STARTPTS output.mp4
ffmpeg -y -i input.mp4 -vf trim=00\:00\:05:00\:00\:15,setpts=PTS-STARTPTS output.mp4
> Output file is empty, nothing was encoded(check -ss / -t / -frames parameters if used) Is it possible to fix it? (A guy on Super User suggested trim='00\:00\:05':'00\:00\:15' or trim=00\\:00\\:05:00\\:00\\:15, but I receive the same error message.) **Side questions** - To keep the first 5 seconds and drop everything else, I can use ffmpeg -i input.mp4 -vf trim=end=5 output.mp4. But how to keep only the last 5 seconds? - To drop frist 5 seconds, I can use ffmpeg -i input.mp4 -vf trim=start=5,setpts=PTS-STARTPTS output.mp4. But how to drop the last 5 seconds?
Asked by jsx97 (1347 rep)
Jun 19, 2024, 07:54 AM
Last activity: Jul 1, 2024, 07:37 AM