How to keep part of a video | Trim and atrim video filters explained

Published: 28 March 2022
on channel: The FFMPEG guy
652
15

Today, we show how to keep part a video / drop part of a video using the trim video filter. The method allows you to select the beginning, the end or part of a film! Enjoy!

MORE TIME TRIMING VIDEO TRICKS
How to trim / truncate a video | Cut by time
   • How to trim / truncate a video | Cut ...  
How to remove the last X seconds from the end of a video | Cut the end of a film
   • How to remove the last X seconds from...  

ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
EXAMPLES
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
❶ Keeping the start of a video (no audio trimming)
→ ffmpeg -i input.mp4 -vf trim=duration=5 output01.mp4

with:
-i input.mp4 = Reads input.mp4…
-vf trim = … calls the «trim» video filter (vf)…
duration=5 = … keeping 5 seconds of video from the start (default)
output01.mp4 = … and outputs the result to file «output01.mp4»

❷ Keeping the end of a video (audio & video trimming)
→ ffmpeg -i input.mp4 -vf trim=start=2 -af atrim=start=2 output02.mp4

with:
-i input.mp4 = Reads file «input.mp4» and …
-vf trim = … calls the «trim» video filter (vf)…
start = … to keep all video starting …
2 = … after 2 seconds …
-af atrim = Calls now the atrim audio filter (af) …
start=2 = … to keep all audio after 2 seconds …
output02.mp4 = … and outputs the result to file «output02.mp4»

❸ Keeping the middle of a video (resetting timestamps)
→ ffmpeg -i input.mp4 -vf trim=start=2:duration=5,setpts=PTS-STARTPTS -af atrim=start=2:duration=5,asetpts=PTS-STARTPTS output03.mp4

with:
-i input.mp4 = Reads file «input.mp4» and …
-vf trim = … calls the «trim» video filter (vf)…
start=2 = … that keeps all video starting after 2 seconds…
duration=5 = … for a duration of 5 seconds
(i.e. seconds 2 to 7)
setpts=PTS-STARTPTS = … resetting the video timestamp to 0 at start.
-af atrim = Calls now the «atrim» audio filter (af)…
start=2:duration=5 = … keeping audio between seconds 2 to 7 and…
asetpts=PTS-STARTPTS = … resetting the audio timestamp to 0 at start.
output03.mp4 = … and outputs the result to file «output03.mp4»
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
→ Catch up with the FFMPEG guy Channel
   • ALL THE VIDEOS FROM THE CHANNEL  
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
MUSIC
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
→ Contender - TrackTribe
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
An FFMPEG question?
Ask the FFMPEG guy
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ


Watch video How to keep part of a video | Trim and atrim video filters explained online without registration, duration hours minute second in high quality. This video was added by user The FFMPEG guy 28 March 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 652 once and liked it 15 people.