为 html 5 准备 mp4 文件 [英] preparing mp4 file for html 5

查看:36
本文介绍了为 html 5 准备 mp4 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 html 5 中,我想嵌入这样的 mp4:

In html 5, I want to embed an mp4 like this:

<video width="640" height="480" controls>
    <source src="somefile.mp4" type="video/mp4">
    Your browser does not support the video tag.
</video>

视频在我的开发机器上的浏览器中运行良好,但文件大小为 500MB,因为它是以全高清录制的.如何对文件进行下采样,使其大小约为 50MB,视频更小但音质相同,并且仍然能够使用上面显示的 html5 视频标签在浏览器中播放?

The video runs fine the the browser in my development machine, but the file is 500MB because it was recorded in full HD. How do I down-sample the file so that it is about 50MB, with smaller video but the same sound quality, and still able to play in the browser using the html5 video tag shown above?

我使用的是 Windows.我一直在使用 FlashIntegro,但它将文件转换为 avi 格式,无法使用视频标签查看html 5. 我想要一个 mp4 格式,我可以使用 html 5 中的视频标签发布.我想使用免费软件.

I am using Windows. I have been using FlashIntegro, but it converts the files to avi format, which cannot be viewed using the video tags in html 5. I want an mp4 format I can publish using the video tags in html 5. I would like to use free software.

我不想使用 Flash 或 adobe 创意云,但我添加这些标签是为了寻找可能了解免费替代方案的观众.

I do not want to use flash or adobe creative cloud, but I am adding those tags to find viewers who might know about free alternatives.

推荐答案

我会推荐类似 ffmpeg 的东西,但如果你从 500mb 的文件变成 50mb 的文件,我会设定质量期望 - 不过很大程度上取决于源代码中已经存在的优化量......我能够使用以下方法将 270Mb 的文件降低到 29Mb,而没有明显的质量损失:

I would suggest something like ffmpeg, though would set expectations on quality if you go from a 500mb file to a 50mb one - though a lot will depend on the amount of optimization already present in the source... I was able to get a 270Mb file down to 29Mb without visible loss of quality using the following:

./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

这篇关于为 html 5 准备 mp4 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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