Trimming video with FFmpeg is easy. The overall process involves installing FFmpeg on your computer, then offering the source video file as input with the -i
flag, and then specifying the timestamps where the video needs to be trimmed.
Following are the step-by-step instructions-
Trim video using FFmpeg with re-encoding
Use the -ss
flag offered by FFmpeg to extract a section of your input and then search within it to browse and change the input video’s area.
The following steps show how to use the -ss flag to cut the video:
Step 1: Install FFmpeg
If you don’t have FFmpeg installed on your computer, you must install it first. You can download FFmpeg from the official website and follow the installation instructions.
We have the following guides to help you get started
Step 2: Browse the Folder
- Search Command Prompt or Terminal in the Start menu or Finder and press Enter.
- Use the cd command to navigate the folder containing your input video file. For example, type
cd Desktop/Videos
and hit Enter if your video file is in the Videos folder on your desktop.
Step 4: Trim the Video with FFmpeg
-
Run the following command to trim a video in FFmpeg:
ffmpeg -i inputfile.mp4 -ss 00:00:20 -t 00:00:40 -c copy outputfile.mp4
-
Each flag has its own meaning as follows
-i
inputfile.mp4: Indicates the input file name and its extension.-ss
00:00:20: States the start time of the desired clip. In this example, we begin the video at 20 seconds.-t
00:00:40: Choose how long you want the clip extracted. In this case, we are selecting a 40-second clip.-c
copy: It will copy audio and video streams without re-encoding. This process is faster than re-encoding but only works if the output format is exactly the same as the input format.- outputfile.mp4: Indicates the output file name with extension.
-
After running the above command, change the filename from
inputfile.mp4
tooutputfile.mp4
. -
FFmpeg will extract the desired clip from the input file and save it as a new output file when you run the above command by pressing
Enter
.
Step 5: Inspect the Output
In order to determine whether the video has been cut or not, play the output file.
And, it’s done! with FFmpeg, you may trim a video by following these easy steps.
When to trim a video?
There are situations when you might wish to cut a video as follows.
1. Remove undesired footage
There can be certain portions of a movie that you’ve captured that are pointless or undesirable. By trimming the video, you can get rid of these bits and maintain exactly what you need.
2. Highlight specific content
Trimming can allow you to identify a particular area of a video you’d prefer to focus on and produce a smaller video clip that focuses on the information you want to highlight.
3. Create a trailer
When making a teaser or trailer for a lengthier video, trimming can be helpful. You can make a preview that captures the attention of the entire video by picking the most interesting or thrilling segments of it and compressing them into a shorter clip.
4. Save storage space
Video files occupy a lot of space on the storage media. While the size of the video file can vary according to the codec, bitrate, and compression settings, 60-second video footage can occupy almost 450MB on your HDD.
By trimming the video, you can save a lot of space on storage media; thus bringing down the overall cost of hosting your videos.
5. Improve loading time
Trimming a video can improve its loading time by reducing the file size. When you trim a video, you remove unwanted or unnecessary portions, which results in a shorter video with a smaller file size. Smaller files require less bandwidth and storage, which enables them to load and buffer more quickly when accessed online.
When viewers stream a video online, their devices need to download and buffer the video data before playback. Smaller video files can be downloaded and buffered faster, leading to reduced waiting times and a smoother streaming experience for viewers. This is particularly important for users with slower internet connections or those accessing the video from mobile devices with limited bandwidth.
Overall, you should crop a video when you believe that doing so will enhance its overall quality or increase the effectiveness with which it fulfills its intended goal.