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 相关文章推荐
Dojo之路:如何利用Dojo实现Drag and Drop效果
Apr 10 Javascript
UI Events 用户界面事件
Jun 27 Javascript
动态加载dtree.js树treeview(示例代码)
Dec 17 Javascript
JavaScript Serializer序列化时间处理示例
Jul 31 Javascript
jquery checkbox 勾选的bug问题解决方案与分析
Nov 13 Javascript
js中键盘事件实例简析
Jan 10 Javascript
JQuery调用绑定click事件的3种写法
Mar 28 Javascript
如何给ss bash 写一个 WEB 端查看流量的页面
Mar 23 Javascript
JS阻止事件冒泡的方法详解
Aug 26 Javascript
tracking.js实现前端人脸识别功能
Apr 16 Javascript
在vue中使用vant TreeSelect分类选择组件操作
Nov 02 Javascript
js用正则表达式筛选年月日的实例方法
Jan 04 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与已存在的Java应用程序集成
2006/10/09 PHP
无法在发生错误时创建会话,请检查 PHP 或网站服务器日志,并正确配置 PHP 安装最快的解决办法
2010/08/01 PHP
PHP flush()与ob_flush()的区别详解
2013/06/03 PHP
laravel 实现关闭CSRF(全部关闭、部分关闭)
2019/10/21 PHP
YUI 读码日记之 YAHOO.util.Dom - Part.1
2008/03/22 Javascript
javascript 控制input只允许输入的各种指定内容
2014/06/19 Javascript
jQuery禁用键盘后退屏蔽F5刷新及禁用右键单击
2016/01/22 Javascript
学习使用bootstrap基本控件(table、form、button)
2016/04/12 Javascript
Winform客户端向web地址传参接收参数的方法
2016/05/17 Javascript
javascript获取select标签选中的值
2016/06/04 Javascript
Angular实现跨域(搜索框的下拉列表)
2017/02/16 Javascript
Express URL跳转(重定向)的实现方法
2017/04/07 Javascript
老生常谈combobox和combotree模糊查询
2017/04/17 Javascript
javascript算法之二叉搜索树的示例代码
2017/09/12 Javascript
Vue 与 Vuex 的第一次接触遇到的坑
2018/08/16 Javascript
JavaScript的词法结构精华篇
2018/10/17 Javascript
iview通过Dropdown(下拉菜单)实现的右键菜单
2018/10/26 Javascript
如何在Vue中使用CleaveJS格式化你的输入内容
2018/12/14 Javascript
详解如何用webpack4从零开始构建react开发环境
2019/01/27 Javascript
Fetch超时设置与终止请求详解
2019/05/18 Javascript
小程序实现按下录音松开识别语音
2019/11/22 Javascript
解决vue字符串换行问题(绝对管用)
2020/08/06 Javascript
Python输出汉字字库及将文字转换为图片的方法
2016/06/04 Python
python中实现数组和列表读取一列的方法
2018/04/03 Python
python实现计数排序与桶排序实例代码
2019/03/28 Python
解决Django生产环境无法加载静态文件问题的解决
2019/04/23 Python
python pptx复制指定页的ppt教程
2020/02/14 Python
python实现用户名密码校验
2020/03/18 Python
python爬虫中的url下载器用法详解
2020/11/30 Python
python通过cython加密代码
2020/12/11 Python
镇班子对照检查材料思想汇报
2014/09/24 职场文书
店面出租协议书范本
2014/11/28 职场文书
幼儿园园务工作总结2015
2015/05/18 职场文书
《女娲补天》读后感5篇
2019/12/31 职场文书
Java面试题冲刺第十五天--设计模式
2021/08/07 面试题
怎么禁用Windows 11快照布局? win11不使用快照布局的技巧
2021/11/21 数码科技