destiny_child

Gold Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Но и она не определяет на лету - а ЧТО надо зацикливать? типа а какой поток по факту короче, чтобы его противоположника зацикливать пришлось бы... может что-то типа этого: Код: param( [Parameter(Mandatory=$true)] [string]$Url ) # --- Настройки --- $TempDir = Join-Path $env:TEMP "coub_tmp" $VideoFile = Join-Path $TempDir "video.mp4" $AudioFile = Join-Path $TempDir "audio.mp3" $OutputFile = "coub_final.mp4" # --- Создать временную папку --- if (-not (Test-Path $TempDir)) { New-Item -ItemType Directory -Path $TempDir | Out-Null } # --- 1. Скачать видео --- Write-Host "[1/5] Скачиваю видео..." yt-dlp -f "bv" -o "$VideoFile" $Url # --- 2. Скачать аудио --- Write-Host "[2/5] Скачиваю аудио..." yt-dlp -f "ba" -o "$AudioFile" $Url # --- 3. Функция определения длительности с идеально тихим выводом данных по длительности --- function Get-Duration($file) { $cmd = ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file" return [double]$cmd } Write-Host "[3/5] Измеряю длительности..." $VideoDuration = Get-Duration $VideoFile $AudioDuration = Get-Duration $AudioFile Write-Host " Видео: $VideoDuration сек." Write-Host " Аудио: $AudioDuration сек." # --- 4. Определяем, что нужно зациклить --- $LoopVideo = $false $LoopAudio = $false if ($VideoDuration -lt $AudioDuration) { $LoopVideo = $true Write-Host "Видео короче -> зацикливаем ВИДЕО" } elseif ($AudioDuration -lt $VideoDuration) { $LoopAudio = $true Write-Host "Аудио короче -> зацикливаем АУДИО" } else { Write-Host "Видео и аудио одинаковой длины → без зацикливания" } # --- 5. Сборка FFmpeg --- Write-Host "[4/5] Собираю финальный файл..." $LoopVideoArg = "" $LoopAudioArg = "" if ($LoopVideo) { $LoopVideoArg = "-stream_loop -1" } if ($LoopAudio) { $LoopAudioArg = "-stream_loop -1" } # порядок входов важен $FFmpegCmd = @( "ffmpeg", $LoopVideoArg, "-i", "`"$VideoFile`"", $LoopAudioArg, "-i", "`"$AudioFile`"", "-shortest", "-map 0:v:0", "-map 1:a:0", "-y", "`"$OutputFile`"" ) Write-Host "Команда FFmpeg:" Write-Host $FFmpegCmd -join " " # Запуск FFmpeg & $FFmpegCmd Write-Host "[5/5] Готово!" Write-Host "Финальный файл: $OutputFile" |
| Всего записей: 5093 | Зарегистр. 01-04-2006 | Отправлено: 10:37 06-12-2025 | Исправлено: destiny_child, 10:39 06-12-2025 |
|