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

Bha*_*bhi 2 audio video mp4 ffmpeg

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

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

ffmpeg -r 1/5.544000 -i 1.png -qscale 2 1.mp4
Run Code Online (Sandbox Code Playgroud)

但是当我添加 mp3 音频文件时它失败了

ffmpeg -r 1/5.544000 -i 1.png -i 1.mp3 -qscale 2 1.mp4
Run Code Online (Sandbox Code Playgroud)

以下是我得到的错误:

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.
Run Code Online (Sandbox Code Playgroud)

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

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

llo*_*gan 5

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

\n\n
ffmpeg -loop 1 -framerate 25 -i image.png -i audio.mp3 -c:a aac \\\n-vf format=yuv420p -movflags +faststart -shortest output.mp4\n
Run Code Online (Sandbox Code Playgroud)\n\n

其他建议:

\n\n
    \n
  • 如果您的设备不喜欢 H.264 High profile,请添加-profile:v main输出选项。
  • \n
  • 如果您想要非常低的帧速率(低于 5 fps),请将该-framerate选项调整为您想要的值,然后添加-r具有正常值的输出选项,例如-r 25
  • \n
  • 有些播放器不喜欢 MP4 中的 MP3 音频,因此使用 AAC 来代替。
  • \n
  • 宽度和高度必须能被 2 整除,因此如果出现not divisible by 2错误,请参阅FFMPEG (libx264) \xe2\x80\x9cheight/width not divisible by 2\xe2\x80\x9d
  • \n
  • 请参阅FFmpeg Wiki:H.264了解更多选项。
  • \n
\n