FFMPEG 视频到 MP4 的转换适用于除 iOS Safari/Chrome 之外的任何地方 [英] FFMPEG video conversion to MP4 works everywhere except in iOS Safari/Chrome
问题描述
我使用以下代码使用 FFMPEG 库将 .webm
视频转换为 .mp4
:
I use the following code to convert .webm
videos to .mp4
using the FFMPEG library:
ffmpeg -i video.webm -vcodec h264 -acodec aac -strict experimental video.mp4
这在 Windows (Chrome/Firefox)、Mac (Safari/Chrome)、Android (Chrome) 中播放转换后的视频时完美无缺,但在通过 iOS (Safari/Chrome) 观看时不起作用.
This works flawless when playing the converted video in Windows (Chrome/Firefox), Mac (Safari/Chrome), Android (Chrome) but it does not work when watching through iOS (Safari/Chrome).
起初我以为这可能是 mp4
的问题?但是后来我在我的 iOS Safari 中播放没有任何问题这个视频 https://www.w3schools.com/html/mov_bbb.mp4 这也是一个 mp4
.
At first I thought it might be an mp4
problem? But then I played without any problems in my iOS Safari this video https://www.w3schools.com/html/mov_bbb.mp4 which is also a mp4
.
所以这告诉我转换有些不对劲.
So this tells me that something is not quite right about the conversion.
我在转换中遗漏了什么?
What am I missing in the conversion?
来自 PuTTy 的日志:https://pastebin.com/VLSPL0nC
Log from PuTTy: https://pastebin.com/VLSPL0nC
推荐答案
- 你的
ffmpeg
很古老.下载 或 编译一个新版本. - 删除
-strict Experimental
(只有真正的旧版本才需要). - 添加
-movflags +faststart
以便它可以更快地开始播放. - 添加
-vf format=yuv420p
以获得兼容的像素格式. - 输出 AAC 音频 (
-c:a aac
) 而不是 MP3 (-c:a libmp3lame
). - 如果仍然失败,可能是因为设备不支持 High profile.添加
-profile:v main
.如果您的设备支持 High profile,则无需添加此项.
- Your
ffmpeg
is ancient. Download or compile a new version. - Remove
-strict experimental
(that's only needed for really old builds). - Add
-movflags +faststart
so it can begin playback faster. - Add
-vf format=yuv420p
for a compatible pixel format. - Output AAC audio (
-c:a aac
) instead of MP3 (-c:a libmp3lame
). - If it still fails it may be due to the device not supporting High profile. Add
-profile:v main
. You don't need to add this if your device supports High profile.
示例:
ffmpeg -i input -c:v libx264 -profile:v main -vf format=yuv420p -c:a aac -movflags +faststart output.mp4
请参阅目标设备的规格以确定适当的
-profile:v
(可能还有-level
).有关详细信息,请参阅 FFmpeg Wiki:H.264.
See FFmpeg Wiki: H.264 for more info.
这篇关于FFMPEG 视频到 MP4 的转换适用于除 iOS Safari/Chrome 之外的任何地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!