Methods to Add and Remove Video Watermarks with FFmpeg
Detailed introduction to adding text and image watermarks, including 9 position settings, animation effects, opacity adjustment, and techniques for removing blurred watermarks.
Read More โMaster core FFmpeg video editing skills, from beginner to expert
FFmpeg is a powerful cross-platform audio/video processing tool that covers virtually all video editing needs. Compared to traditional desktop editing software, FFmpeg works via the command line, enabling batch automated processing and finding wide application in video production workflows.
This article systematically introduces core FFmpeg video editing operations, including timeline trimming, precise cutting, multi-segment concatenation, playback speed adjustment, video reverse, cropping and rotation โ each with detailed command examples and parameter explanations.
Video trimming is the most basic and commonly used editing operation. FFmpeg provides multiple trimming methods to extract any time segment from a video.
Using -ss to specify the start time and -to to specify the end time is the most intuitive trimming method:
ffmpeg -ss 00:01:30 -to 00:02:30 -i input.mp4 -c copy output.mp4
Besides specifying the end time, you can also use the -t parameter to directly specify the trim duration:
ffmpeg -ss 30 -t 60 -i input.mp4 -c:v libx264 -c:a aac output.mp4
Note that when using -c copy for stream copy, the cut point aligns to the nearest keyframe, which may cause a few seconds of error. For frame-accurate trimming, re-encoding is required:
ffmpeg -i input.mp4 -ss 00:01:30.500 -to 00:02:30.250 -c:v libx264 -c:a aac -accurate_seek output.mp4
In professional video production, frame-accurate editing is crucial. Here are several methods to achieve precise editing.
Through the select filter, you can precisely select a specific frame range:
ffmpeg -i input.mp4 -vf "select='between(n,100,500)',setpts=PTS-STARTPTS" -af "aselect='between(t,4.17,20.83)',asetpts=PTS-STARTPTS" output.mp4
The placement position of the -ss parameter in FFmpeg affects trimming accuracy and speed:
FFmpeg provides multiple video concatenation methods for different scenarios.
When all videos have identical encoding parameters, you can use stream copy for fast concatenation:
# Create filelist.txt
file 'video1.mp4'
file 'video2.mp4'
file 'video3.mp4'
# Execute concatenation
ffmpeg -f concat -safe 0 -i filelist.txt -c copy output.mp4
When video parameters differ, use the concat filter for re-encoding concatenation:
ffmpeg -i video1.mp4 -i video2.mp4 -i video3.mp4 \
-filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a]concat=n=3:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" output.mp4
Adjusting video playback speed is a commonly used effect in creative editing. FFmpeg can flexibly implement speed-up and slow-down.
Use the setpts filter to adjust video speed โ the smaller the value, the faster the speed:
# 2x speed playback
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -af "atempo=2.0" output.mp4
# 4x speed playback (audio requires multi-stage atempo)
ffmpeg -i input.mp4 -vf "setpts=0.25*PTS" -af "atempo=2.0,atempo=2.0" output.mp4
Slow motion effects are also achieved with setpts โ the larger the value, the slower the speed:
# 0.5x speed (slow motion)
ffmpeg -i input.mp4 -vf "setpts=2.0*PTS" -af "atempo=0.5" output.mp4
Reverse is a creative video effect, implemented in FFmpeg through the reverse filter.
ffmpeg -i input.mp4 -vf reverse -af areverse output_reverse.mp4
If you only need to reverse the video and keep the original audio:
ffmpeg -i input.mp4 -vf reverse -c:a copy output_reverse.mp4
Besides timeline trimming, adjusting frame dimensions is also a common requirement.
Use the crop filter to crop the frame, with parameters as width:height:x:y:
# Crop center area (width 800 height 600, starting at x=100,y=50)
ffmpeg -i input.mp4 -vf "crop=800:600:100:50" output.mp4
# Crop center square
ffmpeg -i input.mp4 -vf "crop=w=min(iw\,ih):h=min(iw\,ih):x=(iw-min(iw\,ih))/2:y=(ih-min(iw\,ih))/2" output.mp4
Use the scale filter to adjust video resolution:
# Scale to 1280x720
ffmpeg -i input.mp4 -vf "scale=1280:720" output.mp4
# Scale proportionally (maintain aspect ratio)
ffmpeg -i input.mp4 -vf "scale=640:-1" output.mp4
Adjusting video orientation is also a common editing operation.
# Rotate 90 degrees clockwise
ffmpeg -i input.mp4 -vf "transpose=1" output.mp4
# Rotate 90 degrees counterclockwise
ffmpeg -i input.mp4 -vf "transpose=2" output.mp4
# Rotate 180 degrees
ffmpeg -i input.mp4 -vf "transpose=2,transpose=2" output.mp4
# Horizontal flip (mirror)
ffmpeg -i input.mp4 -vf hflip output.mp4
# Vertical flip
ffmpeg -i input.mp4 -vf vflip output.mp4
FFmpeg provides rich video editing capabilities โ from basic trimming and concatenation to advanced speed changes, reverse playback, and frame adjustments โ all achievable through simple command lines. Mastering these techniques can greatly improve video processing efficiency, especially for batch processing and automated workflow scenarios.
If you want to quickly experience video processing features, you can directly use our online video tools โ no software installation needed, complete various video processing operations right in your browser.
More great articles and useful tools
Detailed introduction to adding text and image watermarks, including 9 position settings, animation effects, opacity adjustment, and techniques for removing blurred watermarks.
Read More โComprehensive introduction to FFmpeg audio processing capabilities, including noise reduction, multi-track mixing, volume normalization, fade in/out, equalizer adjustment, and other practical tips.
Read More โIn-depth explanation of HLS encryption principles and implementation, including AES-128 and SAMPLE-AES encryption schemes, key management, server configuration, and security best practices.
Read More โUse our online video conversion tools โ no FFmpeg installation needed, complete video trimming, format conversion, and more right in your browser
Try It Now โก