为 <video> 设置缓冲目的 [英] Set up buffering for <video> object

查看:40
本文介绍了为 <video> 设置缓冲目的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试播放托管在远程服务器上的视频,我遇到的问题是大型视频需要很长时间才能开始播放.似乎需要在视频开始播放之前下载整个视频(通过比较视频开始播放所需的时间与下载所需的时间).有没有人对如何设置视频以在下载少量视频后立即开始显示有任何建议.

So I'm trying to play videos that are hosted on a remote server, the problem I'm encountering is that it takes a VERY long time for large videos to start playing. It seems that the entire video needs to be downloaded before the video starts playing (by comparing the time it takes for the video to start playing with the time it takes to download it). Does anyone have any advice on how to set up the videos to start showing as soon as even a small amount of it has downloaded.

推荐答案

要处理单个上传,您需要使用 ffmpeg 之类的工具将元数据 (MOOV atom) 移动到视频文件的前面:

to process individual uploads you'll want to use something like ffmpeg to move the meta data (MOOV atom) to the front of the video file:

./ffmpeg -y -i SourceFile.mp4 -s 1280x720 -c:v libx264 -b 3M -strict -2 -movflags faststart DestFile.mp4

以上内容将在 mp4 容器中使用 h264 以 3Mbps 的速度为您提供 1280x720 输出,并且还将执行第二遍以将 moov 元素移动到文件的前面,使其能够更快地开始流式传输.它不会重新编码音频,因此会保持您开始使用的任何质量

The above will give you a 1280x720 output, at 3Mbps using h264 in an mp4 container, and will also do a second pass to move the moov element to the front of the file enabling it to start streaming faster. It will not re-encode the audio so will keep whatever quality you started with

您可能想要调整帧大小和比特率,以使文件大小与您喜欢/需要的相匹配.

You may want to play around with the framesize and the bitrate to get the filesize to match what you like/need.

要在后台执行此操作,您需要查看类似 this 从 PHP 调用 ffmpeg,或使用 http://ffmpeg-php.sourceforge.net/ 调用它,或者如果更容易使用远程转码服务,例如 http://ffmpegasaservice.com/

to do this in the background you'll want to review something like this to call ffmpeg from PHP, or to make use of http://ffmpeg-php.sourceforge.net/ to call it, or if easier use a remote transcode service such as http://ffmpegasaservice.com/

这篇关于为 <video> 设置缓冲目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