audio - 无法使用 png 和 mp3 音频生成 mp4

标签 audio video ffmpeg mp4

我完全不喜欢 FFMPEG。
我正在尝试通过合并 mp3 和 png 图像来生成 mp4 视频文件。

当我尝试将 png 图像转换为 mp4 时,它可以工作

ffmpeg -r 1/5.544000 -i 1.png -qscale 2 1.mp4

但是当我添加 mp3 音频文件时它会失败
ffmpeg -r 1/5.544000 -i 1.png -i 1.mp3 -qscale 2 1.mp4

以下是我得到的错误:
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.

[libx264 @ 0x1475be0] using SAR=1/1

[libx264 @ 0x1475be0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2

`[libx264 @ 0x1475be0] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-`bit

[libx264 @ 0x1475be0] 264 - core 142 r2431 a5831aa - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00

[aac @ 0x1476660] The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it.

我尝试使用 -strict -2但它仍然失败。

命令有什么问题?如何使用 mp3 和 png 创建 mp4?

最佳答案

循环图像,使用 AAC 音频,使用 yuv420p 像素格式:

ffmpeg -loop 1 -framerate 25 -i image.png -i audio.mp3 -c:a aac \
-vf format=yuv420p -movflags +faststart -shortest output.mp4

其他建议:
  • 如果您的设备不喜欢 H.264 High profile 添加 -profile:v main输出选项。
  • 如果你想要一个非常低的帧率(低于 5 fps)然后调整 -framerate选择您想要的值,然后添加 -r具有正常值的输出选项,例如 -r 25 .
  • 有些播放器不喜欢 MP4 中的 MP3 音频,所以这就是使用 AAC 的原因。
  • 宽度和高度必须能被 2 整除,所以如果你得到 not divisible by 2错误见 FFMPEG (libx264) “height/width not divisible by 2” .
  • FFmpeg Wiki: H.264更多选择。
  • 关于audio - 无法使用 png 和 mp3 音频生成 mp4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33322354/

    相关文章:

    c - 使用 FFT 代替卷积实现的低通滤波器

    actionscript-3 - ActionScript混响算法

    c# - Windows Server 2008 R2-无法创建AAC文件

    ubuntu - 初学者使用 ffmpeg 将 YUV 文件转换为 .mp4

    video - ffmpeg 删除 mp4 文件中的一部分音频,但不是全部

    opencv - FFmpeg 将输出更改为特定的像素格式?

    c++ - 将音频从输入直接馈送到输出,听起来很干净 c++

    javascript - 多个视频的播放/暂停功能

    ffmpeg - 使用ffmpeg提取帧分数范围内的I帧

    ffmpeg - 每次我尝试运行代码时,AVI INFO 都会使 Octave GUI 崩溃