Closed githottub closed 7 months ago
The setting Preferred audio container
translates to the command line option/argument -S "aext:<ext>"
, which tells yt-dlp which audio file extension to consider the best. That causes yt-dlp to download a format with the specified file extension, if such a one exists. It does not cause yt-dlp to put the audio stream into a specific container.
The program provides options like ogg
, flac
, and mp3
for non-YouTube sites that may offer those container formats. As far as I can tell, YouTube's opus audio format is always in a .webm container, so the most you can do, is use -x --audio-format opus
as a custom argument. That causes yt-dlp to mux the audio stream from the downloaded .webm file into an .opus file using ffmpeg, and then delete the .webm file.
Edit: of course, you should also select the opus format from the formats list, or better yet in the custom arguments
(-f 251 -x --audio-format opus
).
Thanks for the explanation. Yes, Youtube does download Opus audio in a .webm container. Therefore, I've been manually doing exactly what you described and using ffmpeg to extract the Opus audio and save it as a .opus file... which results in a slightly smaller file and makes it far more recognizeable to most audio players than a webm file.
The feature request was essentially my hope that ytdlip-interface could automate that process. Thereby, if Opus was set as the Preferred audio container and if only Opus audio (no video) was selected in the formats window then the app would d/l it from Youtube as webm then automatically have ffmpeg extract/save the opus audio. My thinking was that I know I'm not the only one saving the audio track from YT videos and since having it as a .opus file makes it both smaller and more widely playable than .webm, it would be a particularly helpful feature to all the people who have no idea how to use CLI commands to get such a file using ffmpeg manually.
As always, thanks for your consideration and continued improvement of this great app.
@ErrorFlynn I use this command to get .opus file -x
yt-dlp by default downloads the best audio available(which is opus in .webm container). -x extracts .opus file from .webm.
if you need .m4a instead of .opus, use this code -f bestaudio[ext=m4a] -x
.
--audio-format
is actually used to convert file to a specific format using ffmpeg. don't use it unless you want it in .mp3
-f ba
gives you the audio in raw .webm. I don't use it since I can't add album cover in .webm with yt-dlp
There are millions of youtube videos with Opus audio. When downloading just the audio (i.e. from a music video, concert, etc) it would be preferable to leave it as-is saved as an opus file. There is no requirement to put opus audio into a separate container such as Ogg. Practically every current Windows audio player will play audio files with an .opus extension and Google themselves added that ability to Android many years ago.