Last active
October 21, 2023 06:59
-
-
Save HunterAP23/0b5f5b0930ee74654f35a96e1c998960 to your computer and use it in GitHub Desktop.
Convert Media Sources to rawvideo AVI with transparency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableDelayedExpansion | |
for %%a in (*.webm *.mkv) do ( | |
FOR /F "usebackq" %%F IN (`ffprobe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%%a"`) DO ( | |
if "%%F"=="vp8" ( | |
ffmpeg -hide_banner -c:v libvpx -i "%%a" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 "%%~dpna_RAWVIDEO.avi" | |
) else ( | |
if "%%F"=="vp9" ( | |
ffmpeg -hide_banner -c:v libvpx-vp9 -i "%%a" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 "%%~dpna_RAWVIDEO.avi" | |
) else ( | |
ffmpeg -hide_banner -i "%%a" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 "%%~dpna_RAWVIDEO.avi" | |
) | |
) | |
) | |
) | |
for %%a in (*.mp4 *.mov) do ( | |
ffmpeg -hide_banner -i "%%a" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 "%%~dpna_RAWVIDEO.avi" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$loc = $args[0] | |
If ($args.length -eq 0) { | |
"Defaulting to current directory of `"$(Get-Location)`"" | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
} ElseIf ( $(Try { Test-Path $args[0].trim() } Catch { $false }) ) { | |
"Path `"$loc`" was found." | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
} Else { | |
"Path `"$loc`" was not found." | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
exit | |
} | |
@(Get-ChildItem -Path $loc -File -Filter *.webm).foreach({ | |
"Working on file `"$_`"" | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
$pat = Split-Path ($_).FullName | |
$codec = ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$_" | |
$new = "$pat\$(($_).BaseName)_RAWVIDEO.avi" | |
If ($codec -eq "vp8") { | |
ffmpeg -hide_banner -hwaccel auto -c:v libvpx -i "$(($_).FullName)" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 -y "$new" | |
} ElseIf ($codec -eq "vp9") { | |
ffmpeg -hide_banner -hwaccel auto -c:v libvpx-vp9 -i "$(($_).FullName)" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 -y "$new" | |
} Else { | |
ffmpeg -hide_banner -hwaccel auto -i "$(($_).FullName)" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 -y "$new" | |
} | |
"Finished file `"$_`"" | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
}) | |
@(Get-ChildItem -Path $loc -File -Filter *.mov).foreach({ | |
"Working on file `"$_`"" | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
$pat = Split-Path ($_).FullName | |
$new = "$pat\$(($_).BaseName)_RAWVIDEO.avi" | |
ffmpeg -hide_banner -hwaccel auto -i "$(($_).FullName)" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 -y "$new" | |
"Finished file `"$_`"" | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
}) | |
@(Get-ChildItem -Path $loc -File -Filter *.mp4).foreach({ | |
"Working on file `"$_`"" | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
$pat = Split-Path ($_).FullName | |
$new = "$pat\$(($_).BaseName)_RAWVIDEO.avi" | |
ffmpeg -hide_banner -hwaccel auto -i "$(($_).FullName)" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 -y "$new" | |
"Finished file `"$_`"" | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
}) | |
@(Get-ChildItem -Path $loc -File -Filter *.mkv).foreach({ | |
"Working on file `"$_`"" | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
$pat = Split-Path ($_).FullName | |
$codec = ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$_" | |
$new = "$pat\$(($_).BaseName)_RAWVIDEO.avi" | |
If ($codec -eq "vp8") { | |
ffmpeg -hide_banner -hwaccel auto -c:v libvpx -i "$(($_).FullName)" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 -y "$new" | |
} ElseIf ($codec -eq "vp9") { | |
ffmpeg -hide_banner -hwaccel auto -c:v libvpx-vp9 -i "$(($_).FullName)" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 -y "$new" | |
} Else { | |
ffmpeg -hide_banner -hwaccel auto -i "$(($_).FullName)" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 -y "$new" | |
} | |
"Finished file `"$_`"" | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
}) | |
@(Get-ChildItem -Path $loc -File -Filter *.avi).foreach({ | |
If ($_ -notmatch "_RAWVIDEO.avi") { | |
$codec = ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$_" | |
If ($codec -eq "rawvideo") { | |
"File `"$_`" is already in rawvideo AVI format - skipping..." | Out-File -append -noClobber -encoding UTF8 -filepath "$(Get-Location)\media_to_avi.log" | |
} Else { | |
"Working on file `"$_`"" | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
$pat = Split-Path ($_).FullName | |
$new = "$pat\$(($_).BaseName)_RAWVIDEO.avi" | |
ffmpeg -hide_banner -hwaccel auto -i "$(($_).FullName)" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 -y "$new" | |
"Finished file `"$_`"" | Tee-Object -Append -filepath "$(Get-Location)\media_to_avi.log" | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment