-
Notifications
You must be signed in to change notification settings - Fork 0
/
FFmpegSnippets.txt
52 lines (40 loc) · 2.35 KB
/
FFmpegSnippets.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Useful FFMpeg snippets from here and there
------------------------------------------
# Nicely convert 5.1 surround sound to stereo
ffmpeg -i ... -ac 2 -af "pan=stereo|FL=FC+0.30*FL+0.30*BL|FR=FC+0.30*FR+0.30*BR" -preset faster output.mp4
# Extract raw 5.1 surround stereo from a video
ffmpeg -i ... -vn -b:a 384k output.ogg
# (batch) Bulk convert AVI / MOV files that get compressed down too much with default settings
FOR /f %%a IN ('dir /b *.AVI') DO CALL ffmpeg -i %%a -b:a 48k -b:v 20000k -pix_fmt yuv420p %%~na.mp4
FOR /f %%a IN ('dir /b *.MOV') DO CALL ffmpeg -i %%a -b:a 48k -b:v 20000k %%~na.mpeg
# (powershell) Bulk convert AVI files using default MP4 settings
$dir = "..."
$outputDir = "..."
foreach ($file in [IO.Directory]::GetFiles($dir))
{
$fileRoot = [IO.Path]::GetFileNameWithoutExtension($file)
if ($file.EndsWith(".AVI"))
{
& .\ffmpeg.exe -i "$file" "$outputDir\$($fileRoot).mp4"
}
}
# Compare videos after FFmpeg compression for differences
.\ffmpeg.exe -i "original.mov" -i "converted.mp4" -filter_complex "blend=all_mode=difference" -c:v libx264 -crf 18 -c:a copy difference_output.mkv
# Cut a video from timestamp <start> for <duration>
.\ffmpeg.exe -ss <start> -i <input> -to <end> -c copy <output>
## Example: Cut the video so it starts 30 seconds later and run to the end, reconverting it as well.
\ffmpeg.exe -ss 00:00:30 -i "input.mp4" -c copy output.mp4
# Crop a video and slow it down to a 10th the speed (dropping frames and audio if framerate not > 30fps)
## Use '-r 29' to set the framerate appropriately.
## Use 10 to speed it up 10x
## Use -filter:a "atempo=2.0,atempo=2.0" to quadruple audio. You can only do 0.5 to 2x audio speedup / slowdown
ffmpeg -i "input.mp4" -filter:v "crop=680:in_h:390:0, setpts=0.10*PTS" -an "output.mp4"
# Change brightness/contrast/saturation points
## Also change the red/blue center points in the color curve
ffmpeg -i "input.mp4" -vf "eq=brightness=0:contrast=1:saturation=1,curves=red='0/0 0.5/0.58 1/1',curves=blue='0/0 0.5/0.4 1/1'" "output.mp4"
# Combine images into a 29 FPS video
ffmpeg -start_number 4701 -i DSC0%d.JPG -r 30 -s 1920x1080 out.mp4
## Run at 29 FPS without dropping frames
ffmpeg -start_number 1 -i %d.jpg -r 30 -s 1920x1080 -filter "setpts=8*PTS" out.mp4
## Align images via Hugin for video combiation
"C:\Program Files\Hugin\bin\align_image_stack.exe" -a a_ image1 image2 ... imageN