将FFMPEG视频转换为MP4的任何地方都可以使用,但iOS Safari/Chrome浏览器除外 [英] FFMPEG video conversion to MP4 works everywhere except in iOS Safari/Chrome

查看:90
本文介绍了将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.

我在转换中缺少什么?

从PuTTy登录: https://pastebin.com/VLSPL0nC

推荐答案

  1. 您的 ffmpeg 很古老.下载编译一个新版本.
  2. 删除-严格实验性(只有真正的旧版本才需要).
  3. 添加 -movflags + faststart ,以便可以更快地开始播放.
  4. 添加 -vf format = yuv420p 以获得兼容的像素格式.
  5. 输出AAC音频( -c:a aac )而不是MP3( -c:a libmp3lame ).
  6. 如果仍然失败,则可能是由于该设备不支持High profile.添加 -profile:v main .如果您的设备支持高级"配置,则无需添加此项.
  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天全站免登陆