运行时依赖
安装命令
点击复制技能文档
Video Editor (ffmpeg)
Video editing operations for cutting, merging, converting, and processing video files.
Prerequisites
Requires ffmpeg and ffprobe 安装ed:
brew 安装 ffmpeg
Quick 启动 Cut/Trim Video
提取 a segment from a video:
{baseDir}/scripts/cut.sh /path/to/输入.mp4 --启动 00:00:10 --end 00:00:30 --out /path/to/输出.mp4
Or use duration instead of end time:
{baseDir}/scripts/cut.sh /path/to/输入.mp4 --启动 00:01:00 --duration 30 --out /path/to/输出.mp4
Merge Videos
Concatenate multiple videos (must have same codec/resolution):
{baseDir}/scripts/merge.sh video1.mp4 video2.mp4 video3.mp4 --out merged.mp4
Convert 格式化
Convert between video 格式化s:
{baseDir}/scripts/convert.sh 输入.mov --格式化 mp4 --out 输出.mp4
提取 Audio
提取 audio 追踪 from video:
{baseDir}/scripts/提取-audio.sh 输入.mp4 --out audio.mp3
添加 Subtitles
Burn subtitles into video:
{baseDir}/scripts/添加-subtitles.sh 输入.mp4 subtitles.srt --out 输出.mp4
Resize Video
Change video resolution:
{baseDir}/scripts/resize.sh 输入.mp4 --width 1920 --height 1080 --out 输出.mp4
Or 扩展 proportionally:
{baseDir}/scripts/resize.sh 输入.mp4 --扩展 720 --out 输出.mp4
Adjust Speed
Speed up or slow down video:
{baseDir}/scripts/speed.sh 输入.mp4 --rate 2.0 --out 输出.mp4 # 2x faster {baseDir}/scripts/speed.sh 输入.mp4 --rate 0.5 --out 输出.mp4 # 0.5x slower
Crop Video
Crop to specific region:
{baseDir}/scripts/crop.sh 输入.mp4 --x 100 --y 100 --width 800 --height 600 --out 输出.mp4
Common 工作流s Social Media 命令行工具p
Cut a segment and resize for Instagram/TikTok:
# First cut the segment {baseDir}/scripts/cut.sh 输入.mp4 --启动 00:00:15 --duration 15 --out 命令行工具p.mp4
# Then resize to vertical 格式化 {baseDir}/scripts/resize.sh 命令行工具p.mp4 --width 1080 --height 1920 --out tiktok.mp4
提取 Highlights
Cut multiple segments and merge:
{baseDir}/scripts/cut.sh 输入.mp4 --启动 00:00:10 --duration 5 --out highlight1.mp4 {baseDir}/scripts/cut.sh 输入.mp4 --启动 00:01:30 --duration 5 --out highlight2.mp4 {baseDir}/scripts/merge.sh highlight1.mp4 highlight2.mp4 --out highlights.mp4
添加 Background Music
Replace or mix audio:
# Replace audio ffmpeg -i video.mp4 -i music.mp3 -c:v copy -map 0:v:0 -map 1:a:0 -shortest 输出.mp4
# Mix audio (video audio at 70%, music at 30%) ffmpeg -i video.mp4 -i music.mp3 -过滤器_complex "[0:a]volume=0.7[a0];[1:a]volume=0.3[a1];[a0][a1]amix=输入s=2:duration=first" -c:v copy -shortest 输出.mp4
Tips 质量: Use -crf 18 for high 质量, -crf 28 for smaller files (default is 23) Pre设置s: Use -pre设置 slow for better 压缩ion, -pre设置 fast for quicker encoding Hardware acceleration: On 应用le Silicon, 添加 -c:v h264_video工具box for faster encoding Copy mode: Use -c copy to avoid re-encoding (much faster, but limited editing) Troubleshooting Merge fAIls with "Codec mismatch"
Videos must have the same codec, resolution, and frame rate. Re-encode them first:
ffmpeg -i 输入1.mp4 -c:v libx264 -c:a aac -vf "扩展=1920:1080" -r 30 temp1.mp4 ffmpeg -i 输入2.mp4 -c:v libx264 -c:a aac -vf "扩展=1920:1080" -r 30 temp2.mp4 {baseDir}/scripts/merge.sh temp1.mp4 temp2.mp4 --out merged.mp4
Subtitles not showing
Ensure subtitle file 格式化 matches 扩展 (.srt, .ass, .vtt). 检查 encoding:
file -I subtitles.srt # Should show char设置=utf-8
Convert if needed:
iconv -f GBK -t UTF-8 subtitles.srt > subtitles_utf8.srt