简体   繁体   English

如何使用videojs从s3 presigned url stream 视频文件

[英]How to stream a video file from an s3 presigned url using videojs

I am currently trying to stream a small video file from an s3 bucket.我目前正在尝试 stream 来自 s3 存储桶的小视频文件。 The size of my video file on s3 bucket is 23.5 Mb and its format is video/quicktime.我在 s3 存储桶上的视频文件大小为 23.5 Mb,格式为 video/quicktime。 I am using the following code in jQuery to retrieve the presigned URL我在 jQuery 中使用以下代码来检索预签名的 URL

 const video = await fetch('http://localhost/getUrl', {
    method: "POST",
    body: "key",
    headers: {
        'Content-Type': 'application/json'
    }
})
const result = await video.text();

The result variable returns a presigned url which when clicked downloads the video file.结果变量返回一个预签名的 url,单击它会下载视频文件。

My html code is the following我的 html 代码如下

<video id="vid1" class="video-js " controls preload="auto" width="640" height="265">
</video>

After That I am setting my src in id vid1 as the following之后,我将我的 src 设置为 id vid1 如下

if (result){
    videojs("vid1").src([
        { type: 'video/quicktime', src: result }
      ]);
}

However the file is not playing back and I recieve the following error但是文件没有播放,我收到以下错误

video.min.js:1 VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) The media could not be loaded, either because the server or network failed or because the format is not supported. st {code: 4, message: "The media could not be loaded, either because the …rk failed or because the format is not supported."}.

How would I use videojs with presigned urls to stream a video file from an s3 bucket我如何使用带有预签名 URL 的 videojs 到 stream 来自 s3 存储桶的视频文件

It won't play because the browser can't play video/quicktime .它不会播放,因为浏览器无法播放video/quicktime mov is not a format for HTML5 video. mov 不是 HTML5 视频的格式。 Try using an mp4 with h264/acc and the video/mp4 type.尝试使用带有 h264/acc 和video/mp4类型的 mp4。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM