在移动设备上捕获和处理视频流 - 从哪里开始?

时间:2013-11-06 10:02:13

标签: android ios video-streaming video-capture video-processing

我正处于新项目的最开始阶段。在深入了解细节之前,需要您的指导意见。

要求:

  1. 从设备的相机获取视频流,将其渲染为预览并保存以供进一步处理

  2. 对外部视频流(http://...m3u8

  3. 执行相同操作
  4. 从已保存的视频中提取一些帧,添加一些叠加层,合并回可播放的视频文件并在本地保存和/或发送到服务器

  5. 需要支持iOS和Android设备。

    问题:

    Q1。仅使用标准的iOS / Android框架,这一切都是可行的(并且有多难)? #2和#3的例子?谷歌的关键词?

    Q2。下注ffmpeg或其他什么更好?

    Q3。 MarmaladeMoSync会简化ffmpeg编译和使用吗?

    Q4。有什么建议吗?

    谢谢

1 个答案:

答案 0 :(得分:0)

对于Android,有一个NDK,试试这个 http://mobilepearls.com/labs/native-android-api/ndk/docs/openmaxal/index.html

对于iOS,您可以使用默认的MPMoviewPlayer来播放流

      NSURL *mediaURL = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
      MPMoviePlayerController *mediaPlayer = [[MPMoviePlayerController alloc] initWithContentURL:mediaURL];

对于自定义技巧,您需要使用ffmpeg, 这是一个在iOS下编译ffmpeg的脚本

export PLATFORM="iPhoneOS"
export MIN_VERSION="4.0"
export MAX_VERSION="5.0"
export DEVROOT=/Developer/Platforms/${PLATFORM}.platform/Developer
export SDKROOT=$DEVROOT/SDKs/${PLATFORM}${MAX_VERSION}.sdk
export CC=$DEVROOT/usr/bin/llvm-gcc
export LD=$DEVROOT/usr/bin/ld
export CPP=$DEVROOT/usr/bin/cpp
export CXX=$DEVROOT/usr/bin/llvm-g++
export AR=$DEVROOT/usr/bin/ar
export LIBTOOL=$DEVROOT/usr/bin/libtool
export NM=$DEVROOT/usr/bin/nm
export CXXCPP=$DEVROOT/usr/bin/cpp
export RANLIB=$DEVROOT/usr/bin/ranlib
COMMONFLAGS="-pipe -gdwarf-2 -no-cpp-precomp -isysroot ${SDKROOT} -marm -fPIC"
export LDFLAGS="${COMMONFLAGS} -fPIC"
export CFLAGS="${COMMONFLAGS} -fvisibility=hidden"
export CXXFLAGS="${COMMONFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden"

FFMPEG_LIBS="libavcodec libavdevice libavformat libavutil libswscale"

echo "Building armv6..."

make clean
./configure \
    --cpu=arm1176jzf-s \
    --extra-cflags='-arch armv6 -miphoneos-version-min=${MIN_VERSION} -mthumb' \
    --extra-ldflags='-arch armv6 -miphoneos-version-min=${MIN_VERSION}' \
    --enable-cross-compile \
    --arch=arm \
    --target-os=darwin \
    --cc=${CC} \
    --sysroot=${SDKROOT} \
    --prefix=installed \
    --disable-network \
    --disable-decoders \
    --disable-muxers \
    --disable-demuxers \
    --disable-devices \
    --disable-parsers \
    --disable-encoders \
    --disable-protocols \
    --disable-filters \
    --disable-bsfs \
    --enable-decoder=h264 \
    --enable-decoder=svq3 \
    --enable-gpl \
    --enable-pic \
    --disable-doc
perl -pi -e 's/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/' config.h
make -j3

mkdir -p build.armv6
for i in ${FFMPEG_LIBS}; do cp ./$i/$i.a ./build.armv6/; done

echo "Building armv7..."

make clean
./configure \
    --cpu=cortex-a8 \
    --extra-cflags='-arch armv7 -miphoneos-version-min=${MIN_VERSION} -mthumb' \
    --extra-ldflags='-arch armv7 -miphoneos-version-min=${MIN_VERSION}' \
    --enable-cross-compile \
    --arch=arm \
    --target-os=darwin \
    --cc=${CC} \
    --sysroot=${SDKROOT} \
    --prefix=installed \
    --disable-network \
    --disable-decoders \
    --disable-muxers \
    --disable-demuxers \
    --disable-devices \
    --disable-parsers \
    --disable-encoders \
    --disable-protocols \
    --disable-filters \
    --disable-bsfs \
    --enable-decoder=h264 \
    --enable-decoder=svq3 \
    --enable-gpl \
    --enable-pic \
    --disable-doc
perl -pi -e 's/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/' config.h
make -j3

mkdir -p build.armv7
for i in ${FFMPEG_LIBS}; do cp ./$i/$i.a ./build.armv7/; done

mkdir -p build.universal
for i in ${FFMPEG_LIBS}; do lipo -create ./build.armv7/$i.a ./build.armv6/$i.a -output ./build.universal/$i.a; done

for i in ${FFMPEG_LIBS}; do cp ./build.universal/$i.a ./$i/$i.a; done

make install

export PLATFORM="iPhoneOS" export MIN_VERSION="4.0" export MAX_VERSION="5.0" export DEVROOT=/Developer/Platforms/${PLATFORM}.platform/Developer export SDKROOT=$DEVROOT/SDKs/${PLATFORM}${MAX_VERSION}.sdk export CC=$DEVROOT/usr/bin/llvm-gcc export LD=$DEVROOT/usr/bin/ld export CPP=$DEVROOT/usr/bin/cpp export CXX=$DEVROOT/usr/bin/llvm-g++ export AR=$DEVROOT/usr/bin/ar export LIBTOOL=$DEVROOT/usr/bin/libtool export NM=$DEVROOT/usr/bin/nm export CXXCPP=$DEVROOT/usr/bin/cpp export RANLIB=$DEVROOT/usr/bin/ranlib COMMONFLAGS="-pipe -gdwarf-2 -no-cpp-precomp -isysroot ${SDKROOT} -marm -fPIC" export LDFLAGS="${COMMONFLAGS} -fPIC" export CFLAGS="${COMMONFLAGS} -fvisibility=hidden" export CXXFLAGS="${COMMONFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden" FFMPEG_LIBS="libavcodec libavdevice libavformat libavutil libswscale" echo "Building armv6..." make clean ./configure \ --cpu=arm1176jzf-s \ --extra-cflags='-arch armv6 -miphoneos-version-min=${MIN_VERSION} -mthumb' \ --extra-ldflags='-arch armv6 -miphoneos-version-min=${MIN_VERSION}' \ --enable-cross-compile \ --arch=arm \ --target-os=darwin \ --cc=${CC} \ --sysroot=${SDKROOT} \ --prefix=installed \ --disable-network \ --disable-decoders \ --disable-muxers \ --disable-demuxers \ --disable-devices \ --disable-parsers \ --disable-encoders \ --disable-protocols \ --disable-filters \ --disable-bsfs \ --enable-decoder=h264 \ --enable-decoder=svq3 \ --enable-gpl \ --enable-pic \ --disable-doc perl -pi -e 's/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/' config.h make -j3 mkdir -p build.armv6 for i in ${FFMPEG_LIBS}; do cp ./$i/$i.a ./build.armv6/; done echo "Building armv7..." make clean ./configure \ --cpu=cortex-a8 \ --extra-cflags='-arch armv7 -miphoneos-version-min=${MIN_VERSION} -mthumb' \ --extra-ldflags='-arch armv7 -miphoneos-version-min=${MIN_VERSION}' \ --enable-cross-compile \ --arch=arm \ --target-os=darwin \ --cc=${CC} \ --sysroot=${SDKROOT} \ --prefix=installed \ --disable-network \ --disable-decoders \ --disable-muxers \ --disable-demuxers \ --disable-devices \ --disable-parsers \ --disable-encoders \ --disable-protocols \ --disable-filters \ --disable-bsfs \ --enable-decoder=h264 \ --enable-decoder=svq3 \ --enable-gpl \ --enable-pic \ --disable-doc perl -pi -e 's/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/' config.h make -j3 mkdir -p build.armv7 for i in ${FFMPEG_LIBS}; do cp ./$i/$i.a ./build.armv7/; done mkdir -p build.universal for i in ${FFMPEG_LIBS}; do lipo -create ./build.armv7/$i.a ./build.armv6/$i.a -output ./build.universal/$i.a; done for i in ${FFMPEG_LIBS}; do cp ./build.universal/$i.a ./$i/$i.a; done make install

将此用于android ffmpeg http://bambuser.com/opensource