-
Notifications
You must be signed in to change notification settings - Fork 0
/
Generate.ps1
82 lines (62 loc) · 3.15 KB
/
Generate.ps1
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
$ErrorActionPreference = "Stop"
# Audio does a little ladder from 90 to 240 Hz, moving up by 30 Hz every 1s and looping every 5s.
$volume = "0.1"
$carrierFreq = "(90+mod(floor(t), 5)*30)"
$channelSweepFreq = "60"
$leftAudio = "$volume*sin(2*PI*($carrierFreq-$channelSweepFreq/2)*t)"
$rightAudio = "$volume*sin(2*PI*($carrierFreq+$channelSweepFreq/2)*t)"
function CreateTestPatterns($namePrefix, $durationSeconds, $fps, $width, $height, $color) {
# Video is some test pattern type of thing from FFmpeg
$videoA = "testsrc2=r=$($fps):s=$($width)x$($height)"
$videoB = "testsrc=r=$($fps):s=$($width)x$($height):n=3"
$outA = "$($namePrefix)_TestPatternA_$($fps)fps_$($height)p.mp4"
$outB = "$($namePrefix)_TestPatternB_$($fps)fps_$($height)p.mp4"
# If a color is specified, we remove other colors from the mix.
if ($color) {
$colorSource = "[video] chromahold=color=$($color):similarity=0.2 [out]"
$videoA = $videoA + " [video];" + $colorSource
$videoB = $videoB + " [video];" + $colorSource
}
ffmpeg -f lavfi -i "aevalsrc='$($leftAudio) | $($rightAudio):s=48000'" -f lavfi -i "$videoA" -pix_fmt yuv420p -acodec aac -ab 64k -t $durationSeconds -vcodec libx264 -tune animation $outA
if ($LASTEXITCODE -ne 0){
Write-Error "Failed with exit code $LASTEXITCODE"
}
ffmpeg -f lavfi -i "aevalsrc='$($leftAudio) | $($rightAudio):s=48000'" -f lavfi -i "$videoB" -pix_fmt yuv420p -acodec aac -ab 64k -t $durationSeconds -vcodec libx264 -tune animation $outB
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed with exit code $LASTEXITCODE"
}
}
$redcolor = $redcolor
$greencolor = "limegreen"
$bluecolor = "blue"
# 360p
CreateTestPatterns "1m" (60) 30 640 360
CreateTestPatterns "1m_red" (60) 30 640 360 $redcolor
CreateTestPatterns "1m_green" (60) 30 640 360 $greencolor
CreateTestPatterns "1m_blue" (60) 30 640 360 $bluecolor
CreateTestPatterns "10m" (600) 30 640 360
CreateTestPatterns "10m_red" (600) 30 640 360 $redcolor
CreateTestPatterns "10m_green" (600) 30 640 360 $greencolor
CreateTestPatterns "10m_blue" (600) 30 640 360 $bluecolor
CreateTestPatterns "3h" (3 * 3600) 30 640 360
CreateTestPatterns "24h" (24 * 3600) 30 640 360
# 1080p
CreateTestPatterns "1m" (60) 30 1920 1080
CreateTestPatterns "1m_red" (60) 30 1920 1080 $redcolor
CreateTestPatterns "1m_green" (60) 30 1920 1080 $greencolor
CreateTestPatterns "1m_blue" (60) 30 1920 1080 $bluecolor
CreateTestPatterns "10m" (600) 30 1920 1080
CreateTestPatterns "10m_red" (600) 30 1920 1080 $redcolor
CreateTestPatterns "10m_green" (600) 30 1920 1080 $greencolor
CreateTestPatterns "10m_blue" (600) 30 1920 1080 $bluecolor
CreateTestPatterns "3h" (3 * 3600) 30 1920 1080
CreateTestPatterns "24h" (24 * 3600) 30 1920 1080
# 2160p
CreateTestPatterns "1m" (60) 30 3840 2160
CreateTestPatterns "1m_red" (60) 30 3840 2160 $redcolor
CreateTestPatterns "1m_green" (60) 30 3840 2160 $greencolor
CreateTestPatterns "1m_blue" (60) 30 3840 2160 $bluecolor
CreateTestPatterns "10m" (600) 30 3840 2160
CreateTestPatterns "10m_red" (600) 30 3840 2160 $redcolor
CreateTestPatterns "10m_green" (600) 30 3840 2160 $greencolor
CreateTestPatterns "10m_blue" (600) 30 3840 2160 $bluecolor