Youtube dl error requested format not available

This code: from __future__ import unicode_literals import youtube_dl class MyLogger(object): def debug(self, msg): print(msg) def warning(self, msg): print(msg) def error(self, msg): print(msg) def...

This code:

from __future__ import unicode_literals
import youtube_dl


class MyLogger(object):
    def debug(self, msg):
        print(msg)

    def warning(self, msg):
        print(msg)

    def error(self, msg):
        print(msg)


def my_hook(d):
    if d['status'] == 'finished':
        print('Done downloading, now converting ...')


ydl_options = {
    'continuedl': True,
    'format': '137/248',
    'cache-dir':'/var/www/.cache/youtube-dl',
    'verbose':True
    }

with youtube_dl.YoutubeDL(ydl_options) as ydl:
    ydl.download(['https://www.youtube.com/watch?v=7uq7DiKg9IQ'])

fails in python with error:

python basic_python_youtubedl.py 
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.03.14
[debug] Git HEAD: 10cd2003b
[debug] Python version 2.7.16 (CPython) - Linux-4.19.0-6-amd64-x86_64-with-debian-10.2
[debug] exe versions: ffmpeg 4.2.1, ffprobe 4.2.1
[debug] Proxy map: {}
[youtube] 7uq7DiKg9IQ: Downloading webpage
ERROR: requested format not available
Traceback (most recent call last):
  File "/var/www/v3/youtube-dl/youtube_dl/YoutubeDL.py", line 806, in wrapper
    return func(self, *args, **kwargs)
  File "/var/www/v3/youtube-dl/youtube_dl/YoutubeDL.py", line 838, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/var/www/v3/youtube-dl/youtube_dl/YoutubeDL.py", line 872, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/var/www/v3/youtube-dl/youtube_dl/YoutubeDL.py", line 1675, in process_video_result
    expected=True)
ExtractorError: requested format not available

Traceback (most recent call last):
  File "basic_python_youtubedl.py", line 29, in <module>
    ydl.download(['https://www.youtube.com/watch?v=7uq7DiKg9IQ'])
  File "/var/www/v3/youtube-dl/youtube_dl/YoutubeDL.py", line 2060, in download
    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
  File "/var/www/v3/youtube-dl/youtube_dl/YoutubeDL.py", line 799, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "/var/www/v3/youtube-dl/youtube_dl/YoutubeDL.py", line 815, in wrapper
    self.report_error(compat_str(e), e.format_traceback())
  File "/var/www/v3/youtube-dl/youtube_dl/YoutubeDL.py", line 628, in report_error
    self.trouble(error_message, tb)
  File "/var/www/v3/youtube-dl/youtube_dl/YoutubeDL.py", line 598, in trouble
    raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: requested format not available

Same formats downloads fine with binary and the formats are also shown as available when checking with binary:


youtube-dl -v -F 7uq7DiKg9IQ
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'-F', u'7uq7DiKg9IQ']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.03.14
[debug] Python version 2.7.16 (CPython) - Linux-4.19.0-6-amd64-x86_64-with-debian-10.2
[debug] exe versions: ffmpeg 4.2.1, ffprobe 4.2.1
[debug] Proxy map: {}
[youtube] 7uq7DiKg9IQ: Downloading webpage
[youtube] 7uq7DiKg9IQ: Downloading MPD manifest
[info] Available formats for 7uq7DiKg9IQ:
format code  extension  resolution note
139          m4a        audio only DASH audio   54k , m4a_dash container, mp4a.40.5 (22050Hz), 31.75MiB
251          webm       audio only tiny   95k , webm_dash container, opus @ 95k (48000Hz), 61.87MiB
140          m4a        audio only tiny  129k , m4a_dash container, mp4a.40.2@129k (44100Hz), 84.26MiB
278          webm       256x144    DASH video   95k , webm_dash container, vp9, 24fps, video only
160          mp4        256x144    DASH video  108k , mp4_dash container, avc1.4d400b, 24fps, video only
242          webm       426x240    DASH video  220k , webm_dash container, vp9, 24fps, video only
133          mp4        426x240    DASH video  242k , mp4_dash container, avc1.4d400c, 24fps, video only
134          mp4        640x360    360p  355k , mp4_dash container, avc1.4d401e@ 355k, 24fps, video only, 231.40MiB
243          webm       640x360    DASH video  405k , webm_dash container, vp9, 24fps, video only
244          webm       854x480    DASH video  752k , webm_dash container, vp9, 24fps, video only
135          mp4        854x480    DASH video 1155k , mp4_dash container, avc1.4d4014, 24fps, video only
247          webm       1280x720   DASH video 1505k , webm_dash container, vp9, 24fps, video only
136          mp4        1280x720   DASH video 2310k , mp4_dash container, avc1.4d4016, 24fps, video only
248          webm       1920x1080  DASH video 2646k , webm_dash container, vp9, 24fps, video only
137          mp4        1920x1080  DASH video 4331k , mp4_dash container, avc1.64001e, 24fps, video only
18           mp4        640x360    360p  383k , avc1.42001E, 24fps, mp4a.40.2 (44100Hz), 249.85MiB
22           mp4        1280x720   720p 1699k , avc1.64001F, 24fps, mp4a.40.2 (44100Hz) (best)

