I'm trying to get ffmpeg to encode several individual JPEG images into a video on Android. I've successfully built it for Android (see the configuration string at the end of this post).
I can encode an h.263+ video with randomly generated frame content, and ffmpeg otherwise appears to work well.
A similar question suggests that the following code should be sufficient to load an image into an AvFrame
:
// Make sure we have the codecs
av_register_all();
AVFormatContext *pFormatCtx;
int ret = av_open_input_file(&pFormatCtx, imageFileName, NULL, 0, NULL);
if (ret != 0) {
printf("Can't open image file '%s': code %d, %s",
imageFileName, ret, strerror(AVERROR(ret)));
}
The above returns the correct absolute file path and error:
Failed '/sdcard/DCIM/Camera/IMG083.jpg': code -1094995529, Unknown error: 1094995529
Incidentally, if I omit av_register_all()
, it returns with error 2.
I've compiled ffmpeg with the following arguments:
./configure --target-os=linux --prefix=$PREFIX --enable-cross-compile --extra-libs="-lgcc" --arch=arm --cc=$PREBUILT/bin/arm-linux-androideabi-gcc --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- --nm=$PREBUILT/bin/arm-linux-androideabi-nm --sysroot=$PLATFORM --extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " --enable-shared --enable-static --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" --disable-everything --enable-demuxer=mov --enable-demuxer=h264 --disable-ffplay --enable-protocol=file --enable-avformat --enable-avcodec --enable-decoder=mjpeg --enable-decoder=png --enable-parser=h264 --enable-encoder=h263 --enable-encoder=h263p --disable-network --enable-zlib --disable-avfilter --disable-avdevice
Any suggestions would be most welcome!