Reputation: 6958
I'm currently trying to use ffmpeg on Android. I built ffmpeg using https://github.com/halfninja/android-ffmpeg-x264 (I adapted it to not use libx264 and build with ndk-r9b, using GCC 4.6). I try to trim an MP4 file. However, the input file fails to open:
11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): ffmpeg 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): -i 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): /storage/emulated/0/DCIM/20131126_173903.mp4 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): -ss 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): 2 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): -t 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): 4 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): -vcodec 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): copy 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): -acodec 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): copy 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): /storage/emulated/0/DCIM/trimmed-000-20131126_173903.mp4 11-28 10:59:18.494: INFO/com.rfc.video.VideoKit(4125): Running main 11-28 10:59:18.494: INFO/Videokit(4125): Initializing AV codecs 11-28 10:59:18.494: INFO/Videokit(4125): ffmpeg version 0.9.2, Copyright (c) 2000-2012 the FFmpeg developers 11-28 10:59:18.494: INFO/Videokit(4125): built on Nov 27 2013 15:38:26 with gcc 4.6 20120106 (prerelease) 11-28 10:59:18.494: INFO/Videokit(4125): configuration: --enable-cross-compile --arch=arm5te --enable-armv5te --target-os=linux --disable-stripping --prefix=../output --disable-neon --enable-version3 --ar=arm-linux-androideabi-ar --disable-shared --enable-static --enable-gpl --enable-memalign-hack --cc=arm-linux-androideabi-gcc --ld=arm-linux-androideabi-ld --extra-cflags='-fPIC -DANDROID -D__thumb__ -mthumb -Wno-deprecated' --disable-everything --enable-decoder=mjpeg --enable-demuxer=mjpeg --enable-parser=mjpeg --enable-demuxer=image2 --enable-muxer=mp4 --enable-decoder=rawvideo --enable-protocol=file --enable-hwaccels --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-network --enable-filter=buffer --enable-filter=buffersink --disable-demuxer=v4l --disable-demuxer=v4l2 --disable-indev=v4l --disable-indev=v4l2 11-28 10:59:18.494: INFO/Videokit(4125): libavutil 51. 32. 0 / 51. 32. 0 11-28 10:59:18.494: INFO/Videokit(4125): libavcodec 53. 42. 4 / 53. 42. 4 11-28 10:59:18.494: INFO/Videokit(4125): libavformat 53. 24. 2 / 53. 24. 2 11-28 10:59:18.494: INFO/Videokit(4125): libavdevice 53. 4. 0 / 53. 4. 0 11-28 10:59:18.494: INFO/Videokit(4125): libavfilter 2. 53. 0 / 2. 53. 0 11-28 10:59:18.494: INFO/Videokit(4125): libswscale 2. 1. 0 / 2. 1. 0 11-28 10:59:18.494: INFO/Videokit(4125): libpostproc 51. 2. 0 / 51. 2. 0 11-28 10:59:18.504: ERROR/Videokit(4125): /storage/emulated/0/DCIM/20131126_173903.mp4: Invalid data found when processing input
I digged into ffmpeg's code, and found the error:
static int opt_input_file(OptionsContext *o, const char *opt, const char *filename)
{
// ...
ic->video_codec_id = video_codec_name ?
find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0)->id : CODEC_ID_NONE;
ic->audio_codec_id = audio_codec_name ?
find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0)->id : CODEC_ID_NONE;
ic->subtitle_codec_id= subtitle_codec_name ?
find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0)->id : CODEC_ID_NONE;
ic->flags |= AVFMT_FLAG_NONBLOCK;
ic->interrupt_callback = int_cb;
if (loop_input) {
LOGW(
"-loop_input is deprecated, use -loop 1\n"
"Note, both loop options only work with -f image2\n"
);
ic->loop_input = loop_input;
}
/* open the input file with generic avformat function */
err = avformat_open_input(&ic, filename, file_iformat, &format_opts);
if (err < 0) {
print_error(filename, err);
exit_program(1);
}
assert_avoptions(format_opts);
// ...
}
As indicated in the logcat, err
is here equal to AVERROR_INVALIDDATA
. I don't understand the reason however: the mp4 codec is enabled, as far as I can tell. Any hint on how to solve it?
Edit: I added more ffmpeg code. I'm pretty sure it's a codec issue now: ic->video_codec_id is set to CODEC_ID_NONE
, which causes ic
to be set to NULL
and return a failure in avformat_open_input()
.
Upvotes: 1
Views: 806
Reputation: 6958
It was effectively a codec issue. Recompiling ffmpeg with libx264 support fixed this.
Upvotes: 1