-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathffmpeg.ps1
More file actions
32 lines (28 loc) · 1.42 KB
/
Copy pathffmpeg.ps1
File metadata and controls
32 lines (28 loc) · 1.42 KB
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
# create directory structure
New-Item -ItemType Directory -Path ".\sd" -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path ".\sd\movies" -ErrorAction SilentlyContinue
# convert each .mp4 here to 480x320 20fps series of jpegs
Get-ChildItem *.mp4 | ForEach-Object {
$movieName = ( $_.Name -replace ".mp4", "" )
$movieName = ( $movieName -replace " ", "" )
$movieOutputPath = '.\sd\movies\' + ( $movieName -replace ".mp4", "" )
$movieOutput = $movieOutputPath + '\%04d.jpg'
New-Item -ItemType Directory -Path $movieOutputPath -ErrorAction SilentlyContinue
ffmpeg.exe -i $_.Name -s 480x320 -filter:v "fps=20" $movieOutput
}
# create movies.json with largestJpeg, movie paths and number of frames
Write-Output "{" > .\movies.json
$maxFileSize = 0
Get-ChildItem ".\sd\movies" -Recurse -File | ForEach-Object {
$Size = $_.Length
$maxFileSize = (Get-Variable -name maxFileSize, Size | Sort Value | Select -Last 1).Value
}
Write-Output " ""maxFileSize"": $((Get-Variable -name maxFileSize).Value)," >> .\movies.json
Write-Output " ""movies"": [" >> .\movies.json
Get-ChildItem ".\sd\movies" -Recurse -Dir | ForEach-Object {
Write-Output "{ ""name"": ""$($_)"", ""frameCount"": $((dir .\sd\movies\$_ | measure).Count)}," >> .\movies.json
}
Write-Output "]" >> .\movies.json
Write-Output "}" >> .\movies.json
# copy to sd and convert to ascii
gc -en utf8 .\movies.json | Out-File -en ascii .\sd\movies\movies.json