[CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$Path, [ValidateRange(1, 100000)] [int]$Minutes = 30, [switch]$Recurse, [string[]]$Extensions = @('mp4', 'mkv', 'webm', 'mov', 'avi', 'm4v', 'ts'), [string]$Csv ) $ErrorActionPreference = 'Stop' foreach ($tool in @('ffmpeg', 'ffprobe')) { if (-not (Get-Command $tool -ErrorAction SilentlyContinue)) { throw "$tool не найден в PATH. Установите FFmpeg." } } if (-not (Test-Path -LiteralPath $Path -PathType Container)) { throw "Папка не найдена: $Path" } $root = (Resolve-Path -LiteralPath $Path).Path $wanted = $Extensions | ForEach-Object { $_.TrimStart('.').ToLowerInvariant() } $files = @( Get-ChildItem -LiteralPath $root -File -Recurse:$Recurse | Where-Object { $wanted -contains $_.Extension.TrimStart('.').ToLowerInvariant() } ) if ($files.Count -eq 0) { Write-Host 'Видеофайлы не найдены.' return } $limit = $Minutes * 60 $results = foreach ($file in $files) { $raw = & ffprobe -v error -show_entries format=duration -of default=nw=1:nk=1 $file.FullName 2>$null if ($LASTEXITCODE -ne 0) { continue } $value = @($raw | Select-Object -First 1)[0] if (-not ($value -match '^[0-9]+([.][0-9]+)?$')) { continue } $seconds = [double]$value if ($seconds -le $limit) { continue } [pscustomobject]@{ File = $file.FullName Minutes = [math]::Round($seconds / 60, 1) SizeMB = [math]::Round($file.Length / 1MB, 2) Modified = $file.LastWriteTime.ToString('yyyy-MM-dd HH:mm') } } if (-not $results) { Write-Host "Видео длиннее $Minutes минут не найдено." return } $results | Sort-Object -Property Minutes -Descending | Format-Table -AutoSize if ($Csv) { $results | Sort-Object -Property Minutes -Descending | Export-Csv -LiteralPath $Csv -NoTypeInformation -Encoding UTF8 Write-Host "Отчёт сохранён: $Csv" }