Answer the question
In order to leave comments, you need to log in
How to choose a different download method in YoutubeDL?
Good afternoon! If you upload a video of any DASH format via youtube_dl (in my case 298) immediately:
from youtube_dl import YoutubeDL
with YoutubeDL({'outtmpl': 'test.mp4', 'format': '298'}) as ydl:
ydl.download(["https://www.youtube.com/watch?v=LXb3EKWsInQ'])
, then all 90 MB will be loaded in a couple of seconds. with YoutubeDL({'outtmpl': 'test.mp4'}) as ydl:
info_dict = ydl.extract_info('https://www.youtube.com/watch?v=LXb3EKWsInQ', download=False)
url = [i for i in info_dict['formats'] if i['format_id'] == '298'][0]['url']
ydl.download([url])
, then the same 90 MB will be loaded in a few minutes. Answer the question
In order to leave comments, you need to log in
In youtube_dl solved it like this:
filename = 'test.mp4'
url = '...' # Прямая ссылка на нужный формат видео
youtube_dl.downloader.HttpFD(YoutubeDL({}), {}).download(filename, {'url': url, 'downloader_options': {'http_chunk_size': 10485760}})
It's better to download YouTube videos through the pytube library. It works a little faster than youtube_dl. Yes, and write only one line of code (not counting imports and inputs).
from pytube import YouTube
link = input()
YouTube(link).streams.first().download()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question