[英]Encode jpeg to H264 stream on Android (ffmpeg)
I have a bunch of jpeg images representing a video. 我有一堆代表视频的jpeg图像。 I need to encode the images in H264 format so I can stream it to a server (from android device).
我需要将图像编码为H264格式,以便可以将其流式传输到服务器(从android设备)。 I understand this can be done using ffmpeg library.
我了解可以使用ffmpeg库完成此操作。 I compiled ffmpeg to a .so file and now I'm trying to find out what methods to use and how...
我将ffmpeg编译为.so文件,现在我试图找出要使用的方法以及方法...
Anyone know how can I convert jpeg into H264 stream on Android using ffmpeg? 有人知道如何使用ffmpeg在Android上将jpeg转换为H264流吗? Any sample code will be appreciated :)
任何示例代码将不胜感激:)
Thanks! 谢谢! PB
PB
https://github.com/jhotovy/android-ffmpeg https://github.com/jhotovy/android-ffmpeg
ProjectTest in this project has android code that creates mp4 from collection of jpg's (video) and an mp3 (audio) 此项目中的ProjectTest具有可从jpg(视频)和mp3(音频)的集合中创建mp4的android代码
This project is forked from another project on git .. you can build it on linux following the instructions 该项目是从git上的另一个项目派生的。您可以按照说明在linux上构建它
I use the modified script to compile ffmpeg with android NDK r8 and ffmpeg 0.1.11. 我使用修改后的脚本用android NDK r8和ffmpeg 0.1.11编译ffmpeg。
#!/bin/bash
######################################################
# FFmpeg builds script for Android+ARM platform
#
# This script is released under term of
# CDDL (http://www.opensource.org/licenses/cddl1)
# Wrote by pinxue (~@gmail.com) from RockPlayer.com
# 2010-8 ~ 2011-4
# Modified by Jacx Wang jacxwang(@)gmail.com 2012-07
######################################################
NDK=/Users/jacxwang/app/android-ndk-r8
PLATFORM=/Users/jacxwang/app/android-ndk-r8/platforms/android-8/arch-arm
PREBUILT=/Users/jacxwang/app/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86
function build_one
{
./configure --target-os=linux \
--prefix=$PREFIX \
--enable-cross-compile \
--extra-libs="-lgcc" \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
--disable-shared \
--enable-static \
--extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
--enable-parsers \
--enable-encoders \
--enable-decoders \
--enable-muxers \
--enable-demuxers \
--enable-swscale \
--disable-ffplay \
--enable-ffprobe \
--enable-ffserver \
--enable-network \
--enable-indevs \
--disable-bsfs \
--disable-filters \
--enable-protocols \
--enable-asm \
--enable-gpl \
$ADDITIONAL_CONFIGURE_FLAG
#make clean
make -j3 install
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}
#arm v6
CPU=armv6
OPTIMIZE_CFLAGS="-marm -march=$CPU"
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
#build_one
#arm v7vfpv3
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one
#arm v7vfp
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
PREFIX=./android/$CPU-vfp
ADDITIONAL_CONFIGURE_FLAG=
build_one
#arm v6+vfp
CPU=armv6
OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU"
PREFIX=./android/${CPU}-vfp
ADDITIONAL_CONFIGURE_FLAG=
build_one
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.