2013-11-28 78 views
1

我目前正在尝试在Android上使用ffmpeg。我使用https://github.com/halfninja/android-ffmpeg-x264(我调整它不使用libx264并使用GCC 4.6编译ndk-r9b)构建ffmpeg。我尝试修剪MP4文件。但是,输入文件无法打开:Android上的ffmpeg解码器

 
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 

我挖成的ffmpeg的代码,并且发现错误:

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); 

// ... 

} 

正如logcat中指出,err在这里等于AVERROR_INVALIDDATA。我不明白其中的原因:据我所知,mp4编解码器已启用。有关如何解决它的任何提示?

编辑:我添加了更多的ffmpeg代码。我很确定这是一个编解码器问题:ic-> video_codec_id设置为CODEC_ID_NONE,这会导致ic设置为NULL,并在avformat_open_input()中返回失败。

回答

1

这实际上是一个编解码器问题。用libx264支持重新编译ffmpeg解决了这个问题。