为什么我不能跳过我制作的网页上的MP4视频? [英] Why Cant i skip ahead on a MP4 video on a web page i made?

查看:210
本文介绍了为什么我不能跳过我制作的网页上的MP4视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了一个Apache服务器,并制作了一个简单的网页,上面有一个视频. 该视频播放,但是如果我尝试向前或向后跳过,则会冻结.如果我单击暂停/播放"按钮,通常会返回到视频的开头.该视频为MP4格式.由于我要播放的视频长达一个小时,因此可能是一个很大的文件.我尝试了较小的文件,它们似乎可以正常播放,并且可以根据需要查找更多文件.另外,如果在本地打开网页也可以,所以我认为它与下载/缓冲视频有关,我只是不知道从哪里开始尝试对其进行修复.

I have an Apache server set up and have made a simple web page,with a video on it. The video plays, but if i try to skip ahead or behind it freezes up. If i click the pause/play button it will usually go back to the beginning of the video. The video is MP4 format.It might be worth noting that the video is a rather large file as the video I'm trying to play is a hour long. I've tried smaller files and they seem to play fine and i can seek as much as i want. Also if open the web page locally it works, so I'm thinking it has something to do with downloading/buffering the video i just don't know where to start to try and fix it.

推荐答案

如果该文件适用于较小的文件,但不适用于较大的文件,那么我将检查mp4中的元数据元素(MOOV原子)在哪里.默认情况下,它是在末尾,这意味着在Web浏览器读取整个文件之前,将无法进行累积查找.

If it's working with smaller files but not larger ones I would check where the meta data element (MOOV atom) in your mp4 is. By default it's at the end, which means accurating seeking won't be able to happen until the web browser has read the entire file.

您可以使用 FFmpeg 解决此问题,从而将MOOV原子重新放置在最前面,以便浏览器能够请求正确的文件的一部分(假设您的服务器配置为支持字节范围请求):

You can address this using FFmpeg to relocate the MOOV atom to the front so the browser is able to request the correct parts of the file (assuming your server is configured to support byte range requests):

./ffmpeg -y -i SourceFile.mp4 -c:v copy -c:a copy -movflags faststart DestFile.mp4

这将简单地重新放置MOOV原子,并复制音频和视频(无需重新处理)-因此,一旦基础知识奏效,您可能希望查看其他优化方法来改善体验.

this will simply re-position the MOOV atom, and copy the audio and video (no reprocessing) - so once the basics are working you might want to look at other optimizations you can do to improve the experience.

这篇关于为什么我不能跳过我制作的网页上的MP4视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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