Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
youtube-dl --extract-audio --audio-format opus --audio-quality 8
and when looking at VLC codec info (Ctrl-J) and media statistics (other tab (from same window)) it show it's an Opus 32 bit 48 KHz and I estimate from the content bitrate fluctuation that its average is 150 Kbps (Is there a better way to get its average?) but I'd like something with a smaller file size. When I stream AAC 32 Kbps (radio), I like the (sound) quality; perhaps Opus would be a similar quality at that bitrate, or even better? I tried
Quote:
youtube-dl -f 'bestaudio' --audio-format opus --audio-quality 8
and the result is (sounds) horrible.
I've noticed multiple videos have audio starting from around what I think is 50 Kbps since it's mentioned
Quote:
opus @ 50k
in the resolution note column but if the quality is as good, or better, than AAC, I don't need something that good; as mentioned above AAC 32 Kbps is fine by me.
How can I get a decent small size audio from Youtube?
It sounds confusing.
You want less than 32kbps audio, and NOT opus? Am I understanding this correctly?
Basically youtube-dl works in this way:
it looks for all audio/video formats
it chooses the best available (possibly with restrictions added on the command line, but be careful, more than 1 restriction quickly leads to no suitable format available!)
it downloads the file(s)
possibly it muxes the chosen audio & video track together
To my knowledge it does NOT transcode anything by default, but there's a switch '--recode-video' you might want to look at (there's no --recode-audio, strangely. You might need to do that manually after downloading).
You really need to read youtube-dl's extensive man page.
For any of this to work with youtube-dl, a recent ffmpeg is a soft dependency.
When I stream AAC 32 Kbps (radio), I like the (sound) quality [...] as mentioned above AAC 32 Kbps is fine by me.
(underlining just added) and if
Quote:
Originally Posted by DynV
[...] Opus would be a similar quality at that bitrate, or even better[...]
is the case, then
Quote:
Originally Posted by DynV
I've noticed multiple videos have audio starting from around what I think is [Opus] 50 Kbps [...]
would be at a quality considerably more than I need, and I'd prefer for it to end up at the sufficient quality is it mean it save a non-negligible amount of storage space.
It doesn't seem there's a man page for the program on my system but
Quote:
--help
has a long output, which I tried my best to understand. I forgot to mention in the OP that I attempted multiple #s for the 2nd command and, while the file size do change (depending on the #), they all sounded considerably less (good) than what's sufficient for me (AAC 32 Kbps).
If Opus is indeed better than AAC, I'd like for this process to occur:
if there's an Opus between 24 & 32 Kbps, for it to be downloaded
if there's an AAC between 32 & 48 Kbps, for it to be downloaded
otherwise the best audio be downloaded then converted to the Opus equivalent of AAC 32 Kbps
youtube-dl -F https://www.youtube.com/watch?v=hXZ2AfBkPD4
[youtube] hXZ2AfBkPD4: Downloading webpage
[youtube] hXZ2AfBkPD4: Downloading video info webpage
[youtube] hXZ2AfBkPD4: Downloading MPD manifest
[info] Available formats for hXZ2AfBkPD4:
format code extension resolution note
139 m4a audio only DASH audio 50k , m4a_dash container, mp4a.40.5@ 48k (22050Hz)
140 m4a audio only DASH audio 130k , m4a_dash container, mp4a.40.2@128k (44100Hz)
251 webm audio only DASH audio 136k , webm_dash container, opus @160k (48000Hz)
278 webm 256x144 DASH video 95k , webm_dash container, vp9, 30fps, video only
160 mp4 256x144 DASH video 108k , mp4_dash container, avc1.4d400b, 30fps, video only
242 webm 426x240 DASH video 220k , webm_dash container, vp9, 30fps, video only
133 mp4 426x240 DASH video 242k , mp4_dash container, avc1.4d400c, 30fps, video only
243 webm 640x360 DASH video 405k , webm_dash container, vp9, 30fps, video only
134 mp4 640x360 DASH video 508k , mp4_dash container, avc1.4d401e, 30fps, video only
244 webm 854x480 DASH video 752k , webm_dash container, vp9, 30fps, video only
135 mp4 854x480 DASH video 1155k , mp4_dash container, avc1.4d4014, 30fps, video only
247 webm 1280x720 DASH video 1505k , webm_dash container, vp9, 30fps, video only
136 mp4 1280x720 DASH video 1629k , mp4_dash container, avc1.4d401f, 30fps, video only
18 mp4 640x360 360p 374k , avc1.42001E, mp4a.40.2@ 96k (44100Hz), 17.68MiB
22 mp4 1280x720 720p 782k , avc1.64001F, mp4a.40.2@192k (44100Hz) (best)
Format 139, 50k, m4a is the smallest available for that video.
If you want it smaller, lower bitrate, then run it through ffmpeg
Quote:
If Opus is indeed better than AAC, I'd like for this process to occur:
1. if there's an Opus between 24 & 32 Kbps, for it to be downloaded
2. if there's an AAC between 32 & 48 Kbps, for it to be downloaded
3. otherwise the best audio be downloaded then converted to the Opus equivalent of AAC 32 Kbps
Make yourself a bash script to do what you are wanting with ffmpeg then.
youtube-dl is python and it uses ffmpeg as it's backend to reencode.
I plan to download playlists so doing it manually, using -F would take a long time. I was hoping for some assistance with automated -f as in the OP 2nd quote. Since youtube-dl has ffmpeg integrated, perhaps there's a way to go through it? I was hoping --audio-format opus --audio-quality 8 would do so.
Also if a bash script would be necessary, perhaps I can get assistance with that? I understand if you don't want to.
This sounds too convoluted to ask youtube-dl to find the suitable format - consider that not all formats are always available for every download.
I think your best bet is to let youtube-dl do its thing (download best quality available), then convert into whatever it is you want in a second step.
Is there a way the selection can be done automatically as in post #3 list (at its bottom) ?
obviously there is a way to do that:
1. get the list as it was explained
2. select the one you prefer (if you know how to do that and what to do if missing...)
3. run youtube-dl and specify the format you need.
Please note in the following there's a 2nd attempt, which I increased the maximum limit to capture the 50 Kbps Opus
Quote:
me@me-computer:~/Downloads$ youtube-dl -f 'bestaudio[ext=opus][abr>=24][abr<=50]/bestaudio[ext=aac][abr>=32][abr<=48]/bestaudio' https://www.youtube.com/watch?v=oPB4gk-SSEs
[youtube] oPB4gk-SSEs: Downloading webpage
[youtube] oPB4gk-SSEs: Downloading video info webpage
[download] Destination: Lemmy ,Slash & Dave Grohl - Ace Of Spades-oPB4gk-SSEs.webm
[download] 100% of 2.90MiB in 00:00
me@me-computer:~/Downloads$ mediainfo --Inform="General;%BitRate/String%" Lemmy\ \,Slash\ \&\ Dave\ Grohl\ -\ Ace\ Of\ Spades-oPB4gk-SSEs.webm
123 kb/s
me@me-computer:~/Downloads$ youtube-dl -F https://www.youtube.com/watch?v=oPB4gk-SSEs | grep -P '^\d+\s{2,}\w+\s{2,}audio only\s.*$'
249 webm audio only tiny 52k , opus @ 50k (48000Hz), 1.09MiB
250 webm audio only tiny 67k , opus @ 70k (48000Hz), 1.46MiB
140 m4a audio only tiny 128k , m4a_dash container, mp4a.40.2@128k (44100Hz), 2.99MiB
251 webm audio only tiny 130k , opus @160k (48000Hz), 2.90MiB
me@me-computer:~/Downloads$ rm Lemmy\ \,Slash\ \&\ Dave\ Grohl\ -\ Ace\ Of\ Spades-oPB4gk-SSEs.webm
me@me-computer:~/Downloads$ youtube-dl -f 'bestaudio[ext=opus][abr>=24][abr<60]/bestaudio[ext=aac][abr>=32][abr<=48]/bestaudio' https://www.youtube.com/watch?v=oPB4gk-SSEs
[youtube] oPB4gk-SSEs: Downloading webpage
[youtube] oPB4gk-SSEs: Downloading video info webpage
[download] Destination: Lemmy ,Slash & Dave Grohl - Ace Of Spades-oPB4gk-SSEs.webm
[download] 100% of 2.90MiB in 00:01
me@me-computer:~/Downloads$ mediainfo --Inform="General;%BitRate/String%" Lemmy\ \,Slash\ \&\ Dave\ Grohl\ -\ Ace\ Of\ Spades-oPB4gk-SSEs.webm
123 kb/s
I thought mediainfo might not work properly so I opened the file in VLC and in the window Current Media Information tab Statistics tree Input/Read entry Input bitrate, it fluctuated at a bit over 120 Kbps.
Quote:
Originally Posted by pan64
you can also specify the file size and the tool will choose depending on that....
That would also depend on the duration, and since I plan on downloading playlists, with the vast majority of the time which included videos have varying non-negligable durations, and often with a decent variation (ie: longest >= 150% shortest). The playlist can also contain videos with different audio only, which I assume would affect the file size.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.