问题解决:blob类型url的视频下载【转载】

 

一:blob下载问题的详细描述

我想用src url blob:https%3A//www.youtube.com/23aea5c8-9ae2-40dc-9417-e675ea99b386下载视频,但是不知道应该怎么做。

有没有下载这类视频的通用方法?

☼+:;;;;:+☼+:;;;;:+☼+:;;;;:+☼+:;;;;:+☼+:;;;;:+☼+:;;;;:+

二: 推荐的解决方法:

我在Vimeo中找到了一个使用blob url下载视频的方法(读了这篇文章,我才知道做法)。我正在使用Google Chrome,具体步骤如下:

  1. 打开More Tools(更多工具)→Developer Tools(开发工具)
  2. 检查视频标签中是否有这样的东西:
    `<video preload="" src="blob:https://player.vimeo.com/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"></video>``
  3. 复制iframe标签的src(如果有的话)值,如http://player.vimeo.com/video/XYZ,如果你发现它可以复制,直接跳到第7点,否则按照步骤4,5,6继续操作。
  4. 现在在页面中找到这个字符串https://skyfire.vimeocdn.com/.../master.json?base64_init=1(使用开发视图(Developer View)),应该可以在javascript函数中找到它,像这样:(function(e,a){var t={"cdn_url":"https://f.vimeocdn.com","view":1,"request":{"files":{"dash":{"origin":"gcs","url":"https://48skyfiregce-a.akamaihd.net/.../master.json?base64_init=1","cdn":"
  5. 复制上面的url字段中的链接到一个新的Chrome选项卡,例如https://48skyfiregce-a.akamaihd.net/.../master.json?base64_init=1,然后使用浏览器打开它,它会打开一个像这样的json文件:
{
   "clip_id": XYZ,
   "base_url": "../",
   "video": [
                { ... ... ...
  1. 现在用id XYZ组合构造一个URL,如下所示:https://player.vimeo.com/video/XYZ
  2. 用最终的URL替换视频标签内的blob:https://player.vimeo.com/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX(在上一步#6中创建的)。
  3. 现在可以发现,魔术般地,视频标签内的src字段已更改(如果没有,请尝试第7步多次)...
    <video preload="none" src="https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/XX/XXX/X/XXXXXXXX/XXXXXXXXX.mp4?token=abcdefg"></video>

☼+:;;;;:+☼+:;;;;:+☼+:;;;;:+☼+:;;;;:+☼+:;;;;:+☼+:;;;;:+

三:其他的解决思路:

这个答案是针对Twitter网址的

  1. 右键点击视频,然后点击检查元素,你会发现这样的代码:
<div id="playerContainer" class="player-container full-screen-enabled" data-config="{&quot;is_360&quot;:false,&quot;duration&quot;:28617,&quot;scribe_widget_origin&quot;:true,&quot;heartbeatEnabled&quot;:true,&quot;video_url&quot;:&quot;https:\/\/video.twimg.com\/ext_tw_video\/844504104512749568\/pu\/pl\/e91Du5N2TZ09ZaW_.m3u8&quot;,&quot;disable_embed&quot;:&quot;0&quot;,&quot;videoInfo&quot;:{&quot;title&quot;:null,&quot;description&quot;:null,&quot;publisher&quot;:{&quot;screen_name&quot;:&quot;MountainButorac&quot;,&quot;name&quot;:&quot;Mountain Butorac&quot;,&quot;profile_image_url&quot;:&quot;https:\/\/pbs.twimg.com\/profile_images\/808318456701521920\/vBvlAASx_normal.jpg&quot;}},&quot;cardUrl&quot;:&quot;https:\/\/t.co\/SdSorop3uN&quot;,&quot;content_type&quot;:&quot;application\/x-mpegURL&quot;,&quot;owner_id&quot;:&quot;14120461&quot;,&quot;looping_enabled&quot;:true,&quot;show_cookie_override_en&quot;:true,&quot;visit_cta_url&quot;:null,&quot;scribe_playlist_url&quot;:&quot;https:\/\/twitter.com\/MountainButorac\/status\/844505243538931714\/video\/1&quot;,&quot;source_type&quot;:&quot;consumer&quot;,&quot;image_src&quot;:&quot;https:\/\/pbs.twimg.com\/ext_tw_video_thumb\/844504104512749568\/pu\/img\/FFt3qkbeOh0RlGfZ.jpg&quot;,&quot;heartbeatIntervalInMs&quot;:5000.0,&quot;use_tfw_live_heartbeat_event_category&quot;:true,&quot;video_loading_timeout&quot;:45000.0,&quot;status&quot;:{&quot;created_at&quot;:&quot;Wed Mar 22 11:05:14 +0000 2017&quot;,&quot;id&quot;:844505243538931714,&quot;id_str&quot;:&quot;844505243538931714&quot;,&quot;text&quot;:&quot;Took my Goddaughter to meet the pope. She stole his hat! https:\/\/t.co\/SdSorop3uN&quot;,&quot;truncated&quot;:false,&quot;entities&quot;:{&quot;hashtags&quot;:[],&quot;symbols&quot;:[],&quot;user_mentions&quot;:[],&quot;urls&quot;:[],&quot;media&quot;:[{&quot;id&quot;:844504104512749568,&quot;id_str&quot;:&quot;844504104512749568&quot;,&quot;indices&quot;:[57,80],&quot;media_url&quot;:&quot;http:\/\/pbs.twimg.com\/ext_tw_video_thumb\/844504104512749568\/pu\/img\/FFt3qkbeOh0RlGfZ.jpg&quot;,&quot;media_url_https&quot;:&quot;https:\/\/pbs.twimg.com\/ext_tw_video_thumb\/844504104512749568\/pu\/img\/FFt3qkbeOh0RlGfZ.jpg&quot;,&quot;url&quot;:&quot;https:\/\/t.co\/SdSorop3uN&quot;,&quot;display_url&quot;:&quot;pic.twitter.com\/SdSorop3uN&quot;,&quot;expanded_url&quot;:&quot;https:\/\/twitter.com\/MountainButorac\/status\/844505243538931714\/video\/1&quot;,&quot;type&quot;:&quot;photo&quot;,&quot;sizes&quot;:{&quot;small&quot;:{&quot;w&quot;:340,&quot;h&quot;:604,&quot;resize&quot;:&quot;fit&quot;},&quot;thumb&quot;:{&quot;w&quot;:150,&quot;h&quot;:150,&quot;resize&quot;:&quot;crop&quot;},&quot;large&quot;:{&quot;w&quot;:576,&quot;h&quot;:1024,&quot;resize&quot;:&quot;fit&quot;},&quot;medium&quot;:{&quot;w&quot;:576,&quot;h&quot;:1024,&quot;resize&quot;:&quot;fit&quot;}}}]},&quot;source&quot;:&quot;\u003ca href=\&quot;http:\/\/twitter.com\/download\/iphone\&quot; rel=\&quot;nofollow\&quot;\u003eTwitter for iPhone\u003c\/a\u003e&quot;,&quot;in_reply_to_status_id&quot;:null,&quot;in_reply_to_status_id_str&quot;:null,&quot;in_reply_to_user_id&quot;:null,&quot;in_reply_to_user_id_str&quot;:null,&quot;in_reply_to_screen_name&quot;:null,&quot;geo&quot;:null,&quot;coordinates&quot;:null,&quot;place&quot;:null,&quot;contributors&quot;:null,&quot;retweet_count&quot;:0,&quot;favorite_count&quot;:0,&quot;favorited&quot;:false,&quot;retweeted&quot;:false,&quot;possibly_sensitive&quot;:false,&quot;lang&quot;:&quot;en&quot;},&quot;show_cookie_override_all&quot;:true,&quot;video_session_enabled&quot;:false,&quot;media_id&quot;:&quot;844504104512749568&quot;,&quot;view_counts&quot;:null,&quot;statusTimestamp&quot;:{&quot;local&quot;:&quot;4:05 AM - 22 Mar 2017&quot;},&quot;media_type&quot;:1,&quot;user&quot;:{&quot;screen_name&quot;:&quot;MountainButorac&quot;,&quot;name&quot;:&quot;Mountain Butorac&quot;,&quot;profile_image_url&quot;:&quot;https:\/\/pbs.twimg.com\/profile_images\/808318456701521920\/vBvlAASx_bigger.jpg&quot;},&quot;watch_now_cta_url&quot;:null,&quot;tweet_id&quot;:&quot;844505243538931714&quot;}" data-source-type="consumer">

复制上面的代码,并粘贴到记事本++(Notepad++)中,然后用"替换所有的&quot;,用/替换所有和\/。 (使用CTRL + H)

你会得到如下的内容:

{
    "is_360": false,
    "duration": 28617,
    "scribe_widget_origin": true,
    "heartbeatEnabled": true,
    "video_url": "https://video.twimg.com/ext_tw_video/844504104512749568/pu/pl/e91Du5N2TZ09ZaW_.m3u8",
 
    "disable_embed": "0",
    "videoInfo": {
        "title": null,
        "description": null,
        "publisher": {
            "screen_name": "MountainButorac",
            "name": "Mountain Butorac",
            "profile_image_url": "https://pbs.twimg.com/profile_images/808318456701521920/vBvlAASx_normal.jpg"
        }
    },
    "cardUrl": "https://t.co/SdSorop3uN",
    "content_type": "application/x-mpegURL",
    "owner_id": "14120461",
    "looping_enabled": true,
    "show_cookie_override_en": true,
    "visit_cta_url": null,
    "scribe_playlist_url": "https://twitter.com/MountainButorac/status/844505243538931714/video/1",
    "source_type": "consumer",
    "image_src": "https://pbs.twimg.com/ext_tw_video_thumb/844504104512749568/pu/img/FFt3qkbeOh0RlGfZ.jpg",
    "heartbeatIntervalInMs": 5000.0,
    "use_tfw_live_heartbeat_event_category": true,
    "video_loading_timeout": 45000.0,
    "status": {
        "created_at": "Wed Mar 22 11:05:14 +0000 2017",
        "id": 844505243538931714,
        "id_str": "844505243538931714",
        "text": "Took my Goddaughter to meet the pope. She stole his hat! https://t.co/SdSorop3uN",
        "truncated": false,
        "entities": {
            "hashtags": [],
            "symbols": [],
            "user_mentions": [],
            "urls": [],
            "media": [{
                "id": 844504104512749568,
                "id_str": "844504104512749568",
                "indices": [57, 80],
                "media_url": "http://pbs.twimg.com/ext_tw_video_thumb/844504104512749568/pu/img/FFt3qkbeOh0RlGfZ.jpg",
                "media_url_https": "https://pbs.twimg.com/ext_tw_video_thumb/844504104512749568/pu/img/FFt3qkbeOh0RlGfZ.jpg",
                "url": "https://t.co/SdSorop3uN",
                "display_url": "pic.twitter.com/SdSorop3uN",
                "expanded_url": "https://twitter.com/MountainButorac/status/844505243538931714/video/1",
                "type": "photo",
                "sizes": {
                    "small": {
                        "w": 340,
                        "h": 604,
                        "resize": "fit"
                    },
                    "thumb": {
                        "w": 150,
                        "h": 150,
                        "resize": "crop"
                    },
                    "large": {
                        "w": 576,
                        "h": 1024,
                        "resize": "fit"
                    },
                    "medium": {
                        "w": 576,
                        "h": 1024,
                        "resize": "fit"
                    }
                }
            }]
        },
        "source": "\u003ca href=\"http://twitter.com/download/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c/a\u003e",
        "in_reply_to_status_id": null,
        "in_reply_to_status_id_str": null,
        "in_reply_to_user_id": null,
        "in_reply_to_user_id_str": null,
        "in_reply_to_screen_name": null,
        "geo": null,
        "coordinates": null,
        "place": null,
        "contributors": null,
        "retweet_count": 0,
        "favorite_count": 0,
        "favorited": false,
        "retweeted": false,
        "possibly_sensitive": false,
        "lang": "en"
    },
    "show_cookie_override_all": true,
    "video_session_enabled": false,
    "media_id": "844504104512749568",
    "view_counts": null,
    "statusTimestamp": {
        "local": "4:05 AM - 22 Mar 2017"
    },
    "media_type": 1,
    "user": {
        "screen_name": "MountainButorac",
        "name": "Mountain Butorac",
        "profile_image_url": "https://pbs.twimg.com/profile_images/808318456701521920/vBvlAASx_bigger.jpg"
    },
    "watch_now_cta_url": null,
    "tweet_id": "844505243538931714"
}

从上面的JSON格式,可以看到video_url的值:
https://video.twimg.com/ext_tw_video/844504104512749568/pu/pl/e91Du5N2TZ09ZaW_.m3u8
这里的问题是,在2016年8月1日之后,Twitter不再使用.mp4视频,而是转换为新的HLS,自适应流格式,带有.m3u8文件扩展名。

.m3u8文件基本上只是一个文本文的封装,它们非常小(300-500字节)。当您使用文本编辑器打开它们时,它们包含指向不同视频大小的链接

  1. 在记事本++(Notepad++)中打开文件m3u8,它会包含这样的代码:

EXTM3U EXT-X-INDEPENDENT-SEGMENTS EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=256000,RESOLUTION=180x320,CODECS="mp4a.40.2,avc1.42001f"/ext_tw_video/844504104512749568/pu/pl/180x320/_Z42SY5zwMlLdFYx.m3u8 EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=832000,RESOLUTION=360x640,CODECS="mp4a.40.2,avc1.42001f"/ext_tw_video/844504104512749568/pu/pl/360x640/-Phfjbbx2yinirLi.m3u8

  1. 根据您需要的分辨率从上面复制对应的链接。重复相同的步骤,直到有.ts文件。下载.ts文件(视频文件)。
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Blob视频是以分段方式传输的视频,因此无法直接下载。为了下载Blob视频,可以使用Python编写代码来获取视频的源地址,并进行下载。以下是使用Python获取Blob视频源地址并下载的步骤: 1. 通过网络请求获取Blob视频URL。可以使用Python的`urllib.request`库发送GET请求,并传入相关的请求头信息。 2. 解析HTML响应,提取视频URL。可以使用正则表达式从HTML响应中提取视频URL,具体的正则表达式可以根据实际情况进行调整。 3. 使用得到的视频URL进行下载。可以使用Python的`urllib.request.urlretrieve`函数将视频保存到本地。 下面是一段示例代码,展示了如何使用Python下载Blob视频: ```python import urllib.request import re # 获取视频URL def get_video_url(url, headers): # GET方式请求网站 req = urllib.request.Request(url, headers=headers, method="GET") try: # 获取到HTML response = urllib.request.urlopen(req).read().decode('utf-8') except urllib.error.HTTPError as e: print(e) print('\r\n' + url + ' download failed' + '\r\n') # 正则表达式提取视频URL video_url = re.search(r"readyVideoUrl: '(.*)?'", response)[0][16: -1] return video_url # 设置请求头信息 headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36' } # Blob视频URL blob_url = 'blob:http://tclearn.cmbchina.cn/5a8c0e2a-0cd9-4a50-ac4e-aa96fdadc15a' # 获取视频的源地址 video_url = get_video_url(blob_url, headers) # 下载视频 urllib.request.urlretrieve(video_url, 'video.ts') ``` 请注意,以上代码仅为示例,具体的实现可能需要根据实际情况进行调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值