在预览时将过滤器应用于视频,并使用应用过滤器和原始音频保存在Android中

时间:2016-07-11 06:03:41

标签: android ffmpeg android-ndk video-processing

我是视频处理新手。我想在运行时将过滤器应用于视频,并且我想在过滤器应用后保存该视频。

对此,我正在做研究。我经历了很多图书馆,但我很难实现目标。

开发环境

Migw-64 with windows 7 64 bit
Android Studio 2.1 preview 5
heap space 4GB 
com.android.tools.build:gradle:2.1.0
android-ndk-r12-win-x86_64
com.android.tools.build:gradle-experimental:0.7.0  --> to build NDK

我试过

  1. AndroidFastImageprocessingLibrary

    Chrisbatt - > AndroidFastImageProcessing in github

    此库使用GLSurfaceview显示过滤器,但我们无法将其保存到mp4文件。

    所以我发现了它的另一个实现icmobilelab - > github中的AndroidFastImageProcessing

    这个库使用JavaCV和ffmpeg编译。但它失败了。

  2. JavaCV

    JavaCV使用过时的ffmpeg并将其放弃。

  3. Grafika - > on github

    我在grafika中使用RecordFBOActivity尝试了Android快速图像处理。但我失败了。该库使用MediaRecorder记录GLSurfaceView的内容。但它录制没有音频的视频(我已经测试了RecordFBOActivity并分析了代码)。

  4. 在platform_frameworks中过滤包

    github.com/android/platform_frameworks_base/blob/master/media/mca/filterpacks/java/android/filterpacks/videosink/MediaEncoderFilter.java 它的android 4.2编辑核心。我无法运行此代码,因为有太多的jni依赖项。

  5. 的ffmpeg

    github.com/guardianproject/android-ffmpeg 我尝试了由guardianproject实现的ffmpeg3.1编译程序。它成功构建了一个静态库,但我无法构建动态库(所以文件)。我遇到了链接器错误。我认为链接顺序很重要。我尝试了下面链接中指定的链接顺序 https://fritzone.wordpress.com/2010/05/11/link-with-static-ffmpeg/ 但它无济于事。发生以下错误

    [armeabi-v7a] SharedLibrary  : libffmpeg.so
    jni/ffmpeg.c:200: error: undefined reference to 'av_frame_alloc'
    jni/ffmpeg.c:201: error: undefined reference to 'av_frame_alloc'
    jni/ffmpeg.c:209: error: undefined reference to 'av_register_all'
    jni/ffmpeg.c:210: error: undefined reference to 'avfilter_register_all'
    jni/ffmpeg.c:45: error: undefined reference to 'avformat_open_input'
    jni/ffmpeg.c:50: error: undefined reference to 'avformat_find_stream_info'
    jni/ffmpeg.c:56: error: undefined reference to 'av_find_best_stream'
    jni/ffmpeg.c:63: error: undefined reference to 'av_opt_set_int'
    jni/ffmpeg.c:66: error: undefined reference to 'avcodec_open2'
    jni/ffmpeg.c:67: error: undefined reference to 'av_log'
    jni/ffmpeg.c:78: error: undefined reference to 'avfilter_get_by_name'
    jni/ffmpeg.c:79: error: undefined reference to 'avfilter_get_by_name'
    jni/ffmpeg.c:80: error: undefined reference to 'avfilter_inout_alloc'
    jni/ffmpeg.c:81: error: undefined reference to 'avfilter_inout_alloc'
    jni/ffmpeg.c:85: error: undefined reference to 'avfilter_graph_alloc'
    jni/ffmpeg.c:98: error: undefined reference to 'avfilter_graph_create_filter'
    jni/ffmpeg.c:106: error: undefined reference to 'avfilter_graph_create_filter'
    jni/ffmpeg.c:113: error: undefined reference to 'av_int_list_length_for_size'
    jni/ffmpeg.c:113: error: undefined reference to 'av_opt_set_bin'
    jni/ffmpeg.c:116: error: undefined reference to 'av_log'
    jni/ffmpeg.c:131: error: undefined reference to 'av_strdup'
    jni/ffmpeg.c:142: error: undefined reference to 'av_strdup'
    jni/ffmpeg.c:147: error: undefined reference to 'avfilter_graph_parse_ptr'
    jni/ffmpeg.c:151: error: undefined reference to 'avfilter_graph_config'
    jni/ffmpeg.c:155: error: undefined reference to 'avfilter_inout_free'
    jni/ffmpeg.c:156: error: undefined reference to 'avfilter_inout_free'
    jni/ffmpeg.c:218: error: undefined reference to 'av_read_frame'
    jni/ffmpeg.c:223: error: undefined reference to 'avcodec_decode_video2'
    jni/ffmpeg.c:230: error: undefined reference to 'av_frame_get_best_effort_timestamp'
    jni/ffmpeg.c:233: error: undefined reference to 'av_buffersrc_add_frame_flags'
    jni/ffmpeg.c:234: error: undefined reference to 'av_log'
    jni/ffmpeg.c:240: error: undefined reference to 'av_buffersink_get_frame'
    jni/ffmpeg.c:171: error: undefined reference to 'av_rescale_q'
    jni/ffmpeg.c:246: error: undefined reference to 'av_frame_unref'
    jni/ffmpeg.c:248: error: undefined reference to 'av_frame_unref'
    jni/ffmpeg.c:251: error: undefined reference to 'av_packet_unref'
    jni/ffmpeg.c:254: error: undefined reference to 'avfilter_graph_free'
    jni/ffmpeg.c:255: error: undefined reference to 'avcodec_close'
    jni/ffmpeg.c:256: error: undefined reference to 'avformat_close_input'
    jni/ffmpeg.c:257: error: undefined reference to 'av_frame_free'
    jni/ffmpeg.c:258: error: undefined reference to 'av_frame_free'
    jni/include/libavutil/error.h:111: error: undefined reference to 'av_strerror'
    collect2.exe: error: ld returned 1 exit status
    make: *** [obj/local/armeabi/libffmpeg.so] Error 1
  6. MediaCodec,MediaExtractor,MediaRecord,MediaMuxer

    最后,我计划将AndroidFastImageProcessing与MediaCodec,MediaExtractor,MediaRecord,MediaMuxer结合使用。

    所以我尝试使用mediamuxer从视频中提取音频 https://gist.github.com/sayan801/9a39ccad0818d2b3499a。 我使用mp4视频(MIME类型视频/ avc,有2个音轨和视频)来提取音频,但结果文件已损坏(仅4 kb)

  7. 我认为这个问题是对现有问题的另一种看法,如果有人遇到这个问题,请指导我。

0 个答案:

没有答案