js blob类型url的视频下载问题的解决


Posted in Javascript onNovember 29, 2019

blob下载问题的详细描述

我想用src url blob:https://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": [
         { ... ... ...

6、现在用id XYZ组合构造一个URL,如下所示:https://player.vimeo.com/video/XYZ

7、用最终的URL替换视频标签内的blob:https://player.vimeo.com/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX(在上一步#6中创建的)。

8、现在可以发现,魔术般地,视频标签内的src字段已更改(如果没有,请尝试第7步多次)...

<video preload="none" src="https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/XX/XXX/X/XXXXXXXX/XXXXXXXXX.mp4?token=abcdefg"></video>

最后,使用新的链接直接下载它,就像这样:https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/XX/XXX/X/XXXXXXXX/XXXXXXXXX.mp4?token=abcdefg

其他的解决思路

这个答案是针对Twitter网址的 -

右键点击视频,然后点击检查元素 -

你会发现这样的代码

<div id="playerContainer" class="player-container full-screen-enabled" data-config="{"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"}" data-source-type="consumer">

复制上面的代码,并粘贴到记事本++(Notepad++)中,然后用"替换所有的",用/替换所有和\/。 (使用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字节)。当您使用文本编辑器打开它们时,它们包含指向不同视频大小的链接

在记事本++(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

根据您需要的分辨率从上面复制对应的链接。重复相同的步骤,直到有.ts文件。下载.ts文件(视频文件)。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Javascript 相关文章推荐
css图片自适应大小
Nov 28 Javascript
js下将字符串当函数执行的方法
Jul 13 Javascript
javascript真的不难-回顾一下基础知识
Jan 15 Javascript
jquery实现弹出层完美居中效果
Mar 03 Javascript
JQuery中extend的用法实例分析
Feb 08 Javascript
jquery实现的仿天猫侧导航tab切换效果
Aug 24 Javascript
js实现文字闪烁特效的方法
Dec 17 Javascript
javascript从定义到执行 你不知道的那些事
Jan 04 Javascript
利用Node.js如何实现文件循环覆写
Apr 05 Javascript
微信小程序 自定义弹窗实现过程(附代码)
Dec 05 Javascript
Node在Controller层进行数据校验的过程详解
Aug 28 Javascript
详解Node.JS模块 process
Aug 31 Javascript
JavaScript之Blob对象类型的具体使用方法
Nov 29 #Javascript
VuePress 中如何增加用户登录功能
Nov 29 #Javascript
Vue.directive 实现元素scroll逻辑复用
Nov 29 #Javascript
Vue.js实现大屏数字滚动翻转效果
Nov 29 #Javascript
Vue基础配置讲解
Nov 29 #Javascript
jQuery实现弹幕特效
Nov 29 #jQuery
Vue实现多标签选择器
Nov 28 #Javascript
You might like
php页面缓存方法小结
2015/01/10 PHP
PHP常用文件操作函数和简单实例分析
2016/06/03 PHP
laravel 执行迁移回滚示例
2019/10/23 PHP
asp 的 分词实现代码
2007/05/24 Javascript
javascript onmouseout 解决办法
2010/07/17 Javascript
精选的10款用于构建良好易用性网站的jQuery插件
2011/01/23 Javascript
html超链接打开窗口大小的方法
2013/03/05 Javascript
JavaScript针对网页节点的增删改查用法实例
2015/02/02 Javascript
jQuery实现在列表的首行添加数据
2015/05/19 Javascript
探讨:JavaScript ECAMScript5 新特性之get/set访问器
2016/05/05 Javascript
Node.js 使用递归实现遍历文件夹中所有文件
2017/09/18 Javascript
Vue.js实现列表清单的操作方法
2017/11/15 Javascript
Vuejs2 + Webpack框架里,模拟下载的实例讲解
2018/09/05 Javascript
nodejs读取本地中文json文件出现乱码解决方法
2018/10/10 NodeJs
jQuery实现ajax的嵌套请求案例分析
2019/02/16 jQuery
jsonp跨域获取百度联想词的方法分析
2019/05/13 Javascript
微信小程序+腾讯地图开发实现路径规划绘制
2019/05/22 Javascript
JavaScript如何判断input数据类型
2020/02/06 Javascript
vue中实现动态生成二维码的方法
2020/02/21 Javascript
JavaScript十大取整方法实例教程
2020/12/03 Javascript
js获取图片的base64编码并压缩
2020/12/05 Javascript
Python深入学习之上下文管理器
2014/08/31 Python
windows下numpy下载与安装图文教程
2019/04/02 Python
Python GUI编程 文本弹窗的实例
2019/06/11 Python
简单分析python的类变量、实例变量
2019/08/23 Python
浅谈tensorflow 中的图片读取和裁剪方式
2020/06/30 Python
超酷炫 CSS3垂直手风琴菜单
2016/06/28 HTML / CSS
CSS3实现点击放大的动画实例代码
2017/02/27 HTML / CSS
美国猫狗药物和用品网站:PetCareRx
2017/01/05 全球购物
电话销售经理岗位职责
2013/12/07 职场文书
银行党的群众路线教育实践活动对照检查材料
2014/09/25 职场文书
2016年主题党日活动总结
2016/04/05 职场文书
python基础之文件处理知识总结
2021/05/23 Python
一次项目中Thinkphp绕过禁用函数的实战记录
2021/11/17 PHP
B站评分公认最好看的动漫,你的名字评分9.9,第六备受喜欢
2022/03/18 日漫
Python TypeError: ‘float‘ object is not subscriptable错误解决
2022/12/24 Python