Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it normal that b[height<=480] gives me a better quality video than b[filesize<25M] ? #7341

Closed
6 of 9 tasks
Nicolas-Gth opened this issue Jun 18, 2023 · 12 comments
Closed
6 of 9 tasks
Labels
question Question

Comments

@Nicolas-Gth
Copy link

Nicolas-Gth commented Jun 18, 2023

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Please make sure the question is worded well enough to be understood

I'm downloading this video : https://www.youtube.com/watch?v=SjgMmo6_DH0

The b[filesize<25M] setting give me a 2Mb mp4 with really low quality audio and the video is only the first frame. It's also quite slow when downloading.

But b[height<=480] gives me a decent 480p 8Mb mp4 file with good audio

Edit : b[height<=720] gives me a 21.73MiB file so I don't understand why b[filesize<25M] does not give me a similar result

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

No response

@Nicolas-Gth Nicolas-Gth added the question Question label Jun 18, 2023
@bashonly
Copy link
Member

you are getting format 18 with b[height<=480], which only has an approximate (~) filesize available (filesize_approx) and is excluded if you filter by filesize

[info] Available formats for SjgMmo6_DH0:
ID  EXT   RESOLUTION FPS CH │   FILESIZE   TBR PROTO │ VCODEC          VBR ACODEC      ABR ASR MORE INFO
────────────────────────────────────────────────────────────────────────────────────────────────────────────────
sb2 mhtml 48x27        0    │                  mhtml │ images                                  storyboard
sb1 mhtml 80x45        1    │                  mhtml │ images                                  storyboard
sb0 mhtml 160x90       1    │                  mhtml │ images                                  storyboard
139 m4a   audio only      2 │    1.35MiB   49k https │ audio only          mp4a.40.5   49k 22k low, m4a_dash
249 webm  audio only      2 │    1.31MiB   47k https │ audio only          opus        47k 48k low, webm_dash
250 webm  audio only      2 │    1.73MiB   63k https │ audio only          opus        63k 48k low, webm_dash
140 m4a   audio only      2 │    3.58MiB  129k https │ audio only          mp4a.40.2  129k 44k medium, m4a_dash
251 webm  audio only      2 │    3.41MiB  123k https │ audio only          opus       123k 48k medium, webm_dash
17  3gp   176x144     12  1 │    2.05MiB   74k https │ mp4v.20.3       74k mp4a.40.2       22k 144p
394 mp4   256x144     24    │    1.85MiB   67k https │ av01.0.00M.08   67k video only          144p, mp4_dash
160 mp4   256x144     24    │    1.42MiB   51k https │ avc1.4d400c     51k video only          144p, mp4_dash
278 webm  256x144     24    │    2.28MiB   83k https │ vp9             83k video only          144p, webm_dash
395 mp4   426x240     24    │    2.96MiB  107k https │ av01.0.00M.08  107k video only          240p, mp4_dash
133 mp4   426x240     24    │    2.95MiB  107k https │ avc1.4d4015    107k video only          240p, mp4_dash
242 webm  426x240     24    │    3.46MiB  125k https │ vp9            125k video only          240p, webm_dash
396 mp4   640x360     24    │    5.37MiB  194k https │ av01.0.01M.08  194k video only          360p, mp4_dash
134 mp4   640x360     24    │    5.36MiB  194k https │ avc1.4d401e    194k video only          360p, mp4_dash
18  mp4   640x360     24  2 │ ~  9.14MiB  323k https │ avc1.42001E    323k mp4a.40.2       44k 360p
243 webm  640x360     24    │    6.82MiB  247k https │ vp9            247k video only          360p, webm_dash
397 mp4   854x480     24    │    8.93MiB  323k https │ av01.0.04M.08  323k video only          480p, mp4_dash
135 mp4   854x480     24    │   10.15MiB  367k https │ avc1.4d401e    367k video only          480p, mp4_dash
244 webm  854x480     24    │   11.23MiB  406k https │ vp9            406k video only          480p, webm_dash
22  mp4   1280x720    24  2 │ ~ 22.26MiB  786k https │ avc1.64001F    786k mp4a.40.2       44k 720p
398 mp4   1280x720    24    │   16.58MiB  600k https │ av01.0.05M.08  600k video only          720p, mp4_dash
136 mp4   1280x720    24    │   18.16MiB  657k https │ avc1.4d401f    657k video only          720p, mp4_dash
247 webm  1280x720    24    │   20.32MiB  735k https │ vp9            735k video only          720p, webm_dash
399 mp4   1920x1080   24    │   27.94MiB 1010k https │ av01.0.08M.08 1010k video only          1080p, mp4_dash
137 mp4   1920x1080   24    │   41.19MiB 1490k https │ avc1.640028   1490k video only          1080p, mp4_dash
248 webm  1920x1080   24    │   34.27MiB 1239k https │ vp9           1239k video only          1080p, webm_dash
400 mp4   2560x1440   24    │   81.98MiB 2965k https │ av01.0.12M.08 2965k video only          1440p, mp4_dash
271 webm  2560x1440   24    │   82.14MiB 2971k https │ vp9           2971k video only          1440p, webm_dash
401 mp4   3840x2160   24    │  174.88MiB 6325k https │ av01.0.12M.08 6325k video only          2160p, mp4_dash
313 webm  3840x2160   24    │  270.87MiB 9797k https │ vp9           9797k video only          2160p, webm_dash

