gpt4 book ai didi

url - 上传视频并获取直接URL以进行流式传输

转载 作者:行者123 更新时间:2023-12-03 05:38:31 31 4
gpt4 key购买 nike

我想上传视频并获取直接的URL(不是YouTube页面,而是服务器上的原始视频文件)。我在这里阅读到youtube-dl可以从YT视频获得这样的直接链接,但返回的内容如下:

https://r5---sn-f5f7ln7s.googlevideo.com/videoplayback?id=5e338da1be872622&itag=
140&source=youtube&requiressl=yes&mm=31&pl=17&mn=sn-f5f7ln7s&mv=m&ms=au&ratebypa
ss=yes&mime=audio/mp4&gir=yes&clen=615762&lmt=1444814917264017&dur=38.730&key=dg
_yt0&signature=85FE55338A7ECBCA4895DFA3084A6C8CB7C09654.28AD612266C937BFBBD20135
D03031E824806B53&sver=3&mt=1444818958&fexp=9405191,9408210,9408710,9414764,94154
35,9415868,9416126,9417707,9418199,9418401,9418702,9420439,9420933,9421923,94220
62,9422545&upn=5cQZ5KNCvl0&ip=89.74.115.72&ipbits=0&expire=1444840721&sparams=ip
,ipbits,expire,id,itag,source,requiressl,mm,pl,mn,mv,ms,ratebypass,mime,gir,clen
,lmt,dur

事实是,它可以播放,但什么也没显示(实际上,它作为视频文件打开)。因此,YT似乎在某种程度上受到了此类行为的保护。

您知道让我做这种事情的网站吗?

谢谢!

最佳答案

youtube-dl可以从各种各样的网站下载视频,而不仅仅是YouTube

youtube-dl -c -l https://www.youtube.com/watch?v=fT88iVceBn4

在服务器(或本地计算机)上拥有媒体文件(音频/视频)后,以下nodejs服务器会将其流式传输到URL ...

将下面的节点代码保存到文件media_server.js中,然后在安装完nodejs后启动以下代码
node ./media_server.js 

然后将您的浏览器指向 http://localhost:8888/

它是一个微型媒体服务器,可以响应所有标准的媒体导航小部件...玩得开心
var http = require('http'),
fs = require('fs'),
util = require('util');

// var path = "/path/to/audio/or/video/file/local/to/server/cool.mp4"; // put any audio or video file here
var path = "/home/stens/Videos/kehoe/OliverSacks_2009-480p.mp4"; // put any audio or video file here

var port = 8888;
var host = "localhost";

http.createServer(function (req, res) {

var stat = fs.statSync(path);
var total = stat.size;

if (req.headers.range) { // meaning client (browser) has moved the forward/back slider
// which has sent this request back to this server logic ... cool
var range = req.headers.range;
var parts = range.replace(/bytes=/, "").split("-");
var partialstart = parts[0];
var partialend = parts[1];

var start = parseInt(partialstart, 10);
var end = partialend ? parseInt(partialend, 10) : total-1;
var chunksize = (end-start)+1;
console.log('RANGE: ' + start + ' - ' + end + ' = ' + chunksize);

var file = fs.createReadStream(path, {start: start, end: end});
res.writeHead(206, { 'Content-Range': 'bytes ' + start + '-' + end + '/' + total, 'Accept-Ranges': 'bytes', 'Content-Length': chunksize, 'Content-Type': 'video/mp4' });
file.pipe(res);

} else {

console.log('ALL: ' + total);
res.writeHead(200, { 'Content-Length': total, 'Content-Type': 'video/mp4' });
fs.createReadStream(path).pipe(res);
}
}).listen(port, host);

console.log("Server running at http://" + host + ":" + port + "/");

关于url - 上传视频并获取直接URL以进行流式传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33123532/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com