Does youtube API provide the original audio you are listening from youtube as a download option? Is it perhaps the --extract-audio option?
More Flexibility (using shell aliases)
As mentioned, the defaults are set to download the highest quality from the provided video URL. This isn't the same as saying that it always will be so, and it certainly hasn't always been so.
I'm a fan of stability, and have better experience with specifying the options directly, as defaults have a tendency to change with versions / updates, but using the specific options would still be valid, or you'd get a warning or error.
Using the direct options I know what I end up with.
It's also more flexible.
You can choose what preferred formats to prioritize, and get the best compatible video + audio merged automatically if the requested format/quality is unavailable and you can specify a format string for naming the downloaded file, and decide where it will end up (by default it's the current working directory).
You can use a separate settings file, on the Mac its by default:
~/.config/youtube-dl/config
Or, you can use an alias defined in your shell
(I've named the alias :ytdl
) so I just do:
:ytdl link_to_single_video
And have it set to automatically download the preferred video/audio format and merge them together at a location specified in the alias command in my shell startup file, using the naming convention I've decided it to use.
I also have a :ytdlpl playlist_id
alias that downloads complete playlists to a specified folder:
/playlists/[name_from_playlist_title]/[episode_num_and_name_from_playlist].[ext]
I've done this by setting up the two aliases:
# Download best mp4 format available or other format if no mp4 is available
alias :ytdl='/usr/local/bin/youtube-dl -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" -o "/Volumes/SSD/Video/YTDL/%(title)s.%(ext).s"'
# Download YouTube playlist videos in separate directory indexed by video order in a playlist
alias :ytdlpl='/usr/local/bin/youtube-dl -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" -o "/Volumes/SSD/Video/YTDL/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s"'
How you choose to do this is personal preference, but this works perfectly for my needs at least! 👍
By default youtube-dl tries to download the best available quality, i.e. if you want the best quality you don't need to pass any special options, youtube-dl will guess it for you by default.
Since the end of April 2015 and version 2015.04.26, youtube-dl uses -f bestvideo+bestaudio/best as the default format selection (see #5447(https://github.com/ytdl-org/youtube-dl/issues/5447), #5456(https://github.com/ytdl-org/youtube-dl/issues/5456)).
If you want to preserve the old format selection behavior (prior to youtube-dl 2015.04.26), i.e. you want to download the best available quality media served as a single file, you should explicitly specify your choice with -f best. You may want to add it to the configuration file in order not to type it every time you run youtube-dl.
Reference: https://github.com/ytdl-org/youtube-dl/blob/master/README.md#readme
Let me know if this helps. if not, we could figure it out in specifics.
UPDATE
Here are a few commands that could come handy;
# Download best mp4 format available or any other best if no mp4 available
$ youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'
# Download best format available but no better than 480p
$ youtube-dl -f 'bestvideo[height<=480]+bestaudio/best[height<=480]'
# Download best video only format but no bigger than 50 MB
$ youtube-dl -f 'best[filesize<50M]'
# Download best format available via direct link over HTTP/HTTPS protocol
$ youtube-dl -f '(bestvideo+bestaudio/best)[protocol^=http]'
# Download the best video format and the best audio format without merging them
$ youtube-dl -f 'bestvideo,bestaudio' -o '%(title)s.f%(format_id)s.%(ext)s'
More Flexibility (using shell aliases)
As mentioned, the defaults are set to download the highest quality from the provided video URL. This isn't the same as saying that it always will be so, and it certainly hasn't always been so.
I'm a fan of stability, and have better experience with specifying the options directly, as defaults have a tendency to change with versions / updates, but using the specific options would still be valid, or you'd get a warning or error.
Using the direct options I know what I end up with.
It's also more flexible.
You can choose what preferred formats to prioritize, and get the best compatible video + audio merged automatically if the requested format/quality is unavailable and you can specify a format string for naming the downloaded file, and decide where it will end up (by default it's the current working directory).
You can use a separate settings file, on the Mac its by default:
~/.config/youtube-dl/config
Or, you can use an alias defined in your shell
(I've named the alias :ytdl
) so I just do:
:ytdl link_to_single_video
And have it set to automatically download the preferred video/audio format and merge them together at a location specified in the alias command in my shell startup file, using the naming convention I've decided it to use.
I also have a :ytdlpl playlist_id
alias that downloads complete playlists to a specified folder:
/playlists/[name_from_playlist_title]/[episode_num_and_name_from_playlist].[ext]
I've done this by setting up the two aliases:
# Download best mp4 format available or other format if no mp4 is available
alias :ytdl='/usr/local/bin/youtube-dl -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" -o "/Volumes/SSD/Video/YTDL/%(title)s.%(ext).s"'
# Download YouTube playlist videos in separate directory indexed by video order in a playlist
alias :ytdlpl='/usr/local/bin/youtube-dl -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" -o "/Volumes/SSD/Video/YTDL/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s"'
How you choose to do this is personal preference, but this works perfectly for my needs at least! 👍
© 2022 - 2024 — McMap. All rights reserved.