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

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

问题描述

因此,我试图播放托管在远程服务器上的视频,但我遇到的问题是大视频开始播放需要很长时间。似乎需要在视频开始播放之前下载整个视频(通过比较视频开始播放所需的时间和下载所需的时间)。有没有人有任何建议,如何设置视频,即使只有少量它已下载视频开始显示。

解决方案

p>来处理单独的上传,您将需要使用类似ffmpeg的元素将元数据(MOOV原子)移动到视频文件的前端:

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

以上将给出1280x720的输出,在mp4容器中使用h264以3Mbps为单位,并且还将执行第二遍以将moov元素移到前面该文件使其能够更快地开始流式传输。它不会重新编码音频,因此会保持您开始使用的任何质量。您可能想要使用framesize和bitrate来获取文件大小以匹配你喜欢/需要。



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


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.

解决方案

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

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.

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天全站免登陆