#python-3.x #youtube-dl

Вопрос:

Код:

 import tempfile
import youtube_dl

link = "https://www.reddit.com/r/CatastrophicFailure/comments/mhqgso/industrial_fire_in_volendam_netherlands_3132021/?utm_source=shareamp;utm_medium=web2xamp;context=3"

with tempfile.TemporaryDirectory() as tempdir:
    settings = {
        'verbose': True,
        'noplaylist': True,
        'format': 'best',
        'outtmpl': f'{tempdir}/%(id)s.%(ext)s'
    }
    with youtube_dl.YoutubeDL(settings) as ytdl:
        meta = ytdl.extract_info(
            link,
            download=True
        )
 

Ошибка:

 [debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] youtube-dl version 2021.03.31
[debug] Python version 3.8.5 (CPython) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg git-2020-08-31-4a11a6f, ffprobe git-2020-08-31-4a11a6f
[debug] Proxy map: {}
[RedditR] mhqgso: Downloading JSON metadata
[Reddit] hlrzahmcqiq61: Downloading m3u8 information
[Reddit] hlrzahmcqiq61: Downloading MPD manifest
ERROR: requested format not available
Traceback (most recent call last):
  File "C:UsersUserAppDataLocalProgramsPythonPython38libsite-packagesyoutube_dlYoutubeDL.py", line 806, in wrapper
    return func(self, *args, **kwargs)
  File "C:UsersUserAppDataLocalProgramsPythonPython38libsite-packagesyoutube_dlYoutubeDL.py", line 838, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "C:UsersUserAppDataLocalProgramsPythonPython38libsite-packagesyoutube_dlYoutubeDL.py", line 909, in process_ie_result
    return self.process_ie_result(
  File "C:UsersUserAppDataLocalProgramsPythonPython38libsite-packagesyoutube_dlYoutubeDL.py", line 872, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "C:UsersUserAppDataLocalProgramsPythonPython38libsite-packagesyoutube_dlYoutubeDL.py", line 1674, in process_video_result
    raise ExtractorError('requested format not available',
youtube_dl.utils.ExtractorError: requested format not available
 

Почему я получаю эту ошибку? Я знаю, что формат 'best' должен работать, глядя на документы, и я не знаю, не упускаю ли я здесь что-то глупое.

Ответ №1:

Насколько я понимаю, причина ошибки связана со ссылкой (URL), а не с форматом видео. URL-адрес указывает не на видео, а на страницу reddit, на которой отображается видео вместе с другими материалами.

Я не уверен, как использовать youtube-dl с видео reddit или если это вообще возможно. Тем не менее, быстрый просмотр информации о странице > Медиа> в моем Waterfox (браузере на базе Firefox) показал прямой URL-адрес видео как https://v.redd.it/hlrzahmcqiq61/DASH_96.mp4 которые можно сохранить с помощью кнопки «Сохранить как».

So I was trying to download a video from Bilibili using annie. I oroginally chose youtube-dl but unfortunately it doesn’t seem to support Bilibili website, so I chose annie instead, following the advice from a reddit user
But despite it seems I have no luck using Annie either. I wonder if this is because Bilibili has updated their mechanism or if I made a mistake somewhere.
This is the code.

apple@apples-MacBook-Pro ~ % annie "https://www.bilibili.com/s/video/BV1TD4y1R7k2"
Downloading https://www.bilibili.com/s/video/BV1TD4y1R7k2 error:
this page has no playlist
apple@apples-MacBook-Pro ~ % 

Also, youtube-dl claims it supports Bilibili and I definitely remember downlowding video from Bilibili using youtube-dl not so long ago. So what happened. Did Bilibili update their code or something?

apple@apples-MacBook-Pro ~ % youtube-dl "https://www.bilibili.com/video/av90163846?p=1"
[BiliBili] 90163846: Downloading webpage
[BiliBili] 90163846: Downloading video info page
WARNING: Unable to download JSON metadata: HTTP Error 412: Precondition Failed
[BiliBili] 90163846: Downloading video info page
ERROR: Unable to download JSON metadata: HTTP Error 412: Precondition Failed (caused by 
HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using 
the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the -- 
verbose flag and include its complete output.
apple@apples-MacBook-Pro ~ % 

edit:
Here is the debug log if it is of any help.

 apple@192 ~ % youtube-dl -v "https://bilibili.com/video/BV1TD4y1R7k2"         
[debug] System config: [u'--format', u'mp4', u'-o', u'~/Desktop/%(title)s.%(ext)s', u'--write-sub', u'--embed-subs']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'https://bilibili.com/video/BV1TD4y1R7k2']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.03.14
[debug] Python version 2.7.16 (CPython) - Darwin-20.3.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 4.3.1, ffprobe 4.3.1, rtmpdump 2.4
[debug] Proxy map: {}
[BiliBili] 1TD4y1R7k2: Downloading webpage
[BiliBili] 1TD4y1R7k2: Downloading video info page
ERROR: requested format not available
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 806, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 838, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 872, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1675, in process_video_result
    expected=True)
ExtractorError: requested format not available

apple@192 ~ % 

FT129 opened this issue a year ago · comments

Checklist

  • I’m reporting a broken site support issue
  • I’ve verified that I’m running youtube-dl version 2021.12.17
  • I’ve checked that all provided URLs are alive and playable in a browser
  • I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
  • I’ve searched the bugtracker for similar bug reports including closed ones
  • I’ve read bugs section in FAQ

Verbose log

PS C:Usersuserdvtest> ./youtube-dl -v https://v.redd.it/gslumru4bid81 --format "bestvideo[ext=mp4][vcodec=h264]+bestaudio[ext=m4a]/best[ext=mp4][vcodec=h264]/best"
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', 'https://v.redd.it/gslumru4bid81', '--format', 'bestvideo[ext=mp4][vcodec=h264]+bestaudio[ext=m4a]/best[ext=mp4][vcodec=h264]/best']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.22538
[debug] exe versions: ffmpeg n4.4-ffmpeg-windows-build-helpers, ffprobe n4.4-ffmpeg-windows-build-helpers
[debug] Proxy map: {}
[Reddit] gslumru4bid81: Downloading m3u8 information
[Reddit] gslumru4bid81: Downloading MPD manifest
ERROR: requested format not available
Traceback (most recent call last):
  File "C:UsersdstAppDataRoamingBuild archiveyoutube-dlytdl-orgtmpupik7c6wbuildyoutube_dlYoutubeDL.py", line 815, in wrapper
  File "C:UsersdstAppDataRoamingBuild archiveyoutube-dlytdl-orgtmpupik7c6wbuildyoutube_dlYoutubeDL.py", line 847, in __extract_info
  File "C:UsersdstAppDataRoamingBuild archiveyoutube-dlytdl-orgtmpupik7c6wbuildyoutube_dlYoutubeDL.py", line 881, in process_ie_result
  File "C:UsersdstAppDataRoamingBuild archiveyoutube-dlytdl-orgtmpupik7c6wbuildyoutube_dlYoutubeDL.py", line 1684, in process_video_result
youtube_dl.utils.ExtractorError: requested format not available

Description

Format selection fails even when the requested video exists in the specified format. Even if it doesn’t by the order of precedence the final option ‘best’ is supposed to download the video in its best available format from what I understand, but it doesn’t. Without the format selection option the download works fine and downloads an mp4.

YouTube-DL already chooses the best format by default, so why cant you just use this:

youtube-dl v.redd.it/gslumru4bid81 

I don’t always need the best format, I want an mp4 with the video codec h264. I choose best only when this is not available. And I use this as part of a larger script that downloads videos from other sites as well. One of them being tiktok, and tiktok sometimes downloads the video encoded in h265 when it’s left at the default option.

OP may know that what Reddit calls the avc1.4d001f video codec (as listed with -F) is really H.264 but yt-dl doesn’t.

Use [vcodec^=avc1] instead of [vcodec=h264], but as that’s all the video formats there’s really no point, to second @89z.

If someone wanted to get H.264 instead of WebM video as a default configuration setting, the way to do that would be to say so, eg [vcodec!^=?vp9], or (as I now see) to avoid H.265 [vcodec!^=?h265]. But be aware that H.265 may also appear as hevc....

I want an mp4 with the video codec h264

I think thats literally the only option Reddit has, so whats the problem?

I thought I described the problem in the rest of my comment. I mostly just want to know why the last best in ‘bestvideo[ext=mp4][vcodec=h264]+bestaudio[ext=m4a]/best[ext=mp4][vcodec=h264]/best‘] doesn’t work to produce an output when the other format selection options fail. Isn’t that the intended function of best with no qualifiers. Am I doing something wrong or is the option broken?

OP may know that what Reddit calls the avc1.4d001f video codec (as listed with -F) is really H.264 but yt-dl doesn’t.

Use [vcodec^=avc1] instead of [vcodec=h264], but as that’s all the video formats there’s really no point, to second @89z.

If someone wanted to get H.264 instead of WebM video as a default configuration setting, the way to do that would be to say so, eg [vcodec!^=?vp9], or (as I now see) to avoid H.265 [vcodec!^=?h265]. But be aware that H.265 may also appear as hevc....

Thank you, this is helpful.

Finally, .../best didn’t help because for this Reddit page the extracted formats are all either audio-only or video-only. Try .../best/bestvideo+bestaudio or .../bestvideo+bestaudio/best according to preference.

Finally, .../best didn’t help because for this Reddit page the extracted formats are all either audio-only or video-only. Try .../best/bestvideo+bestaudio or .../bestvideo+bestaudio/best according to preference.

Thank you!

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Youtube com error
  • Your device does not match the hardware requirements of this application как исправить на андроид
  • Your current default speech engine does not support this action at this time как исправить
  • Your cpu does not support avx which is required by xenia как исправить на пк
  • Your connection is not secure firefox как исправить

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии