在 android 上使用 FFMPEG 将图像制作成视频无效

Make images to video using FFMPEG on android not working

我用 libx264 构建了 ffmpeg 2.5.4 并正在使用这些命令,但它们给出了错误...
在以前版本的 ffmpeg 上,它们工作正常...

这是我用来将图像转换为视频的命令

          String[] ffmpegCommand = {
                    "/data/data/uk.org.humanfocus.hfi/ffmpeg",
                    "-r",
                    Fps,
                    "-i",
                    Environment.getExternalStorageDirectory().getPath()
                            + "/HumanFocus/MarkerFrame/frame%05d.jpg",
                    "-qscale", "0",
                    mFilePathMarker };

这是我的 ffmpeg 日志

03-06 10:00:12.579: V/asd(10011): ***Input #0, image2, from '/storage/emulated/0/HumanFocus/MarkerFrame/frame%05d.jpg':***
03-06 10:00:12.579: V/asd(10011): ***  Duration: 00:00:02.32, start: 0.000000, bitrate: N/A***
03-06 10:00:12.584: V/asd(10011): ***    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1279x719 [SAR 1:1 DAR 1279:719], 25 fps, 25 tbr, 25 tbn, 25 tbc***
03-06 10:00:12.584: V/asd(10011): ***Please use -q:a or -q:v, -qscale is ambiguous***
03-06 10:00:12.589: V/asd(10011): ***No pixel format specified, yuvj420p for H.264 encoding chosen.***
03-06 10:00:12.589: V/asd(10011): ***Use -pix_fmt yuv420p for compatibility with outdated media players.***
03-06 10:00:12.594: V/asd(10011): ***[libx264 @ 0x52e80] width not divisible by 2 (1279x719)***
03-06 10:00:12.594: V/asd(10011): ***Output #0, mp4, to '/storage/emulated/0/HumanFocus/WPOvideos/TEMP/20150306050004.mp4':***
03-06 10:00:12.594: V/asd(10011): ***    Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, SAR 1:1 DAR 0:0, 11.40 fps***
03-06 10:00:12.594: V/asd(10011): ***    Metadata:***
03-06 10:00:12.594: V/asd(10011): ***      encoder         : Lavc56.13.100 libx264***
03-06 10:00:12.594: V/asd(10011): ***Stream mapping:***
03-06 10:00:12.594: V/asd(10011): ***  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))***
03-06 10:00:12.594: V/asd(10011): ***Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height***

请帮帮我...
问题出在哪里?

尝试一组宽度和高度可被 2 整除的图像。至少,这就是您的错误日志所说的尝试。

解决方案

改变这个:

scale=-1:576

为此:

scale=-2:576

为什么

这是控制台输出中的相关消息:

[libx264 @ 0x52e80] width not divisible by 2 (1279x719)

使用 libx264 编码时,输出使用 YUV 4:2:0 色度子采样,宽度和高度必须能被 2 整除。