Skip to content

Instantly share code, notes, and snippets.

@DarthJahus
Created November 22, 2025 12:40
Show Gist options
  • Select an option

  • Save DarthJahus/bb69dc19b53b277b1276628ec957fcbc to your computer and use it in GitHub Desktop.

Select an option

Save DarthJahus/bb69dc19b53b277b1276628ec957fcbc to your computer and use it in GitHub Desktop.
param(
[Parameter(Mandatory = $true)]
[string]$Source,
[Parameter(Mandatory = $true)]
[string]$Destination,
[int]$Bitrate = 40,
[ValidateSet("speed", "balanced", "quality", "high_quality")]
[string]$Quality = "quality"
)
$Source = $Source.TrimEnd('\')
$Destination = $Destination.TrimEnd('\')
$BufSize = "$($Bitrate * 3)M"
if (-not (Test-Path $Destination)) {
New-Item -ItemType Directory -Path $Destination | Out-Null
}
$validExtensions = ".mp4", ".mov", ".mkv", ".avi", ".mpq"
$videos = Get-ChildItem -Path $Source -File | Where-Object {
$validExtensions -contains ($_.Extension -as [string]).Trim().ToLower()
}
if ($videos.Count -eq 0) {
Write-Host "Aucun fichier vidéo trouvé dans '$Source'"
exit
}
# ? -c:a aac -b:a 128k `
foreach ($file in $videos) {
$inputFile = $file.FullName
$baseName = $file.BaseName
$outputFile = Join-Path $Destination "$baseName.av1.mkv"
if (Test-Path $outputFile) {
Write-Host "Déjà converti : $outputFile"
continue
}
Write-Host "Encodage : $file.Name → $outputFile (vbr=$Bitrate Mbps, quality=$Quality)"
ffmpeg -hide_banner -y -i "$inputFile" `
-map 0 `
-map_metadata 0 -movflags use_metadata_tags `
-c:v av1_amf `
-usage transcoding `
-quality $Quality `
-rc vbr_peak `
-b:v ${Bitrate}M -maxrate ${Bitrate}M -bufsize $BufSize `
-pix_fmt yuv420p `
-c:a copy `
-c:s copy `
"$outputFile"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment