FFMPEG 视频到 MP4 的转换适用于除 iOS Safari/Chrome 之外的任何地方 [英] FFMPEG video conversion to MP4 works everywhere except in iOS Safari/Chrome

查看:41
本文介绍了FFMPEG 视频到 MP4 的转换适用于除 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

推荐答案

  1. 你的 ffmpeg 很古老.下载编译一个新版本.
  2. 删除 -strict Experimental(只有真正的旧版本才需要).
  3. 添加 -movflags +faststart 以便它可以更快地开始播放.
  4. 添加 -vf format=yuv420p 以获得兼容的像素格式.
  5. 输出 AAC 音频 (-c:a aac) 而不是 MP3 (-c:a libmp3lame).
  6. 如果仍然失败,可能是因为设备不支持 High profile.添加-profile:v main.如果您的设备支持 High profile,则无需添加此项.
  1. Your ffmpeg is ancient. Download or compile a new version.
  2. Remove -strict experimental (that's only needed for really old builds).
  3. Add -movflags +faststart so it can begin playback faster.
  4. Add -vf format=yuv420p for a compatible pixel format.
  5. Output AAC audio (-c:a aac) instead of MP3 (-c:a libmp3lame).
  6. 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屋!

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