AVI到MP4 - ffmpeg转换 [英] AVI to MP4 - ffmpeg conversion
问题描述
我正在运行一个debian 7.5机器,其中安装了ffmpeg-2.2,遵循以下这些说明
发行
我试图在浏览器中显示一个mp4视频。原始文件具有AVI容器格式。我可以成功地将其转换为mp4,目标文件是可读的(视频+声音)与图腾电影播放器。所以我以为一切都可以显示下面的页面
HTML5网页
<!DOCTYPE html>< html>
< head>
< title>网络摄像头< / title>
< / head>
< body>
< video width =640height =480controls>
< source src =/ path / to / output.mp4type =video / mp4>
< h3>您的浏览器不支持视频标签< / h3>
< / video>
< / body>< / html>
输入探针
code> $ ffprobe -show_streams input.avi
持续时间:00:08:22.90,开始:0.000000,比特率:1943 kb / s
流#0:0:音频: mp3(U [0] [0] [0] / 0x0055),48000 Hz,立体声,s16p,64 kb / s
流#0:1:视频:mpeg4(高级简单配置文件)(XVID / 0x44495658) ,yuv420p,720x540 [SAR 1:1 DAR 4:3],1870 kb / s,29.97 fps,25 tbr,29.97 tbn,25 tbc
转换
$ ffmpeg -y -fflags + genpts -i input.avi -acodec copy -vcodec copy ouput.mp4
Html浏览器
打开上述html文件播放声音,但没有显示视频。
当我使用其他.mp4文件时,视频成功显示,所以我确定我面临转换问题。
不是:我尝试了很多其他ffmpeg选项,但没有成功。
任何想法? / p>
提前感谢
你的命令是流复制(重新复制)MPEG-4 Part 2视频转换为MP4容器,但这种格式可能无法由浏览器播放。您应该使用H.264视频代替MP4容器:
ffmpeg -i input.avi -c:v libx264< ..更多选项...> -c:libfaac \
-movflags + faststart output.mp4
-movflags + faststart
将允许视频在查看器完全下载文件之前开始播放。
请注意,您可以指定多种替代媒体资源兼容:
< video width =640height =480controls>
< source src =/ path / to / output.mp4type =video / mp4>
< source src =/ path / to / output.webmtype =video / webm>
< source src =/ path / to / output.ogvtype =video / ogg>
...
< / video>
另见:
I'm running a debian 7.5 machine with ffmpeg-2.2 installed following these instructions
Issue
I'm trying to display a mp4 video inside my browser. The original file has an AVI container format. I can successfully convert it to mp4 and the targetfile is readable (video + sound) with the totem movie player. So I thought everything would be OK displaying the bellow page
HTML5 web page
<!DOCTYPE html><html>
<head>
<title>Webcam</title>
</head>
<body>
<video width="640" height="480" controls>
<source src="/path/to/output.mp4" type="video/mp4">
<h3>Your browser does not support the video tag</h3>
</video>
</body></html>
Input probe
$ ffprobe -show_streams input.avi
Duration: 00:08:22.90, start: 0.000000, bitrate: 1943 kb/s
Stream #0:0: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 64 kb/s
Stream #0:1: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 720x540 [SAR 1:1 DAR 4:3], 1870 kb/s, 29.97 fps, 25 tbr, 29.97 tbn, 25 tbc
Convert
$ ffmpeg -y -fflags +genpts -i input.avi -acodec copy -vcodec copy ouput.mp4
Html browser
Opening the above html file plays sound but no video is displayed.
When I use other .mp4 files, videos succesfully displayed so I'm sure I face a conversion issue.
Not : I've tryed a lot of other ffmpeg options but without success.
Any idea ?
Thanks in advance.
Your command was stream copying (re-muxing) MPEG-4 Part 2 video into MP4 container, but this format is probably not playable by the browser. You should use H.264 video instead for MP4 container:
ffmpeg -i input.avi -c:v libx264 <... more options ...> -c:a libfaac \
-movflags +faststart output.mp4
-movflags +faststart
will allow the video to begin playback before the file is completely downloaded by the viewer.
Note that you can specify multiple alternative media resources for compatibility:
<video width="640" height="480" controls>
<source src="/path/to/output.mp4" type="video/mp4">
<source src="/path/to/output.webm" type="video/webm">
<source src="/path/to/output.ogv" type="video/ogg">
...
</video>
Also see:
这篇关于AVI到MP4 - ffmpeg转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!