0

我正在使用 pytube 下载 youtube 视频,作为更大项目的一部分。这是导致部分的问题:

    from pytube import YouTube
    yt = YouTube('https://www.youtube.com/watch?v=LXb3EKWsInQ&t=7s')
    x = yt.streams.get_by_resolution('144p')
    print(x) # output of this line is None

但是,如果我跑

    y = yt.streams.streams.all() 
    print(y) # the output of this shows that several streams with res = '144p' exist

输出:

<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2" progressive="True" type="video">
<Stream: itag="313" mime_type="video/webm" res="2160p" fps="30fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="315" mime_type="video/webm" res="2160p" fps="60fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="337" mime_type="video/webm" res="2160p" fps="60fps" vcodec="vp9.2" progressive="False" type="video">
<Stream: itag="401" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.13M.10.0.110.09.16.09.0" progressive="False" type="video">
<Stream: itag="271" mime_type="video/webm" res="1440p" fps="30fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="308" mime_type="video/webm" res="1440p" fps="60fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="336" mime_type="video/webm" res="1440p" fps="60fps" vcodec="vp9.2" progressive="False" type="video">
<Stream: itag="400" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.12M.10.0.110.09.16.09.0" progressive="False" type="video">
<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028" progressive="False" type="video">
<Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="299" mime_type="video/mp4" res="1080p" fps="60fps" vcodec="avc1.64002a" progressive="False" type="video">
<Stream: itag="303" mime_type="video/webm" res="1080p" fps="60fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="335" mime_type="video/webm" res="1080p" fps="60fps" vcodec="vp9.2" progressive="False" type="video">
<Stream: itag="399" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.09M.10.0.110.09.16.09.0" progressive="False" type="video">
<Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f" progressive="False" type="video">
<Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="298" mime_type="video/mp4" res="720p" fps="60fps" vcodec="avc1.4d4020" progressive="False" type="video">
<Stream: itag="302" mime_type="video/webm" res="720p" fps="60fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="334" mime_type="video/webm" res="720p" fps="60fps" vcodec="vp9.2" progressive="False" type="video">
<Stream: itag="398" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.08M.10.0.110.09.16.09.0" progressive="False" type="video">
<Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401f" progressive="False" type="video">
<Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="333" mime_type="video/webm" res="480p" fps="60fps" vcodec="vp9.2" progressive="False" type="video">
<Stream: itag="397" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.04M.10.0.110.09.16.09.0" progressive="False" type="video">
<Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e" progressive="False" type="video">
<Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="332" mime_type="video/webm" res="360p" fps="60fps" vcodec="vp9.2" progressive="False" type="video">
<Stream: itag="396" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.01M.10.0.110.09.16.09.0" progressive="False" type="video">
<Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015" progressive="False" type="video">
<Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="331" mime_type="video/webm" res="240p" fps="60fps" vcodec="vp9.2" progressive="False" type="video">
<Stream: itag="395" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.00M.10.0.110.09.16.09.0" progressive="False" type="video">
<Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c" progressive="False" type="video">
<Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9" progressive="False" type="video">
<Stream: itag="330" mime_type="video/webm" res="144p" fps="60fps" vcodec="vp9.2" progressive="False" type="video">
<Stream: itag="394" mime_type="video/mp4" res="None" fps="30fps" vcodec="av01.0.00M.10.0.110.09.16.09.0" progressive="False" type="video">
<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2" progressive="False" type="audio">
<Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus" progressive="False" type="audio">
<Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus" progressive="False" type="audio">
<Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus" progressive="False" type="audio">

现在,我不明白为什么即使流存在也会yt.streams.get_by_resolution('144p')返回。None

更多:似乎对于此视频的所有分辨率,除了360pNone都返回。

4

1 回答 1

3

根据文档,流必须是渐进式 mp4。如果渐进式流不可用,则返回 None。

于 2020-03-26T08:21:17.883 回答