ffmpeg - 使用 FFMPEG 将 mp4 转换为最大移动支持的 MP4

标签 ffmpeg h.264

我想使用ffmpeg转换mp4至“小尺寸”mp4 ...

我需要一个mp4文件 h263视频和aac音频(或低成本移动设备支持的一些其他设置。)我主要担心的是视频可以在大多数设备上播放。

有什么可能的ffmpeg命令来完成这个?

提前致谢。

最佳答案

对 mp4 视频进行编码的方法有很多种,而针对移动设备进行编码则更加复杂。我不确定您所说的“低成本移动”是什么意思,您是指设备中的低成本,还是播放所述视频所需的带宽?

无论如何,这里有一篇文章可以帮助您继续:H.264 WEB VIDEO ENCODING TUTORIAL WITH FFMPEG

示例

以下是帖子中的一些 ffmpeg 示例...

“Standard” web video (480p at 500kbit/s):

ffmpeg -i input_file.avi -vcodec libx264 -vprofile high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -acodec libvo_aacenc -b:a 128k output_file.mp4

360p video for older mobile phones (360p at 250kbit/s in baseline profile):

ffmpeg -i inputfile.avi -vcodec libx264 -vprofile baseline -preset slow -b:v 250k -maxrate 250k -bufsize 500k -vf scale=-1:360 -threads 0 -acodec libvo_aacenc -ab 96k output.mp4

480p video for iPads and tablets (480p at 400kbit/s in main profile):

ffmpeg -i inputfile.avi -vcodec libx264 -vprofile main -preset slow -b:v 400k -maxrate 400k -bufsize 800k -vf scale=-1:480 -threads 0 -acodec libvo_aacenc -ab 128k output.mp4

High-quality SD video for archive/storage (PAL at 1Mbit/s in high profile):

ffmpeg -i inputfile.avi -vcodec libx264 -vprofile high -preset slower -b:v 1000k -vf scale=-1:576 -threads 0 -acodec libvo_aacenc -ab 196k output.mp4

比特率、规模和配置文件...

从那里的示例中,您可能需要注意的一些关键事项是......

-b:v 500k

-b:a 128k

这些是视频 v 和音频 a 的比特率,数字越低,质量越低,但在低端设备上“播放”的效果也越好.

比例=-1:480

这会将视频缩小到较小的尺寸,请参阅帖子中的更多信息)

-vprofile 基线

这个看似奇怪的基线(或另一个适当的 profile parameter )在为某些低成本(例如 Android)设备进行编码时可能很重要......

Baseline Profile (BP)

Primarily for low-cost applications that require additional data loss robustness, this profile is used in some videoconferencing and mobile applications. This profile includes all features that are supported in the Constrained Baseline Profile, plus three additional features that can be used for loss robustness (or for other purposes such as low-delay multi-point video stream compositing). The importance of this profile has faded somewhat since the definition of the Constrained Baseline Profile in 2009. All Constrained Baseline Profile bitstreams are also considered to be Baseline Profile bitstreams, as these two profiles share the same profile identifier code value.

关于ffmpeg - 使用 FFMPEG 将 mp4 转换为最大移动支持的 MP4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13560852/

相关文章:

ffmpeg - libx264 和 h264_nvenc 有什么区别?

iOS 兼容的实时 mp4 流

python - ffmpeg:加载共享库时出错:libmp3lame.so.0:无法打开共享对象文件:没有这样的文件或目录

c - h264 全局 header

image - 图像中的额外数据 (PPM/PAM/PNM)

android - 如何将android的相机设置为ffmpeg的输入

ffmpeg - 使用 qp 将 YUV 编码为 mP4 以获得最高质量

h.264 - AR Drone 2.0、Gstreamer、C++ RTMP Server(无需SDK推流)

opencv - 使用 OpenCV : ffmpeg? 打开 avi 文件

ffmpeg - 合并视频文件后如何设置文件名(批处理脚本,FFMPEG)