FFMPEG转换HTML 5视频不工作 [英] FFMPEG Convert HTML 5 Video NOT Working
问题描述
我正在使用 FFMPEG将视频转换为 .mp4,ogg,.webm ,以便在所有支持HTML5的浏览器中使用视频标签。问题在于,我将视频转换为3种格式,但不会在视频标签中显示视频,我所得到的只有IE9:红十字,Firefox:Gray cross是转换的问题,或者是将其添加到视频标签的来源中的方式。 以下是我所做的:
-
FFmpeg命令行: / strong>
ffmpeg -i test.mp4 test.mp4
ffmpeg -i test.mp4 test.ogg
ffmpeg -i test.mp4 test.webm
-
视频标签:
< video id =videoheight =340width =470 =PlayVideoFromVid('PAUSE')onpause =PlayVideoFromVid('PLAY')onended =ResetVideo()preload =trueautobuffer =truecontrols =true>
< source src =test.oggtype =video / ogg>< / source>
< source src =test.mp4type =video / mp4>< / source>
< / video>
-
视频支持的Webconfig行:
< staticContent>
< mimeMap fileExtension =。mp4mimeType =video / mp4/>
< mimeMap fileExtension =。oggmimeType =audio / ogg/>
< mimeMap fileExtension =。ogamimeType =audio / ogg/>
< mimeMap fileExtension =。ogvmimeType =video / ogg/>
< mimeMap fileExtension =。webmmimeType =video / webm/>
< / staticContent>
如果有人可以发送给我, ffmpeg将视频转换为3种所需格式的必要参数,以及如何将视频标签中的源设置为再次显示的示例。任何其他的建议将会非常好,在进行转换时如何设置质量等。
提前感谢
排序,谢谢所有的帮助:)我找到以下内容:
1。您需要下载最新的ffmpeg +预设:
ffmpeg.arrozcru.org/autobuilds/ffmpeg/mingw32/static/
<强> 2。您需要创建一个HOME环境变量:
(a) www.moosechips.com/2009/08/installing-ffmpeg-binary-in-windows/
(b) www.itechtalk.com/thread3595.html
3。复制环境变量文件夹下的预设
4。您需要使用以下命令转换ffmpeg:
对于mp4(H.264 / ACC):
ffmpeg -i INPUTFILE -b 1500k -vcodec libx264 -vpre slow -vpre baseline -g 30OUTPUTFILE.mp4
对于webm(VP8 / Vorbis):
ffmpeg -iINPUTFILE-b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30OUTPUTFILE.webm
对于ogv(Theora / Vorbis):
ffmpeg -iINPUTFILE-b 1500k -vcodec libtheora -acodec libvorbis -ab 160000 -g 30OUTPUTFILE.ogv
pre>
I am using FFMPEG to convert a video to .mp4, ,ogg, .webm so that it may be viewed in all HTML5 capable browsers using the video tag. The problem is that I manage to convert the video to the 3 required formats but it does not display the video in the video tag, all I get is IE9: red cross, Firefox: Grey cross, could it be a problem with the conversion or is it something to do with the way I am adding them to the source of the video tag. Here is what I have done:
FFmpeg command line(s):
ffmpeg -i test.mp4 test.mp4 ffmpeg -i test.mp4 test.ogg ffmpeg -i test.mp4 test.webm
Here is the video tag:
<video id="video" height="340" width="470" onplaying="PlayVideoFromVid('PAUSE')" onpause="PlayVideoFromVid('PLAY')" onended="ResetVideo()" preload="true" autobuffer="true" controls="true"> <source src="test.ogg" type="video/ogg"></source> <source src="test.mp4" type="video/mp4"></source> </video>
Webconfig lines for the video support:
<staticContent> <mimeMap fileExtension=".mp4" mimeType="video/mp4" /> <mimeMap fileExtension=".ogg" mimeType="audio/ogg" /> <mimeMap fileExtension=".oga" mimeType="audio/ogg" /> <mimeMap fileExtension=".ogv" mimeType="video/ogg" /> <mimeMap fileExtension=".webm" mimeType="video/webm" /> </staticContent>
It would be great if someone could send me the required parameters for ffmpeg to convert the video to the 3 required formats and an example of how they setting the source in the video tag to display them again. And any other advise would be great like how to set the quality up etc when doing the conversion.
Thanks in advance.
解决方案Sorted it out, thanks for all the help :) I found the following:
1. You need to download the latest ffmpeg + the presets:
ffmpeg.arrozcru.org/autobuilds/ffmpeg/mingw32/static/
2. You need to create a HOME environmetal variable:
(a) www.moosechips.com/2009/08/installing-ffmpeg-binary-in-windows/
(b) www.itechtalk.com/thread3595.html
3. Copy the presets under the environmental variable folder
4. You need to use the following commands to convert using ffmpeg:
For mp4 (H.264 / ACC):
ffmpeg -i INPUTFILE -b 1500k -vcodec libx264 -vpre slow -vpre baseline -g 30 "OUTPUTFILE.mp4"
For webm (VP8 / Vorbis):
ffmpeg -i "INPUTFILE" -b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30 "OUTPUTFILE.webm"
For ogv (Theora / Vorbis):
ffmpeg -i "INPUTFILE" -b 1500k -vcodec libtheora -acodec libvorbis -ab 160000 -g 30 "OUTPUTFILE.ogv"
这篇关于FFMPEG转换HTML 5视频不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!