FFmpeg provides a
suite of
command-line
interface tools for working with audio and video files. It is
free and
open-source software that is available for a variety of
operating systems,
including
Microsoft Windows,
Linux, and
macOS. If you wish to
use it on a Microsoft Windows system, you can install it with the
Windows
Package Manager known as winget by
opening a command prompt window
and issuing the command winget install "FFmpeg (Essentials Build)".
Microsoft Windows [Version 10.0.26100.7623] (c) Microsoft Corporation. All rights reserved. C:\Windows\System32>winget install "FFmpeg (Essentials Build)" Found FFmpeg (Essentials Build) [Gyan.FFmpeg.Essentials] Version 8.0.1 This application is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Downloading https://github.com/GyanD/codexffmpeg/releases/download/8.0.1/ffmpeg-8.0.1-essentials_build.zip ██████████████████████████████ 101 MB / 101 MB Successfully verified installer hash Extracting archive... Successfully extracted archive Starting package install... Command line alias added: "ffmpeg" Command line alias added: "ffplay" Command line alias added: "ffprobe" Path environment variable modified; restart your shell to use the new value. Successfully installed C:\Windows\System32>
If you need to trim the beginning of a video file, such as a .mp4 file,
you can do so using a command of the form
ffmpeg -ss hh:mm:ss -i input.mp4 -c copy output.mp4 where
you specify the point you wish the video to start in the form hh:mm:ss
for hours, minutes, and seconds with -ss and
input.mp4 is the file you wish to trim and output.mp4
is the name you wish to give to the trimmed file. E.g., if I have a video
file, REC-0001-A.mp4, where I wish to discard audio and video up to the 3
minutes and 34 seconds mark in the file, I can use ffmpeg -ss 00:03:34 -i REC-0001-A.mp4 -c copy output1.mp4 to create a new file, output1.mp4,
that omits the first 3 minutes and 33 seconds from the input file. Using the
-c copy option copies the video/audio streams directly,
which is fast but can be less accurate on
keyframes.
C:\Users\moonp\Videos>ffmpeg -ss 00:03:34 -i REC-0001-A.mp4 -c copy output1.mp4 ffmpeg version 8.0.1-essentials_build-www.gyan.dev Copyright (c) 2000-2025 the FFmpeg developers built with gcc 15.2.0 (Rev8, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-a utodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --e nable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable -avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --en able-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enab le-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libvidstab --enable-libvmaf --e nable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --e nable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi -- enable-openal --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-l ibopus --enable-libspeex --enable-libvorbis --enable-librubberband libavutil 60. 8.100 / 60. 8.100 libavcodec 62. 11.100 / 62. 11.100 libavformat 62. 3.100 / 62. 3.100 libavdevice 62. 1.100 / 62. 1.100 libavfilter 11. 4.100 / 11. 4.100 libswscale 9. 1.100 / 9. 1.100 libswresample 6. 1.100 / 6. 1.100 [mov,mp4,m4a,3gp,3g2,mj2 @ 000001b033043400] All samples in data stream index:id [2:3] have zero duration, stream set to be discarded by defa ult. Override using AVStream->discard or -discard for ffmpeg command. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'REC-0001-A.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.20.100 Duration: 00:14:18.52, start: 0.000000, bitrate: 37520 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 3840x2160 , 37175 kb/s, 30 fps, 30 tbr, 90k tbn (default) Metadata: handler_name : SStar Video vendor_id : [0][0][0][0] Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 104 kb/s (de fault) Metadata: handler_name : SStar Audio vendor_id : [0][0][0][0] Stream #0:2[0x3](und): Data: none (ssmd / 0x646D7373) Metadata: handler_name : SStarMeta Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Output #0, mp4, to 'output1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf62.3.100 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 384 0x2160, q=2-31, 37175 kb/s, 30 fps, 30 tbr, 90k tbn (default) Metadata: handler_name : SStar Video vendor_id : [0][0][0][0] Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 104 kb/s (default ) Metadata: handler_name : SStar Audio vendor_id : [0][0][0][0] Press [q] to stop, [?] for help [out#0/mp4 @ 000001b033046c40] video:2928211KiB audio:8253KiB subtitle:0KiB other streams:0KiB g lobal headers:0KiB muxing overhead: 0.018641% frame=19364 fps=1733 q=-1.0 Lsize= 2937011KiB time=00:10:44.43 bitrate=37335.1kbits/sspeed=57.7x elapsed=0:00:11.17 C:\Users\moonp\Videos>
If the copy method freezes or starts at the wrong spot, you can
re-encode
to be more precise with a command such as ffmpeg -ss hh:mm:ss -i input.mp4
-c:v libx2x4 -c:a aac output.mp4 to re-encode the video for
frame-accurate, perfect cuts. The process for re-encoding a video will take
much longer, which is why using the -c copy method to trim a file
in FFmpeg will complete much more quickly than trying to trim off the beginning
of a video file with a program such as
Kdenlive. Kdenlive offers
many great audio/video editing features, but I found that trimming a few
minutes from a video using that software took about 40 minutes for the rendering
process to create the output file compared to about
9 seconds to trim the same video with FFmpeg using the -c copy
option.
If you wish to start at a certain point and end after a specific duration,
e.g., cut the first 10 seconds, then take the next 30 seconds, you can use a
command such as ffmpeg -ss 00:00:10 -i input.mp4 -t 00:00:30 -c copy
output.mp4 with -t 00:00:30 specifying the duration of
the output file will be 30 seconds. Note: the output video might start
slightly before or after the 10-second mark if it falls between keyframes.
Though placing -ss before -i is usually fater
for input seeking, if the first few seconds in the output file are black, try
plaing -ss after -i or use the re-encoding method.