@Nicolas-Gth
Copy link
Author

Nicolas-Gth commented Jun 18, 2023

So what should I use instead ? Something like b[filesize~24M] ?

@bashonly
Copy link
Member

filesize_approx is what would filter the formats with only approximate filesizes

the easiest solution would be to use format sorting instead of format selection filtering, like -f b -S size:24M , since it sorts by both filesize and approximate filesize

@Nicolas-Gth
Copy link
Author

Thank you !

@gamer191
Copy link
Collaborator

the easiest solution would be to use format sorting instead of format selection filtering, like -f b -S size:24M

I would just do -S size:24M. -f b shouldn't be used unless you know what it does (hint: it doesn't download the best quality)

@Nicolas-Gth
Copy link
Author

Nicolas-Gth commented Jun 18, 2023

ydl_opts = {
		'format': 'b[ext=mp4]',
		'format_sort' : 'size:25M',
		'outtmpl': f'{folderPath}{mp4_title}.mp4',
		'ffmpeg_location': './ffmpeg-N-103380-ge41bd075dd-win64-gpl/bin/ffmpeg.exe',
		'noplaylist': True,
		'progress_hooks': [self.my_hook],
		'cachedir': False,
		'cookiefile' : cookiePath
		}

ERROR: Invalid format sort string ":" given by extractor

how should I write it ?

@bashonly
Copy link
Member

'format_sort': ['size:25M']

use this to convert CLI to API https://github.com/yt-dlp/yt-dlp/blob/master/devscripts/cli_to_api.py

@Nicolas-Gth
Copy link
Author

the easiest solution would be to use format sorting instead of format selection filtering, like -f b -S size:24M

I would just do -S size:24M. -f b shouldn't be used unless you know what it does (hint: it doesn't download the best quality)

Can you explain please ?

@gamer191
Copy link
Collaborator

gamer191 commented Jun 18, 2023

-f b is used to limit yt-dlp to combined video+audio formats. It's not recommended, since the non-combined formats are usually much higher quality, and, assuming you have ffmpeg installed, yt-dlp will automatically merge the best quality video and audio formats matching your options

@bashonly
Copy link
Member

bashonly commented Jun 18, 2023

and if you want to heed gamer191's advice, additionally I would suggest not using a format param at all in your opts.
instead you could only use format sorting, like this:
{'format_sort': ['ext', 'size:25M']}
it will sort formats by extension (mp4 having priority) and then by size (formats with a size of 25M or less having priority)

@Nicolas-Gth
Copy link
Author

Nicolas-Gth commented Jun 18, 2023

Ok thanks, the only problem is that it seems that the 'size:25M' only looks at the files separately so once the mp4 and m4a are combined the file is more than 25Mb

@gamer191
Copy link
Collaborator

@ThurstyWonk the audio is usually pretty small (3.41MiB in your example video), but yes, that is a known limitation (see #4846). If that's a problem, you'll need to add back -f b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question
Projects
None yet
Development

No branches or pull requests

3 participants