我完全不喜欢 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
其他建议:
-profile:v main
输出选项。 -framerate
选择您想要的值,然后添加 -r
具有正常值的输出选项,例如 -r 25
. not divisible by 2
错误见 FFMPEG (libx264) “height/width not divisible by 2” . 关于audio - 无法使用 png 和 mp3 音频生成 mp4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33322354/