dantelabs-agentic-school 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +23 -2
- package/README.md +92 -8
- package/package.json +6 -2
- package/plugins/media/media-fx/skills/ffmpeg-cli/SKILL.md +940 -0
- package/plugins/media/media-fx/skills/ffmpeg-cli/references/common-recipes.md +693 -0
- package/plugins/media/media-fx/skills/ffmpeg-cli/references/ffmpeg-filters.md +799 -0
- package/plugins/media/media-fx/skills/ffmpeg-cli/references/ffmpeg-syntax-reference.md +666 -0
- package/plugins/media/media-fx/skills/video-editor/SKILL.md +254 -0
- package/plugins/media/media-fx/skills/video-editor/scripts/requirements.txt +6 -0
- package/plugins/media/media-fx/skills/video-editor/scripts/video_editor.py +1293 -0
- package/plugins/trading/trading-tools/plugin.json +9 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/.env.example +16 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/SKILL.md +504 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/assets/kiwoom_api_client_template.py +443 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/references/account.md +47 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/references/api_endpoints.md +179 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/references/environment_config.md +93 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/references/institution.md +76 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/references/market_price.md +212 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/references/misc.md +76 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/references/ranking.md +282 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/references/sector.md +47 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/references/short_selling.md +53 -0
- package/plugins/trading/trading-tools/skills/kiwoom-api/references/stock_info.md +658 -0
- package/plugins/trading/trading-tools/skills/opendart-api/.env.example +9 -0
- package/plugins/trading/trading-tools/skills/opendart-api/SKILL.md +191 -0
- package/plugins/trading/trading-tools/skills/opendart-api/references/api_reference.md +342 -0
- package/plugins/trading/trading-tools/skills/opendart-api/references/corp_codes.md +90 -0
- package/plugins/trading/trading-tools/skills/opendart-api/scripts/get_corp_code.py +89 -0
- package/plugins/trading/trading-tools/skills/opendart-api/scripts/get_disclosures.py +97 -0
|
@@ -0,0 +1,940 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ffmpeg-cli
|
|
3
|
+
description: This skill should be used when processing video, audio, or image files with FFmpeg. Use this skill for tasks like adding text/subtitles, extracting/mixing audio, converting formats, merging/trimming videos, applying transitions/fades, overlaying images/videos, and querying media metadata. Ideal for multimedia processing, video editing, format conversion, and media file manipulation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FFmpeg CLI
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Execute FFmpeg command-line operations to process video, audio, and image files. This skill provides comprehensive FFmpeg workflows for 13 common multimedia processing tasks, from basic format conversion to advanced video editing with transitions and overlays.
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
Verify FFmpeg installation before proceeding:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
ffmpeg -version
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Minimum version:** FFmpeg 4.3+ (for xfade transitions)
|
|
21
|
+
**Common installation:**
|
|
22
|
+
- macOS: `brew install ffmpeg`
|
|
23
|
+
- Linux: `apt-get install ffmpeg` or `yum install ffmpeg`
|
|
24
|
+
- Windows: Download from ffmpeg.org
|
|
25
|
+
|
|
26
|
+
## Official CLI Syntax
|
|
27
|
+
|
|
28
|
+
### Command Structure
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url} ...
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
> **Critical Rule**: Options are positional. Input options apply ONLY to the next `-i`. Output options apply ONLY to the next output file. Misordering options causes silent misbehavior.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# CORRECT: -ss seeks input (fast), -t limits output duration
|
|
38
|
+
ffmpeg -y -ss 5 -i input.mp4 -t 10 -c:v libx264 output.mp4
|
|
39
|
+
# ^ ^ ^ ^
|
|
40
|
+
# | input option output options output file
|
|
41
|
+
# global option
|
|
42
|
+
|
|
43
|
+
# DIFFERENT BEHAVIOR: -ss after -i seeks output (slow but accurate)
|
|
44
|
+
ffmpeg -y -i input.mp4 -ss 5 -t 10 -c:v libx264 output.mp4
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Stream Specifiers
|
|
48
|
+
|
|
49
|
+
Target specific streams with `-option:stream_specifier`:
|
|
50
|
+
|
|
51
|
+
| Pattern | Meaning | Example |
|
|
52
|
+
|---------|---------|---------|
|
|
53
|
+
| `v` | All video streams | `-c:v libx264` |
|
|
54
|
+
| `a` | All audio streams | `-c:a aac` |
|
|
55
|
+
| `s` | All subtitle streams | `-c:s mov_text` |
|
|
56
|
+
| `v:0` | First video stream | `-b:v:0 2M` |
|
|
57
|
+
| `a:1` | Second audio stream | `-c:a:1 copy` |
|
|
58
|
+
|
|
59
|
+
### Stream Mapping
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Without -map: auto-selects best video + best audio + first subtitle
|
|
63
|
+
ffmpeg -i input.mp4 output.mp4
|
|
64
|
+
|
|
65
|
+
# With -map: auto-selection DISABLED — must map ALL desired streams
|
|
66
|
+
ffmpeg -i input.mp4 -map 0:v -map 0:a output.mp4
|
|
67
|
+
|
|
68
|
+
# Multiple inputs: video from first, audio from second
|
|
69
|
+
ffmpeg -i video.mp4 -i audio.mp3 -map 0:v -map 1:a output.mp4
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
> **Gotcha**: Using `-map` once disables auto-selection. Forgetting to map audio = silent output.
|
|
73
|
+
|
|
74
|
+
### Seeking Behavior
|
|
75
|
+
|
|
76
|
+
| Position | Speed | Accuracy | Use Case |
|
|
77
|
+
|----------|-------|----------|----------|
|
|
78
|
+
| `-ss` before `-i` | Fast (keyframe seek) | Approximate | Stream copy, rough cuts |
|
|
79
|
+
| `-ss` after `-i` | Slow (decode & discard) | Frame-exact | Precise editing |
|
|
80
|
+
| Both combined | Fast + Accurate | Best of both | Recommended for re-encode |
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Fast seeking (good with -c copy)
|
|
84
|
+
ffmpeg -ss 30 -i input.mp4 -t 10 -c copy output.mp4
|
|
85
|
+
|
|
86
|
+
# Accurate seeking (re-encode required)
|
|
87
|
+
ffmpeg -i input.mp4 -ss 30 -t 10 -c:v libx264 -c:a aac output.mp4
|
|
88
|
+
|
|
89
|
+
# Combined: fast jump + fine-tune
|
|
90
|
+
ffmpeg -ss 29 -i input.mp4 -ss 1 -t 10 -c:v libx264 -c:a aac output.mp4
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Stream Copy vs Re-encoding
|
|
94
|
+
|
|
95
|
+
| | `-c copy` | Re-encode (`-c:v libx264`) |
|
|
96
|
+
|---|-----------|---------------------------|
|
|
97
|
+
| Speed | Very fast | Slow |
|
|
98
|
+
| Quality | Lossless (original) | Depends on settings |
|
|
99
|
+
| Filters | Cannot use | Required for filters |
|
|
100
|
+
| Cut accuracy | Keyframe only | Frame-exact |
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Stream copy (fast, no quality loss, no filters)
|
|
104
|
+
ffmpeg -i input.mp4 -c copy output.mp4
|
|
105
|
+
|
|
106
|
+
# Re-encode video only (allows video filters, copies audio)
|
|
107
|
+
ffmpeg -i input.mp4 -vf "scale=1280:720" -c:v libx264 -c:a copy output.mp4
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Common Patterns
|
|
111
|
+
|
|
112
|
+
**Copy without re-encoding (fast):**
|
|
113
|
+
```bash
|
|
114
|
+
ffmpeg -i input.mp4 -c copy output.mp4
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Re-encode with quality control:**
|
|
118
|
+
```bash
|
|
119
|
+
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a aac output.mp4
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Apply video filter:**
|
|
123
|
+
```bash
|
|
124
|
+
ffmpeg -i input.mp4 -vf "filter_name=param=value" -c:a copy output.mp4
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Complex filter graph:**
|
|
128
|
+
```bash
|
|
129
|
+
ffmpeg -i input1.mp4 -i input2.mp4 \
|
|
130
|
+
-filter_complex "[0:v][1:v]filter_name[out]" \
|
|
131
|
+
-map "[out]" -map 0:a output.mp4
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Core Operations
|
|
135
|
+
|
|
136
|
+
### 1. Add Text to Video
|
|
137
|
+
|
|
138
|
+
Add text overlays with full control over font, size, color, position, and timing.
|
|
139
|
+
|
|
140
|
+
**Basic text overlay:**
|
|
141
|
+
```bash
|
|
142
|
+
ffmpeg -i input.mp4 \
|
|
143
|
+
-vf "drawtext=fontfile=/path/to/font.ttf:text='Hello World':fontsize=48:fontcolor=white:x=(w-text_w)/2:y=h-th-20" \
|
|
144
|
+
-c:a copy output.mp4
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Parameters:**
|
|
148
|
+
- `fontfile` - Path to TrueType font file (required)
|
|
149
|
+
- `text` - Text content (escape single quotes: `don''t`)
|
|
150
|
+
- `fontsize` - Font size in pixels (default: 16)
|
|
151
|
+
- `fontcolor` - Color name or hex value
|
|
152
|
+
- `x`, `y` - Position (numbers or expressions)
|
|
153
|
+
- `enable` - Time control: `'between(t,5,10)'`
|
|
154
|
+
|
|
155
|
+
**Position expressions:**
|
|
156
|
+
- `(w-text_w)/2` - center horizontally
|
|
157
|
+
- `(h-text_h)/2` - center vertically
|
|
158
|
+
- `10` - 10px from left/top edge
|
|
159
|
+
- `w-text_w-10` - 10px from right edge
|
|
160
|
+
- `h-th-20` - 20px from bottom edge
|
|
161
|
+
|
|
162
|
+
**Text with background box:**
|
|
163
|
+
```bash
|
|
164
|
+
ffmpeg -i input.mp4 \
|
|
165
|
+
-vf "drawtext=fontfile=/path/to/font.ttf:text='Subtitle':fontsize=48:fontcolor=white:x=(w-text_w)/2:y=h-th-20:box=1:boxcolor=black@0.5:boxborderw=5" \
|
|
166
|
+
-c:a copy output.mp4
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Timed text (show from 5 to 10 seconds):**
|
|
170
|
+
```bash
|
|
171
|
+
ffmpeg -i input.mp4 \
|
|
172
|
+
-vf "drawtext=fontfile=/path/to/font.ttf:text='Limited':fontsize=48:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:enable='between(t,5,10)'" \
|
|
173
|
+
-c:a copy output.mp4
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 2. Add Subtitles from SRT File
|
|
177
|
+
|
|
178
|
+
Burn subtitles from SRT file into video.
|
|
179
|
+
|
|
180
|
+
**Method 1: Using subtitles filter (recommended):**
|
|
181
|
+
```bash
|
|
182
|
+
ffmpeg -i input.mp4 -vf "subtitles=subtitle.srt" -c:a copy output.mp4
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Method 2: Custom styling with drawtext (programmatic):**
|
|
186
|
+
|
|
187
|
+
Parse SRT file and generate drawtext filter chain for each subtitle entry. Each entry becomes:
|
|
188
|
+
```bash
|
|
189
|
+
drawtext=fontfile=/path/to/font.ttf:text='subtitle text':fontsize=48:fontcolor=white:x=(w-text_w)/2:y=h-th-50:box=1:boxcolor=black@0.5:boxborderw=5:enable='between(t,START_TIME,END_TIME)'
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Combine all entries with commas:
|
|
193
|
+
```bash
|
|
194
|
+
ffmpeg -i input.mp4 -vf "drawtext=...,drawtext=...,drawtext=..." -c:a copy output.mp4
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Custom subtitle styling:**
|
|
198
|
+
```bash
|
|
199
|
+
ffmpeg -i input.mp4 \
|
|
200
|
+
-vf "subtitles=subtitle.srt:force_style='FontName=Arial,FontSize=24,PrimaryColour=&H00FFFFFF'" \
|
|
201
|
+
-c:a copy output.mp4
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 3. Extract Audio from Video
|
|
205
|
+
|
|
206
|
+
Extract audio track in various formats.
|
|
207
|
+
|
|
208
|
+
**Extract as MP3:**
|
|
209
|
+
```bash
|
|
210
|
+
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k -map 0:a:0 output.mp3
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Extract as AAC:**
|
|
214
|
+
```bash
|
|
215
|
+
ffmpeg -i input.mp4 -vn -c:a aac -b:a 192k -map 0:a:0 output.aac
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Extract as WAV (lossless):**
|
|
219
|
+
```bash
|
|
220
|
+
ffmpeg -i input.mp4 -vn -c:a pcm_s16le -map 0:a:0 output.wav
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Copy audio without re-encoding:**
|
|
224
|
+
```bash
|
|
225
|
+
ffmpeg -i input.mp4 -vn -c:a copy -map 0:a:0 output.m4a
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Parameters:**
|
|
229
|
+
- `-vn` - Remove video stream
|
|
230
|
+
- `-c:a` - Audio codec (libmp3lame, aac, copy)
|
|
231
|
+
- `-b:a` - Audio bitrate (128k, 192k, 320k)
|
|
232
|
+
- `-map 0:a:0` - Select first audio stream
|
|
233
|
+
|
|
234
|
+
### 4. Convert Image to Video
|
|
235
|
+
|
|
236
|
+
Convert static image to video with specified duration.
|
|
237
|
+
|
|
238
|
+
**Basic conversion:**
|
|
239
|
+
```bash
|
|
240
|
+
ffmpeg -loop 1 -i image.png \
|
|
241
|
+
-c:v libx264 -t 10 -pix_fmt yuv420p \
|
|
242
|
+
output.mp4
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**With silent audio for compatibility:**
|
|
246
|
+
```bash
|
|
247
|
+
ffmpeg -loop 1 -i image.png \
|
|
248
|
+
-f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 \
|
|
249
|
+
-c:v libx264 -c:a aac -t 10 -pix_fmt yuv420p -shortest \
|
|
250
|
+
output.mp4
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Custom dimensions:**
|
|
254
|
+
```bash
|
|
255
|
+
ffmpeg -loop 1 -i image.png \
|
|
256
|
+
-f lavfi -i anullsrc \
|
|
257
|
+
-vf "scale=1920:1080" \
|
|
258
|
+
-c:v libx264 -c:a aac -t 10 -pix_fmt yuv420p -shortest \
|
|
259
|
+
output.mp4
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Parameters:**
|
|
263
|
+
- `-loop 1` - Loop image input
|
|
264
|
+
- `-t` - Duration in seconds
|
|
265
|
+
- `-pix_fmt yuv420p` - Ensure compatibility
|
|
266
|
+
- `anullsrc` - Generate silent audio
|
|
267
|
+
- `-shortest` - Match shortest input duration
|
|
268
|
+
|
|
269
|
+
### 5. Merge/Concatenate Videos
|
|
270
|
+
|
|
271
|
+
Combine multiple videos into one.
|
|
272
|
+
|
|
273
|
+
**Method 1: Concat demuxer (same codec/format):**
|
|
274
|
+
```bash
|
|
275
|
+
# Create file list
|
|
276
|
+
echo "file 'video1.mp4'" > list.txt
|
|
277
|
+
echo "file 'video2.mp4'" >> list.txt
|
|
278
|
+
|
|
279
|
+
# Concatenate
|
|
280
|
+
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Method 2: Concat filter (different formats):**
|
|
284
|
+
```bash
|
|
285
|
+
ffmpeg -i video1.mp4 -i video2.mp4 -i video3.mp4 \
|
|
286
|
+
-filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a]concat=n=3:v=1:a=1[outv][outa]" \
|
|
287
|
+
-map "[outv]" -map "[outa]" output.mp4
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**Normalize before merging (different resolutions/framerates):**
|
|
291
|
+
|
|
292
|
+
For each input video, apply normalization:
|
|
293
|
+
```bash
|
|
294
|
+
scale=1920:1080:force_original_aspect_ratio=decrease,
|
|
295
|
+
pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=black,
|
|
296
|
+
setsar=1,
|
|
297
|
+
fps=30,
|
|
298
|
+
setpts=PTS-STARTPTS
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
For audio:
|
|
302
|
+
```bash
|
|
303
|
+
aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,
|
|
304
|
+
asetpts=PTS-STARTPTS
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Then concatenate normalized streams using concat protocol or concat filter.
|
|
308
|
+
|
|
309
|
+
**Handle videos without audio:**
|
|
310
|
+
|
|
311
|
+
Check if video has audio using ffprobe. If missing, add silent audio:
|
|
312
|
+
```bash
|
|
313
|
+
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100:duration=VIDEO_DURATION
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Mix with video stream before normalization.
|
|
317
|
+
|
|
318
|
+
### 6. Mix Audio with Video
|
|
319
|
+
|
|
320
|
+
Combine video with background music or replace audio.
|
|
321
|
+
|
|
322
|
+
**Basic audio mixing:**
|
|
323
|
+
```bash
|
|
324
|
+
ffmpeg -i video.mp4 -i music.mp3 \
|
|
325
|
+
-filter_complex "[0:a]volume=1.0[a0];[1:a]volume=0.5[a1];[a0][a1]amix=inputs=2:duration=first[a]" \
|
|
326
|
+
-map 0:v -map "[a]" -c:v copy output.mp4
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**Replace video audio:**
|
|
330
|
+
```bash
|
|
331
|
+
ffmpeg -i video.mp4 -i new_audio.mp3 \
|
|
332
|
+
-map 0:v -map 1:a -c:v copy -c:a aac -shortest output.mp4
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**Advanced mixing with fade effects:**
|
|
336
|
+
```bash
|
|
337
|
+
ffmpeg -i video.mp4 -i music.mp3 \
|
|
338
|
+
-filter_complex "
|
|
339
|
+
[1:a]afade=t=in:st=0:d=2,afade=t=out:st=28:d=2,volume=0.5[a1];
|
|
340
|
+
[0:a]volume=1.0[a0];
|
|
341
|
+
[a0][a1]amix=inputs=2:duration=first[a]
|
|
342
|
+
" \
|
|
343
|
+
-map 0:v -map "[a]" -c:v copy output.mp4
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**Partial mixing with time control:**
|
|
347
|
+
|
|
348
|
+
Process audio with:
|
|
349
|
+
```bash
|
|
350
|
+
[1:a]atrim=duration=DURATION,asetpts=PTS-STARTPTS,volume=VOLUME,adelay=START_TIME*1000|START_TIME*1000[overlay]
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Mix with main audio:
|
|
354
|
+
```bash
|
|
355
|
+
[0:a]volume=VIDEO_VOLUME[main];
|
|
356
|
+
[main][overlay]amix=inputs=2:duration=first[out]
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
**Loop short audio:**
|
|
360
|
+
```bash
|
|
361
|
+
[1:a]aloop=loop=-1:size=2e9,atrim=duration=VIDEO_DURATION[looped]
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**Parameters:**
|
|
365
|
+
- `volume` - Volume multiplier (0.0-2.0)
|
|
366
|
+
- `amix:duration` - longest/shortest/first
|
|
367
|
+
- `adelay` - Delay in milliseconds
|
|
368
|
+
- `afade` - Fade in/out
|
|
369
|
+
- `atrim` - Trim audio duration
|
|
370
|
+
- `aloop` - Loop audio (-1 for infinite)
|
|
371
|
+
|
|
372
|
+
### 7. Apply Video Transitions
|
|
373
|
+
|
|
374
|
+
Apply transition effects between multiple videos (requires FFmpeg 4.3+).
|
|
375
|
+
|
|
376
|
+
**Fade transition:**
|
|
377
|
+
```bash
|
|
378
|
+
ffmpeg -i video1.mp4 -i video2.mp4 \
|
|
379
|
+
-filter_complex "
|
|
380
|
+
[0:v][1:v]xfade=transition=fade:duration=1:offset=5[v];
|
|
381
|
+
[0:a][1:a]acrossfade=d=1[a]
|
|
382
|
+
" \
|
|
383
|
+
-map "[v]" -map "[a]" output.mp4
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
**Multiple videos with transitions:**
|
|
387
|
+
```bash
|
|
388
|
+
ffmpeg -i v1.mp4 -i v2.mp4 -i v3.mp4 \
|
|
389
|
+
-filter_complex "
|
|
390
|
+
[0:v][1:v]xfade=transition=fade:duration=1:offset=5[v01];
|
|
391
|
+
[v01][2:v]xfade=transition=wipeleft:duration=1:offset=10[v];
|
|
392
|
+
[0:a][1:a]acrossfade=d=1[a01];
|
|
393
|
+
[a01][2:a]acrossfade=d=1[a]
|
|
394
|
+
" \
|
|
395
|
+
-map "[v]" -map "[a]" output.mp4
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**Available transitions:**
|
|
399
|
+
- `fade`, `fadeblack`, `fadewhite`
|
|
400
|
+
- `wipeleft`, `wiperight`, `wipeup`, `wipedown`
|
|
401
|
+
- `slideleft`, `slideright`, `slideup`, `slidedown`
|
|
402
|
+
- `circlecrop`, `rectcrop`, `distance`
|
|
403
|
+
- `dissolve`, `pixelize`, `radial`
|
|
404
|
+
|
|
405
|
+
**Normalize videos before transition:**
|
|
406
|
+
|
|
407
|
+
When videos have different resolutions or framerates:
|
|
408
|
+
```bash
|
|
409
|
+
[0:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:black,settb=AVTB[v0];
|
|
410
|
+
[1:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:black,settb=AVTB[v1];
|
|
411
|
+
[v0][v1]xfade=transition=fade:duration=1:offset=5[v]
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
**Fallback for FFmpeg < 4.3:**
|
|
415
|
+
|
|
416
|
+
Use fade + concat instead:
|
|
417
|
+
```bash
|
|
418
|
+
# First video: fade out at end
|
|
419
|
+
[0:v]fade=t=out:st=5:d=1[v0];
|
|
420
|
+
# Second video: fade in at start
|
|
421
|
+
[1:v]fade=t=in:st=0:d=1[v1];
|
|
422
|
+
# Concatenate
|
|
423
|
+
[v0][0:a][v1][1:a]concat=n=2:v=1:a=1[outv][outa]
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
**Parameters:**
|
|
427
|
+
- `transition` - Transition type
|
|
428
|
+
- `duration` - Transition duration in seconds
|
|
429
|
+
- `offset` - When transition starts in first video
|
|
430
|
+
- `acrossfade:d` - Audio crossfade duration
|
|
431
|
+
|
|
432
|
+
### 8. Overlay Video/Image
|
|
433
|
+
|
|
434
|
+
Place one video or image on top of another.
|
|
435
|
+
|
|
436
|
+
**Basic overlay (logo/watermark):**
|
|
437
|
+
```bash
|
|
438
|
+
ffmpeg -i video.mp4 -i logo.png \
|
|
439
|
+
-filter_complex "[1:v]scale=150:-1[logo];[0:v][logo]overlay=10:10" \
|
|
440
|
+
-c:a copy output.mp4
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
**Positioned overlays:**
|
|
444
|
+
```bash
|
|
445
|
+
# Bottom-right corner
|
|
446
|
+
overlay=main_w-overlay_w-10:main_h-overlay_h-10
|
|
447
|
+
|
|
448
|
+
# Center
|
|
449
|
+
overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2
|
|
450
|
+
|
|
451
|
+
# Top-right
|
|
452
|
+
overlay=main_w-overlay_w-10:10
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
**Overlay with opacity:**
|
|
456
|
+
```bash
|
|
457
|
+
ffmpeg -i video.mp4 -i logo.png \
|
|
458
|
+
-filter_complex "[1:v]scale=150:-1,colorchannelmixer=aa=0.5[logo];[0:v][logo]overlay=10:10" \
|
|
459
|
+
-c:a copy output.mp4
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
**Timed overlay (show from 5 to 15 seconds):**
|
|
463
|
+
```bash
|
|
464
|
+
ffmpeg -i video.mp4 -i logo.png \
|
|
465
|
+
-filter_complex "[1:v]scale=150:-1[logo];[0:v][logo]overlay=10:10:enable='between(t,5,15)'" \
|
|
466
|
+
-c:a copy output.mp4
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
**Picture-in-picture:**
|
|
470
|
+
```bash
|
|
471
|
+
ffmpeg -i main.mp4 -i small.mp4 \
|
|
472
|
+
-filter_complex "
|
|
473
|
+
[1:v]scale=320:-1[pip];
|
|
474
|
+
[0:v][pip]overlay=main_w-overlay_w-10:10[v]
|
|
475
|
+
" \
|
|
476
|
+
-map "[v]" -map 0:a -c:a copy output.mp4
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
**Audio handling options:**
|
|
480
|
+
|
|
481
|
+
```bash
|
|
482
|
+
# Use main video audio only
|
|
483
|
+
-map 0:a
|
|
484
|
+
|
|
485
|
+
# Use overlay video audio only
|
|
486
|
+
-map 1:a
|
|
487
|
+
|
|
488
|
+
# Mix both audio tracks
|
|
489
|
+
-filter_complex "...[v];[0:a]volume=1.0[a0];[1:a]volume=0.5[a1];[a0][a1]amix=inputs=2:duration=longest[a]"
|
|
490
|
+
-map "[v]" -map "[a]"
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
**Parameters:**
|
|
494
|
+
- `scale` - Resize overlay (width:height, -1 for auto)
|
|
495
|
+
- `colorchannelmixer=aa` - Opacity (0.0-1.0)
|
|
496
|
+
- `overlay=x:y` - Position
|
|
497
|
+
- `enable` - Time control
|
|
498
|
+
- `eof_action=pass` - Continue main after overlay ends
|
|
499
|
+
|
|
500
|
+
### 9. Separate Video and Audio
|
|
501
|
+
|
|
502
|
+
Split video into separate video (muted) and audio files.
|
|
503
|
+
|
|
504
|
+
**Create muted video:**
|
|
505
|
+
```bash
|
|
506
|
+
ffmpeg -i input.mp4 -an -c:v copy video_only.mp4
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
**Extract audio:**
|
|
510
|
+
```bash
|
|
511
|
+
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k -map 0:a:0 audio.mp3
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
**Both in one operation:**
|
|
515
|
+
```bash
|
|
516
|
+
# Muted video
|
|
517
|
+
ffmpeg -i input.mp4 -an -c:v copy video_only.mp4
|
|
518
|
+
|
|
519
|
+
# Audio file
|
|
520
|
+
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k -map 0:a:0 audio.mp3
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
**Parameters:**
|
|
524
|
+
- `-an` - Remove audio stream
|
|
525
|
+
- `-vn` - Remove video stream
|
|
526
|
+
- `-c:v copy` - Copy video without re-encoding
|
|
527
|
+
- `-c:a` - Audio codec (libmp3lame, aac, copy)
|
|
528
|
+
|
|
529
|
+
### 10. Apply Fade In/Out
|
|
530
|
+
|
|
531
|
+
Add fade in or fade out effects to video and/or audio.
|
|
532
|
+
|
|
533
|
+
**Video fade in/out:**
|
|
534
|
+
```bash
|
|
535
|
+
ffmpeg -i input.mp4 \
|
|
536
|
+
-vf "fade=type=in:st=0:d=2,fade=type=out:st=28:d=2" \
|
|
537
|
+
-c:a copy output.mp4
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
**Audio fade in/out:**
|
|
541
|
+
```bash
|
|
542
|
+
ffmpeg -i input.mp4 \
|
|
543
|
+
-af "afade=type=in:st=0:d=2,afade=type=out:st=28:d=2" \
|
|
544
|
+
-c:v copy output.mp4
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
**Both video and audio fade:**
|
|
548
|
+
```bash
|
|
549
|
+
ffmpeg -i input.mp4 \
|
|
550
|
+
-vf "fade=type=in:st=0:d=2,fade=type=out:st=28:d=2" \
|
|
551
|
+
-af "afade=type=in:st=0:d=2,afade=type=out:st=28:d=2" \
|
|
552
|
+
output.mp4
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
**Fade to/from white:**
|
|
556
|
+
```bash
|
|
557
|
+
ffmpeg -i input.mp4 \
|
|
558
|
+
-vf "fade=type=in:st=0:d=2:color=white" \
|
|
559
|
+
-c:a copy output.mp4
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
**Parameters:**
|
|
563
|
+
- `type` - `in` or `out`
|
|
564
|
+
- `st` - Start time in seconds
|
|
565
|
+
- `d` - Duration in seconds
|
|
566
|
+
- `color` - Fade color (default: black)
|
|
567
|
+
|
|
568
|
+
### 11. Add Image Stamp/Watermark
|
|
569
|
+
|
|
570
|
+
Add logo, watermark, or stamp image to video.
|
|
571
|
+
|
|
572
|
+
**Basic stamp:**
|
|
573
|
+
```bash
|
|
574
|
+
ffmpeg -i video.mp4 -i stamp.png \
|
|
575
|
+
-filter_complex "[1:v]scale=150:-1[stamp];[0:v][stamp]overlay=10:10" \
|
|
576
|
+
-c:a copy output.mp4
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
**Rotated stamp:**
|
|
580
|
+
```bash
|
|
581
|
+
ffmpeg -i video.mp4 -i stamp.png \
|
|
582
|
+
-filter_complex "
|
|
583
|
+
[1:v]scale=150:-1,rotate=PI/4:fillcolor=none[stamp];
|
|
584
|
+
[0:v][stamp]overlay=10:10
|
|
585
|
+
" \
|
|
586
|
+
-c:a copy output.mp4
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
**Stamp with opacity:**
|
|
590
|
+
```bash
|
|
591
|
+
ffmpeg -i video.mp4 -i stamp.png \
|
|
592
|
+
-filter_complex "
|
|
593
|
+
[1:v]scale=150:-1,colorchannelmixer=aa=0.5[stamp];
|
|
594
|
+
[0:v][stamp]overlay=10:10
|
|
595
|
+
" \
|
|
596
|
+
-c:a copy output.mp4
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
**Timed stamp (show from 5 to 15 seconds):**
|
|
600
|
+
```bash
|
|
601
|
+
ffmpeg -i video.mp4 -i stamp.png \
|
|
602
|
+
-filter_complex "
|
|
603
|
+
[1:v]scale=150:-1[stamp];
|
|
604
|
+
[0:v][stamp]overlay=10:10:enable='between(t,5,15)'
|
|
605
|
+
" \
|
|
606
|
+
-c:a copy output.mp4
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
**Parameters:**
|
|
610
|
+
- `scale` - Resize stamp (width:height, -1 for auto)
|
|
611
|
+
- `rotate` - Rotation angle in radians (PI/2 = 90°, PI/4 = 45°)
|
|
612
|
+
- `colorchannelmixer=aa` - Opacity (0.0-1.0)
|
|
613
|
+
- `overlay=x:y` - Position
|
|
614
|
+
- `enable` - Time control
|
|
615
|
+
|
|
616
|
+
### 12. Trim/Cut Video
|
|
617
|
+
|
|
618
|
+
Extract portion of video between specified times.
|
|
619
|
+
|
|
620
|
+
**Fast cut (keyframe-accurate, input seeking):**
|
|
621
|
+
```bash
|
|
622
|
+
ffmpeg -ss 5 -i input.mp4 -t 10 -c copy output.mp4
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
**Accurate cut (frame-exact, output seeking + re-encode):**
|
|
626
|
+
```bash
|
|
627
|
+
ffmpeg -i input.mp4 -ss 5 -t 10 -c:v libx264 -c:a aac output.mp4
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
**Combined seeking (fast + accurate):**
|
|
631
|
+
```bash
|
|
632
|
+
ffmpeg -ss 4 -i input.mp4 -ss 1 -t 10 -c:v libx264 -c:a aac output.mp4
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
**Extract from 5 to 15 seconds:**
|
|
636
|
+
```bash
|
|
637
|
+
ffmpeg -ss 5 -i input.mp4 -to 10 -c copy output.mp4
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
**Time duration formats:**
|
|
641
|
+
```bash
|
|
642
|
+
-ss 01:23:45.678 # HH:MM:SS.mmm
|
|
643
|
+
-ss 5:30 # MM:SS (5 min 30 sec)
|
|
644
|
+
-ss 90 # seconds (numeric)
|
|
645
|
+
-ss 5500ms # milliseconds with suffix
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
**Parameters:**
|
|
649
|
+
- `-ss` before `-i` - Input seeking (fast, keyframe-accurate)
|
|
650
|
+
- `-ss` after `-i` - Output seeking (slow, frame-accurate)
|
|
651
|
+
- `-to` - End time (absolute when `-ss` is after `-i`, relative when before)
|
|
652
|
+
- `-t` - Duration (always relative from seek point)
|
|
653
|
+
- `-c copy` - Stream copy (fast, keyframe-accurate only)
|
|
654
|
+
- `-c:v libx264` - Re-encode for frame-accurate cutting
|
|
655
|
+
|
|
656
|
+
> **Gotcha**: `-to` behaves differently depending on `-ss` position. With input seeking (`-ss` before `-i`), `-to` becomes relative to the new start.
|
|
657
|
+
|
|
658
|
+
### 13. Probe Media Information
|
|
659
|
+
|
|
660
|
+
Query metadata and technical details of media files.
|
|
661
|
+
|
|
662
|
+
**Complete metadata (JSON):**
|
|
663
|
+
```bash
|
|
664
|
+
ffprobe -v quiet -print_format json -show_format -show_streams input.mp4
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
**Quick info:**
|
|
668
|
+
```bash
|
|
669
|
+
ffmpeg -i input.mp4 2>&1 | grep -E 'Duration|Stream'
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
**Video resolution:**
|
|
673
|
+
```bash
|
|
674
|
+
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 input.mp4
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
**Video duration:**
|
|
678
|
+
```bash
|
|
679
|
+
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
**Check if video has audio:**
|
|
683
|
+
```bash
|
|
684
|
+
ffprobe -i input.mp4 -show_streams -select_streams a -loglevel error
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
**Framerate:**
|
|
688
|
+
```bash
|
|
689
|
+
ffprobe -v error -select_streams v:0 -show_entries stream=r_frame_rate -of default=noprint_wrappers=1:nokey=1 input.mp4
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
**Codec information:**
|
|
693
|
+
```bash
|
|
694
|
+
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 input.mp4
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
## Advanced Patterns
|
|
698
|
+
|
|
699
|
+
### Complex Filter Graphs
|
|
700
|
+
|
|
701
|
+
**Multiple outputs from single input:**
|
|
702
|
+
```bash
|
|
703
|
+
ffmpeg -i input.mp4 \
|
|
704
|
+
-filter_complex "
|
|
705
|
+
[0:v]split=2[v1][v2];
|
|
706
|
+
[v1]scale=1920:1080[out1];
|
|
707
|
+
[v2]scale=1280:720[out2]
|
|
708
|
+
" \
|
|
709
|
+
-map "[out1]" -c:v libx264 output_1080p.mp4 \
|
|
710
|
+
-map "[out2]" -c:v libx264 output_720p.mp4
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
**Side-by-side comparison:**
|
|
714
|
+
```bash
|
|
715
|
+
ffmpeg -i left.mp4 -i right.mp4 \
|
|
716
|
+
-filter_complex "
|
|
717
|
+
[0:v]scale=640:480[left];
|
|
718
|
+
[1:v]scale=640:480[right];
|
|
719
|
+
[left][right]hstack[v]
|
|
720
|
+
" \
|
|
721
|
+
-map "[v]" output.mp4
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
### Quality Control
|
|
725
|
+
|
|
726
|
+
**CRF (Constant Rate Factor) — recommended for local files:**
|
|
727
|
+
|
|
728
|
+
| CRF | Quality | Use Case |
|
|
729
|
+
|-----|---------|----------|
|
|
730
|
+
| 0 | Lossless | Archival |
|
|
731
|
+
| 18 | Visually lossless | Professional editing |
|
|
732
|
+
| 23 | Good (default) | General purpose |
|
|
733
|
+
| 28 | Acceptable | Web distribution |
|
|
734
|
+
| 51 | Worst | (not recommended) |
|
|
735
|
+
|
|
736
|
+
```bash
|
|
737
|
+
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac output.mp4
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
**Constrained bitrate — recommended for streaming:**
|
|
741
|
+
```bash
|
|
742
|
+
# Average bitrate with buffer control
|
|
743
|
+
ffmpeg -i input.mp4 -c:v libx264 -b:v 2M -maxrate 2.5M -bufsize 5M -c:a aac output.mp4
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
> **Gotcha**: `-b:v 2M` = 2 Megabits/s (not bytes). FFmpeg uses bits/s. Use `K`, `M`, `G` suffixes.
|
|
747
|
+
|
|
748
|
+
**Two-pass encoding (best quality at target bitrate):**
|
|
749
|
+
```bash
|
|
750
|
+
# Pass 1 (analysis only — output to /dev/null)
|
|
751
|
+
ffmpeg -i input.mp4 -c:v libx264 -b:v 2M -pass 1 -f null /dev/null
|
|
752
|
+
|
|
753
|
+
# Pass 2 (actual encoding using analysis)
|
|
754
|
+
ffmpeg -i input.mp4 -c:v libx264 -b:v 2M -pass 2 -c:a aac output.mp4
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
**Encoding presets** (speed → quality tradeoff):
|
|
758
|
+
|
|
759
|
+
`ultrafast` > `superfast` > `veryfast` > `faster` > `fast` > `medium` > `slow` > `slower` > `veryslow`
|
|
760
|
+
|
|
761
|
+
**Tunes** (content-type optimization):
|
|
762
|
+
```bash
|
|
763
|
+
# Animation
|
|
764
|
+
ffmpeg -i input.mp4 -c:v libx264 -crf 20 -tune animation output.mp4
|
|
765
|
+
|
|
766
|
+
# Screen recording
|
|
767
|
+
ffmpeg -i input.mp4 -c:v libx264 -crf 18 -tune stillimage output.mp4
|
|
768
|
+
|
|
769
|
+
# Streaming (low latency)
|
|
770
|
+
ffmpeg -i input.mp4 -c:v libx264 -preset fast -tune zerolatency output.mp4
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
**Audio codec options:**
|
|
774
|
+
```bash
|
|
775
|
+
# AAC at 192kbps
|
|
776
|
+
-c:a aac -b:a 192k
|
|
777
|
+
|
|
778
|
+
# MP3 VBR high quality (~190kbps average)
|
|
779
|
+
-c:a libmp3lame -q:a 2
|
|
780
|
+
|
|
781
|
+
# MP3 CBR 192kbps
|
|
782
|
+
-c:a libmp3lame -b:a 192k
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
> **Gotcha**: VBR (`-q:a`) and CBR (`-b:a`) are mutually exclusive for MP3. Don't use both.
|
|
786
|
+
|
|
787
|
+
### Hardware Acceleration
|
|
788
|
+
|
|
789
|
+
**macOS (VideoToolbox):**
|
|
790
|
+
```bash
|
|
791
|
+
ffmpeg -hwaccel videotoolbox -i input.mp4 -c:v h264_videotoolbox output.mp4
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
**Linux/NVIDIA (NVENC):**
|
|
795
|
+
```bash
|
|
796
|
+
ffmpeg -hwaccel cuda -i input.mp4 -c:v h264_nvenc output.mp4
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
**Auto-detect:**
|
|
800
|
+
```bash
|
|
801
|
+
ffmpeg -hwaccel auto -i input.mp4 -c:v libx264 output.mp4
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
## Common Issues and Solutions
|
|
805
|
+
|
|
806
|
+
### Fix Corrupted Video
|
|
807
|
+
```bash
|
|
808
|
+
ffmpeg -i corrupted.mp4 -c copy fixed.mp4
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
### Add Silent Audio to Video
|
|
812
|
+
```bash
|
|
813
|
+
ffmpeg -i video.mp4 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 \
|
|
814
|
+
-c:v copy -c:a aac -shortest output.mp4
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
### Ensure Even Dimensions (H.264 requirement)
|
|
818
|
+
```bash
|
|
819
|
+
ffmpeg -i input.mp4 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:a copy output.mp4
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
### Convert Variable to Constant Framerate
|
|
823
|
+
```bash
|
|
824
|
+
ffmpeg -i input.mp4 -vf fps=30 -c:v libx264 -c:a copy output.mp4
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
### Rotate Video
|
|
828
|
+
```bash
|
|
829
|
+
# 90° clockwise
|
|
830
|
+
ffmpeg -i input.mp4 -vf "transpose=1" -c:a copy output.mp4
|
|
831
|
+
|
|
832
|
+
# 90° counter-clockwise
|
|
833
|
+
ffmpeg -i input.mp4 -vf "transpose=2" -c:a copy output.mp4
|
|
834
|
+
|
|
835
|
+
# 180°
|
|
836
|
+
ffmpeg -i input.mp4 -vf "transpose=2,transpose=2" -c:a copy output.mp4
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
### Remove Metadata
|
|
840
|
+
```bash
|
|
841
|
+
ffmpeg -i input.mp4 -map_metadata -1 -c copy output.mp4
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
## Best Practices
|
|
845
|
+
|
|
846
|
+
1. **Test with short clips first** before processing long videos
|
|
847
|
+
2. **Use `-c copy` when possible** to avoid re-encoding (faster, lossless)
|
|
848
|
+
3. **Always specify codecs explicitly** to avoid unexpected defaults
|
|
849
|
+
4. **Ensure even dimensions** for H.264: `scale=trunc(iw/2)*2:trunc(ih/2)*2`
|
|
850
|
+
5. **Add `-pix_fmt yuv420p`** for maximum compatibility
|
|
851
|
+
6. **Use CRF (18-28) for quality control** instead of fixed bitrate
|
|
852
|
+
7. **Check FFmpeg version** for filter compatibility: `ffmpeg -version`
|
|
853
|
+
8. **Backup original files** before batch processing
|
|
854
|
+
9. **Use `-y` flag cautiously** (overwrites without confirmation)
|
|
855
|
+
10. **Normalize audio** when mixing from different sources
|
|
856
|
+
|
|
857
|
+
## Common Global Options
|
|
858
|
+
|
|
859
|
+
- `-y` - Overwrite output file without asking
|
|
860
|
+
- `-n` - Never overwrite output file
|
|
861
|
+
- `-v quiet` - Suppress output messages
|
|
862
|
+
- `-stats` - Show encoding statistics
|
|
863
|
+
- `-threads 0` - Use all CPU cores
|
|
864
|
+
|
|
865
|
+
## Reference Documentation
|
|
866
|
+
|
|
867
|
+
### Official Syntax Reference
|
|
868
|
+
|
|
869
|
+
For authoritative FFmpeg syntax rules extracted from official documentation (ffmpeg.org), consult:
|
|
870
|
+
|
|
871
|
+
```bash
|
|
872
|
+
references/ffmpeg-syntax-reference.md
|
|
873
|
+
```
|
|
874
|
+
|
|
875
|
+
This includes:
|
|
876
|
+
- CLI grammar and option ordering rules
|
|
877
|
+
- Stream specifier syntax (all patterns)
|
|
878
|
+
- Stream mapping and auto-selection behavior
|
|
879
|
+
- Seeking behavior (input vs output seeking)
|
|
880
|
+
- Time duration, color, size, expression syntax
|
|
881
|
+
- Codec options with valid ranges (libx264, AAC, libmp3lame)
|
|
882
|
+
- Format options (concat demuxer, probing)
|
|
883
|
+
- Critical gotchas and common mistakes
|
|
884
|
+
|
|
885
|
+
### Detailed Filter Reference
|
|
886
|
+
|
|
887
|
+
For comprehensive documentation on all FFmpeg filters, parameters, and advanced usage patterns, consult:
|
|
888
|
+
|
|
889
|
+
```bash
|
|
890
|
+
references/ffmpeg-filters.md
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
This includes:
|
|
894
|
+
- Video filters: drawtext, fade, xfade, scale, overlay, pad, rotate, etc.
|
|
895
|
+
- Audio filters: afade, amix, acrossfade, volume, aformat, etc.
|
|
896
|
+
- Filter graph syntax hierarchy and escaping rules
|
|
897
|
+
- Expression evaluation (variables, functions, constants)
|
|
898
|
+
- Performance tips and common pitfalls
|
|
899
|
+
- Version compatibility information
|
|
900
|
+
|
|
901
|
+
### Common Recipes and Patterns
|
|
902
|
+
|
|
903
|
+
For frequently used command patterns and real-world examples, consult:
|
|
904
|
+
|
|
905
|
+
```bash
|
|
906
|
+
references/common-recipes.md
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
This includes:
|
|
910
|
+
- Text and subtitles recipes
|
|
911
|
+
- Audio processing workflows
|
|
912
|
+
- Video editing patterns
|
|
913
|
+
- Format conversion examples
|
|
914
|
+
- Quality optimization techniques
|
|
915
|
+
- Troubleshooting solutions
|
|
916
|
+
- Batch processing scripts
|
|
917
|
+
|
|
918
|
+
**Access references when:**
|
|
919
|
+
- Need accurate syntax rules → `ffmpeg-syntax-reference.md`
|
|
920
|
+
- Need filter parameters or escaping rules → `ffmpeg-filters.md`
|
|
921
|
+
- Need real-world command examples → `common-recipes.md`
|
|
922
|
+
|
|
923
|
+
## Version Requirements
|
|
924
|
+
|
|
925
|
+
- **FFmpeg 4.3+** - Required for xfade transitions
|
|
926
|
+
- **FFmpeg 3.0+** - Most other filters
|
|
927
|
+
- Check version: `ffmpeg -version`
|
|
928
|
+
- Check filter availability: `ffmpeg -filters | grep filter_name`
|
|
929
|
+
|
|
930
|
+
## Output Format Compatibility
|
|
931
|
+
|
|
932
|
+
**Ensure H.264/AAC compatibility:**
|
|
933
|
+
```bash
|
|
934
|
+
-c:v libx264 -c:a aac -pix_fmt yuv420p -movflags +faststart
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
**Parameters:**
|
|
938
|
+
- `-pix_fmt yuv420p` - Maximum playback compatibility
|
|
939
|
+
- `-movflags +faststart` - Enable web streaming (MP4)
|
|
940
|
+
- Even dimensions required for H.264
|