PowerShell-Youtube-dl icon indicating copy to clipboard operation
PowerShell-Youtube-dl copied to clipboard

Default presets are not downloading best clip quality

Open aollivierre opened this issue 8 months ago • 0 comments

modify the existing script to download the best video quality, such as 1080p, using youtube-dl, you need to adjust the YoutubeDlOptionsList hash table to include options for best video quality. The best video quality option can be achieved by specifying the appropriate format code in youtube-dl.

Here's the modified section of the script to ensure it downloads the best video quality available:

A hash table of youtube-dl option presets for various formats and file types.

NOTE: Youtube-dl options can be found here: https://github.com/ytdl-org/youtube-dl/blob/master/README.md#readme

$YoutubeDlOptionsList = @{ DefaultVideo = "-o ""$DefaultVideoSaveLocation%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --console-title --ignore-errors --no-mtime --no-playlist -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio'" DefaultAudio = "-o ""$DefaultAudioSaveLocation%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --console-title --ignore-errors --no-mtime --no-playlist -x --audio-format mp3 --audio-quality 0 --metadata-from-title ""(?P.+?) - (?P.+)"" --add-metadata --prefer-ffmpeg" DefaultVideoPlaylist = "-o ""$VideoSaveLocation%(playlist)s%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --console-title --ignore-errors --no-mtime --yes-playlist -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio'" DefaultAudioPlaylist = "-o ""$VideoSaveLocation%(playlist)s%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --console-title --ignore-errors --no-mtime --yes-playlist -x --audio-format mp3 --audio-quality 0 --metadata-from-title ""(?P<artist rel="nofollow" target="_blank">.+?) - (?P<title>.+)"" --add-metadata --prefer-ffmpeg" DefaultVideoPlaylistFile = "-o ""$VideoSaveLocation%(playlist)s%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --download-archive ""$DefaultDownloadArchiveFileLocation"" --console-title --ignore-errors --no-mtime --yes-playlist -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio'" DefaultAudioPlaylistFile = "-o ""$VideoSaveLocation%(playlist)s%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --download-archive ""$DefaultDownloadArchiveFileLocation"" --console-title --ignore-errors --no-mtime --yes-playlist -x --audio-format mp3 --audio-quality 0 --metadata-from-title ""(?P<artist rel="nofollow" target="_blank">.+?) - (?P<title>.+)"" --add-metadata --prefer-ffmpeg" Mp3 = "-o ""$DefaultAudioSaveLocation%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --console-title --ignore-errors --no-mtime --no-playlist -x --audio-format mp3 --audio-quality 0 --prefer-ffmpeg" Mp4 = "-o ""$DefaultVideoSaveLocation%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --console-title --ignore-errors --no-mtime --no-playlist -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio'" Webm = "-o ""$DefaultVideoSaveLocation%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --console-title --ignore-errors --no-mtime --no-playlist -f 'bestvideo[ext=webm]+bestaudio[ext=webm]/bestvideo+bestaudio'" WebmNoAudio = "-o ""$DefaultVideoSaveLocation%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --console-title --ignore-errors --no-mtime --no-playlist --recode-video webm --postprocessor-args ""-an"" -f 'bestvideo[ext=webm]+bestaudio[ext=webm]/bestvideo+bestaudio'" WebmForums = "-o ""$DefaultVideoSaveLocation%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --console-title --ignore-errors --no-mtime --no-playlist --recode-video webm --postprocessor-args ""-b:v 800k -b:a 128k -s 640x360"" -f 'bestvideo[ext=webm]+bestaudio[ext=webm]/bestvideo+bestaudio'" WebmForumsNoAudio = "-o ""$DefaultVideoSaveLocation%(title)s.%(ext)s"" --cache-dir ""$DefaultScriptInstallLocation\var\cache"" --console-title --ignore-errors --no-mtime --no-playlist --recode-video webm --postprocessor-args ""-b:v 800k -b:a 128k -s 640x360 -an"" -f 'bestvideo[ext=webm]+bestaudio[ext=webm]/bestvideo+bestaudio'" }

In the DefaultVideo, DefaultVideoPlaylist, DefaultVideoPlaylistFile, and Mp4 presets, I added -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' to download the best video quality in MP4 format. This format code ensures that the best video and audio streams are downloaded and combined.

With these changes, the script will now download the highest quality video available by default when using the DefaultVideo option. You can adjust other presets similarly if needed.

aollivierre avatar Jun 20 '24 12:06 aollivierre