Capture and Transfer Video Frames

Encoding

I420 (YUV), RGB24: http://blog.csdn.net/leixiaohua1020/article/details/12234821

1. I420        A frame in I420 (YUV 4:2:0) is size = width * height * 1.5Byte

                    I420 is YYYY…UUUUVVVV

                    NV21 is YYYY…UVUVUVUV (Maybe used in the deprecated Camera API)

                    YV12 IS YYYY…VVVVUUUU (Maybe used in the deprecated Camera API)

2. RGB24    A frame in RGB24 is size = width * height * 3Byte

Camera2 API

Usage

1. Official guide: https://developer.android.com/guide/topics/media/camera

2. Official samples

        a. https://github.com/googlesamples/android-Camera2Basic/

        b. https://github.com/googlesamples/android-Camera2Raw/

        c. https://github.com/googlesamples/android-Camera2Video/

Format

1. Image class: https://www.polarxiong.com/archives/Android-Image%E7%B1%BB%E6%B5%85%E6%9E%90-%E7%BB%93%E5%90%88YUV_420_888.html

2. YUV_420_888 to I420: https://www.polarxiong.com/archives/Android-YUV_420_888%E7%BC%96%E7%A0%81Image%E8%BD%AC%E6%8D%A2%E4%B8%BAI420%E5%92%8CNV21%E6%A0%BC%E5%BC%8Fbyte%E6%95%B0%E7%BB%84.html

Open Source Libs

1. libyuv

        It is used to rotate, crop and scale the captured video frames before transfer. The frames must be head-up no matter the phone orientation. The best order of image processing for downscaling the captured image is: scale -> crop -> rotate.

        Use Neon to optimize the libyuv when compiling, so that we can do parallel processing.

2. libtheora

        Use the unofficial libtheora 1.2 with neon optimization. Need to change the instruction “BLX” in lib/arm/armenquant.s to “BL” to avoid crush issue.

        1).    Get the tools:

                a.    sudo apt-get install autoconf

                b.    sudo apt-get install libtool

                c.    sudo apt-get install libogg-dev

        2).    set up the ndk build evn:

                a.    NDK=/build/toolchain/lin64/android-ndk-r12b

                b.    SYSROOT=$NDK/platforms/android-19/arch-arm (Use API Level 19 because the libogg and libtheora are too old to be compiled on newer platform)

                c.    PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64

        3).    Build the libogg:

                a.    ./autogen.sh --prefix=$HOME/tmp/libogg --host=arm-linux --enable-shared CC="$PREBUILT/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT" LDFLAGS="-Wl,-O2,--as-needed" CFLAGS="-march=armv7-a -mfpu=neon"

                b.    make install

        4).    Build the libtheora

                ARM compile options https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html

                Into Assambly: http://www.cnblogs.com/goodhacker/p/3206405.htmlhttp://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204ic/Cihfddaf.html

                a.    ./autogen.sh --prefix=$HOME/tmp/libtheora --host=arm-linux --disable-examples CC="$PREBUILT/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT" LDFLAGS="-Wl,-O2,-g,-L$HOME/tmp/libogg/lib" CPPFLAGS="-I$HOME/tmp/libogg/include" CFLAGS="-march=armv7-a -mfpu=neon -mthumb "

                b.    make install

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 3,236评论 0 3
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,878评论 0 10
  • “读你”音频朗读 我喜欢读书,时常以文人自居,有时觉得书就象我的一位至亲密友:它永不会抛弃我,不管我是老了还是丑了...
    焰归来阅读 486评论 3 6
  • 人生不相见,动如参与商。种红豆的,会结果。种相思的,无尽期..... 铁马金戈,相思成蛊......
    icechenzi阅读 274评论 0 1
  • 【学龄后】口号:温柔地坚持 孩子第一个30天目标:在洗手间刷牙,刷完牙马上洗脸 妈妈第一个30天目标:恢复与大宝的...
    zengl阅读 148评论 0 0

友情链接更多精彩内容