From 563a9b2ef74e2f50fe7def3fa9a9a92d7b7e51b9 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 13 Feb 2024 21:57:14 +0100 Subject: [PATCH] Use best quality --- examples/downloadRenameBot.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/downloadRenameBot.php b/examples/downloadRenameBot.php index 993e27347..3d0046932 100755 --- a/examples/downloadRenameBot.php +++ b/examples/downloadRenameBot.php @@ -138,15 +138,16 @@ class MyEventHandler extends SimpleEventHandler $process->join(); if (isset($info['title'])) { $name ??= $info['title'].".mp4"; - $url = Process::start([ - 'yt-dlp', - $url, - '-o', - '-', + $url = escapeshellarg($url); + $process = Process::start([ + 'bash', + '-c', + "yt-dlp $url -f bestvideo*+bestaudio/best -o - | ffmpeg -i - -f mp4 -acodec copy -vcodec copy -movflags isml+frag_keyframe pipe:1", ]); - async(pipe(...), $url->getStderr(), getStderr())->ignore(); - $finally = $url->join(...); - $url = $url->getStdout(); + async(pipe(...), $process->getStderr(), getStderr())->ignore(); + + $finally = $process->join(...); + $url = $process->getStdout(); } else { $name ??= $url; if (Uri::new($url)->getScheme() === null) {