video-edit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVideo Edit
视频编辑
Edit videos locally by running ffmpeg/ffprobe directly. No wrapper scripts needed.
直接运行ffmpeg/ffprobe在本地编辑视频,无需包装脚本。
Prerequisites
前置条件
Install ffmpeg (includes ffprobe):
bash
undefined安装ffmpeg(包含ffprobe):
bash
undefinedmacOS
macOS
brew install ffmpeg
brew install ffmpeg
Ubuntu/Debian
Ubuntu/Debian
sudo apt update && sudo apt install -y ffmpeg
sudo apt update && sudo apt install -y ffmpeg
Verify
验证
ffmpeg -version && ffprobe -version
undefinedffmpeg -version && ffprobe -version
undefinedQuick Reference
快速参考
Get video info
获取视频信息
bash
ffprobe -v quiet -print_format json -show_format -show_streams video.mp4bash
ffprobe -v quiet -print_format json -show_format -show_streams video.mp4Trim
修剪视频
bash
ffmpeg -y -ss 00:00:30 -to 00:01:45 -i video.mp4 -c copy trimmed.mp4bash
ffmpeg -y -ss 00:00:30 -to 00:01:45 -i video.mp4 -c copy trimmed.mp4Concatenate clips
拼接视频剪辑
bash
undefinedbash
undefined1. Create a file list
1. 创建文件列表
printf "file '%s'\n" clip1.mp4 clip2.mp4 clip3.mp4 > list.txt
printf "file '%s'\n" clip1.mp4 clip2.mp4 clip3.mp4 > list.txt
2. Concat with stream copy
2. 流复制模式拼接
ffmpeg -y -f concat -safe 0 -i list.txt -c copy joined.mp4
undefinedffmpeg -y -f concat -safe 0 -i list.txt -c copy joined.mp4
undefinedResize for platform
为平台调整视频尺寸
bash
ffmpeg -y -i video.mp4 \
-vf "scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black" \
-c:a copy tiktok.mp4bash
ffmpeg -y -i video.mp4 \
-vf "scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black" \
-c:a copy tiktok.mp4Change speed
调整视频速度
bash
undefinedbash
undefined2x faster
2倍速
ffmpeg -y -i video.mp4 -filter:v "setpts=0.5*PTS" -filter:a "atempo=2.0" fast.mp4
ffmpeg -y -i video.mp4 -filter:v "setpts=0.5*PTS" -filter:a "atempo=2.0" fast.mp4
0.5x (slow motion)
0.5倍速(慢动作)
ffmpeg -y -i video.mp4 -filter:v "setpts=2.0*PTS" -filter:a "atempo=0.5" slow.mp4
undefinedffmpeg -y -i video.mp4 -filter:v "setpts=2.0*PTS" -filter:a "atempo=0.5" slow.mp4
undefinedExtract audio
提取音频
bash
ffmpeg -y -i video.mp4 -vn -acodec libmp3lame audio.mp3bash
ffmpeg -y -i video.mp4 -vn -acodec libmp3lame audio.mp3Replace audio
替换音频
bash
ffmpeg -y -i video.mp4 -i audio.mp3 -c:v copy -map 0:v:0 -map 1:a:0 -shortest output.mp4bash
ffmpeg -y -i video.mp4 -i audio.mp3 -c:v copy -map 0:v:0 -map 1:a:0 -shortest output.mp4Compress
压缩视频
bash
ffmpeg -y -i video.mp4 -crf 23 -preset medium -c:a copy compressed.mp4bash
ffmpeg -y -i video.mp4 -crf 23 -preset medium -c:a copy compressed.mp4Convert format
转换视频格式
bash
ffmpeg -y -i video.mov output.mp4bash
ffmpeg -y -i video.mov output.mp4Add image overlay
添加图片叠加层
bash
undefinedbash
undefinedLogo in top-right corner
右上角添加logo
ffmpeg -y -i video.mp4 -i logo.png
-filter_complex "overlay=W-w-10:10" -c:a copy watermarked.mp4
-filter_complex "overlay=W-w-10:10" -c:a copy watermarked.mp4
undefinedffmpeg -y -i video.mp4 -i logo.png
-filter_complex "overlay=W-w-10:10" -c:a copy watermarked.mp4
-filter_complex "overlay=W-w-10:10" -c:a copy watermarked.mp4
undefinedPlatform Presets
平台预设参数
| Platform | Resolution | Scale + pad filter |
|---|---|---|
| TikTok | 1080 x 1920 | |
| YouTube | 1920 x 1080 | |
| 1080 x 1350 | | |
| Square | 1080 x 1080 | |
| Twitter/X | 1920 x 1080 | |
Use the filter with:
ffmpeg -y -i input.mp4 -vf "<filter>" -c:a copy output.mp4| 平台 | 分辨率 | 缩放+填充滤镜 |
|---|---|---|
| TikTok | 1080 x 1920 | |
| YouTube | 1920 x 1080 | |
| 1080 x 1350 | | |
| 正方形格式 | 1080 x 1080 | |
| Twitter/X | 1920 x 1080 | |
使用滤镜的命令格式:
ffmpeg -y -i input.mp4 -vf "<filter>" -c:a copy output.mp4Tips
小贴士
- Always use to overwrite output without prompting.
-y - Use when you only need to cut/join (no re-encoding, very fast).
-c copy - Lower CRF = better quality, larger file. Range 18-28 is typical; 23 is the default.
- For detailed recipes and flag explanations, see .
references/operations.md
- 始终使用参数,无需确认即可覆盖输出文件。
-y - 当仅需剪切/拼接视频时,使用参数(无需重新编码,速度极快)。
-c copy - CRF值越低,视频质量越高,文件体积越大。常用范围是18-28,默认值为23。
- 如需详细的操作指南和参数说明,请查看。
references/operations.md