androidffmpeg(android ffmpeg硬编码)
本篇文章给大家谈谈androidffmpeg,以及android ffmpeg硬编码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、如何在Android用FFmpeg解码图像
- 2、如何在Android用FFmpeg+SDL2.0解码显示图像
- 3、android ffmpeg 是啥意思
- 4、Android FFmage 修改视频分辨率,帧率,区域裁剪
- 5、如何在Android上集成ffmpeg
- 6、如何用Android NDK编译FFmpeg
如何在Android用FFmpeg解码图像
CC libavcodec/log2_tab.o
CC libavutil/log2_tab.o
CC libswresample/log2_tab.o
AR libavcodec/libavcodec.a
LD libavutil/libavutil.so.52
AR libavutil/libavutil.a
AR libswresample/libswresample.a
LD libavcodec/libavcodec.so.55
LD libswresample/libswresample.so.0
LD libswscale/libswscale.so.2
LD libavformat/libavformat.so.55
INSTALL libavformat/libavformat.a
INSTALL libavformat/libavformat.so
STRIP install-libavformat-shared
INSTALL libavcodec/libavcodec.a
INSTALL libavcodec/libavcodec.so
STRIP install-libavcodec-shared
INSTALL libswresample/libswresample.a
INSTALL libswresample/libswresample.so
STRIP install-libswresample-shared
INSTALL libswscale/libswscale.a
INSTALL libswscale/libswscale.so
STRIP install-libswscale-shared
INSTALL libavutil/libavutil.a
INSTALL libavutil/libavutil.so
STRIP install-libavutil-shared
INSTALL libavformat/avformat.h
INSTALL libavformat/avio.h
INSTALL libavformat/version.h
INSTALL libavformat/libavformat.pc
INSTALL libavcodec/avcodec.h
INSTALL libavcodec/avfft.h
INSTALL libavcodec/dxva2.h
INSTALL libavcodec/old_codec_ids.h
INSTALL libavcodec/vaapi.h
INSTALL libavcodec/vda.h
INSTALL libavcodec/vdpau.h
INSTALL libavcodec/version.h
INSTALL libavcodec/xvmc.h
INSTALL libavcodec/libavcodec.pc
INSTALL libswresample/swresample.h
INSTALL libswresample/version.h
INSTALL libswresample/libswresample.pc
INSTALL libswscale/swscale.h
INSTALL libswscale/version.h
INSTALL libswscale/libswscale.pc
INSTALL libavutil/adler32.h
INSTALL libavutil/aes.h
INSTALL libavutil/attributes.h
INSTALL libavutil/audio_fifo.h
INSTALL libavutil/audioconvert.h
INSTALL libavutil/avassert.h
INSTALL libavutil/avstring.h
INSTALL libavutil/avutil.h
INSTALL libavutil/base64.h
INSTALL libavutil/blowfish.h
INSTALL libavutil/bprint.h
INSTALL libavutil/bswap.h
INSTALL libavutil/buffer.h
INSTALL libavutil/channel_layout.h
INSTALL libavutil/common.h
INSTALL libavutil/cpu.h
INSTALL libavutil/crc.h
INSTALL libavutil/error.h
INSTALL libavutil/eval.h
INSTALL libavutil/fifo.h
INSTALL libavutil/file.h
INSTALL libavutil/frame.h
INSTALL libavutil/hmac.h
INSTALL libavutil/imgutils.h
INSTALL libavutil/intfloat.h
INSTALL libavutil/intfloat_readwrite.h
INSTALL libavutil/intreadwrite.h
INSTALL libavutil/lfg.h
INSTALL libavutil/log.h
INSTALL libavutil/mathematics.h
INSTALL libavutil/md5.h
INSTALL libavutil/mem.h
INSTALL libavutil/murmur3.h
INSTALL libavutil/dict.h
INSTALL libavutil/old_pix_fmts.h
INSTALL libavutil/opt.h
INSTALL libavutil/parseutils.h
INSTALL libavutil/pixdesc.h
INSTALL libavutil/pixfmt.h
INSTALL libavutil/random_seed.h
INSTALL libavutil/rational.h
INSTALL libavutil/ripemd.h
INSTALL libavutil/samplefmt.h
INSTALL libavutil/sha.h
INSTALL libavutil/sha512.h
INSTALL libavutil/time.h
INSTALL libavutil/timecode.h
INSTALL libavutil/timestamp.h
INSTALL libavutil/version.h
INSTALL libavutil/xtea.h
INSTALL libavutil/lzo.h
INSTALL libavutil/avconfig.h
INSTALL libavutil/libavutil.pc
link ffmpeg.
二、新建一个Android工程,在工程目录下新建一个jni文件夹,在文件夹下新建一个ffmpeg文件夹,用来放ffmpeg相关的头文件。在ffmpeg文件夹下新建Android.mk文件用来预先加载ffmpeg动态库。Android.mk文件内容如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
LOCAL_SRC_FILES := /path/to/build/output/libffmpeg.so
include $(PREBUILT_SHARED_LIBRARY)
三、在jni下新建Android.mk文件和Application.mk两个文件用来指定编译的顺序和编译的平台以及对应的cpu指令集。
Application.mk
APP_ABI := armeabi
APP_PLATFORM := android-9
Android.mk
include $(call all-subdir-makefiles)
四、编写JNI文件,用来绑定java文件与.c文件的交互,文件内容如下:
/*
* ffmpeg_jni.c
*
* Created on: Sep 1, 2014
* Author: clarck
*/
#include stdlib.h
#include string.h
#include stdio.h
#include jni.h
#include "../include/ffmpeg_logger.h"
#include "../include/ffmpeg.h"
// 指定要注册的类,对应完整的java类名
#define JNIREG_CLASS "com/clarck/android/ffmpeg/MainActivity"
JNIEXPORT void JNICALL native_setDataSource(JNIEnv *env, jclass classzz, jstring path) {
char *filepath = ffmpeg_jstringTostr(env, path);
ffmpeg_setDataSource(filepath);
}
//Java和JNI函数的绑定
static JNINativeMethod method_table[] = {
{ "setDataSource", "(Ljava/lang/String;)V", native_setDataSource }
};
//注册native方法到java中
static int registerNativeMethods(JNIEnv *env, const char *className,
JNINativeMethod *gMethods, int numMethods) {
jclass clazz;
clazz = (*env)-FindClass(env, className);
if (clazz == NULL) {
return JNI_FALSE;
}
if ((*env)-RegisterNatives(env, clazz, gMethods, numMethods) 0) {
return JNI_FALSE;
}
return JNI_TRUE;
}
//调用注册方法
int register_ndk_load(JNIEnv *env) {
return registerNativeMethods(env, JNIREG_CLASS, method_table,
(int) (sizeof(method_table) / sizeof(method_table[0])));
}
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *env = NULL;
jint result = -1;
if ((*vm)-GetEnv(vm, (void**)env, JNI_VERSION_1_6) != JNI_OK) {
return result;
}
register_ndk_load(env);
//返回JNI的版本
return JNI_VERSION_1_6;
}
五、编写ffmpeg调用函数,内容如下:
/*
* ffmpeg.c
*
* Created on: Sep 1, 2014
* Author: clarck
*/
#include jni.h
#include android/native_window_jni.h
#include "../include/ffmpeg.h"
#include "../include/ffmpeg_logger.h"
#include "../ffmpeg/include/libavcodec/avcodec.h"
#include "../ffmpeg/include/libavformat/avformat.h"
#include "../ffmpeg/include/libavutil/pixfmt.h"
#include "../ffmpeg/include/libswscale/swscale.h"
char* ffmpeg_jstringTostr(JNIEnv* env, jstring jstr) {
char* pStr = NULL;
jclass jstrObj = (*env)-FindClass(env, "java/lang/String");
jstring encode = (*env)-NewStringUTF(env, "utf-8");
jmethodID methodId = (*env)-GetMethodID(env, jstrObj, "getBytes",
"(Ljava/lang/String;)[B");
jbyteArray byteArray = (jbyteArray) (*env)-CallObjectMethod(env, jstr,
methodId, encode);
jsize strLen = (*env)-GetArrayLength(env, byteArray);
jbyte *jBuf = (*env)-GetByteArrayElements(env, byteArray, JNI_FALSE);
if (jBuf 0) {
pStr = (char*) malloc(strLen + 1);
if (!pStr) {
return NULL ;
}
memcpy(pStr, jBuf, strLen);
pStr[strLen] = 0;
}
(*env)-ReleaseByteArrayElements(env, byteArray, jBuf, 0);
return pStr;
}
void ffmpeg_setDataSource(char *file_path) {
LOGI("ffmpeg_setDataSource:%s", file_path);
AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame, *pFrameYUV;
AVPacket *packet;
uint8_t *out_buffer;
static struct SwsContext *img_convert_ctx;
int videoStream, i, numBytes;
int ret, got_picture;
av_register_all();
pFormatCtx = avformat_alloc_context();
if (avformat_open_input(pFormatCtx, file_path, NULL, NULL) != 0) {
LOGE("can‘t open the file. \n");
return;
}
if (avformat_find_stream_info(pFormatCtx, NULL) 0) {
LOGE("Could‘t find stream infomation.\n");
return;
}
videoStream = 1;
for (i = 0; i pFormatCtx-nb_streams; i++) {
if (pFormatCtx-streams[i]-codec-codec_type == AVMEDIA_TYPE_VIDEO) {
videoStream = i;
}
}
if (videoStream == -1) {
LOGE("Didn‘t find a video stream.\n");
return;
}
pCodecCtx = pFormatCtx-streams[videoStream]-codec;
pCodec = avcodec_find_decoder(pCodecCtx-codec_id);
if (pCodec == NULL) {
LOGE("Codec not found.\n");
return;
}
if (avcodec_open2(pCodecCtx, pCodec, NULL) 0) {
LOGE("Could not open codec.\n");
return;
}
pFrame = av_frame_alloc();
pFrameYUV = av_frame_alloc();
numBytes = avpicture_get_size(AV_PIX_FMT_YUV420P, pCodecCtx-width,
pCodecCtx-height);
out_buffer = (uint8_t *) av_malloc(numBytes * sizeof(uint8_t));
avpicture_fill((AVPicture *) pFrameYUV, out_buffer, AV_PIX_FMT_YUV420P,
pCodecCtx-width, pCodecCtx-height);
int y_size = pCodecCtx-width * pCodecCtx-height;
packet = (AVPacket *) malloc(sizeof(AVPacket));
av_new_packet(packet, y_size);
av_dump_format(pFormatCtx, 0, file_path, 0);
while (av_read_frame(pFormatCtx, packet) = 0) {
if (packet-stream_index == videoStream) {
ret = avcodec_decode_video2(pCodecCtx, pFrame, got_picture,
packet);
LOGI("avcodec_decode_video2 ret:%d", ret);
if (ret 0) {
LOGE("decode error.\n");
return;
}
if (got_picture) {
//TODO 此处可以将解码出来的图片保存起来。
}
}
av_free_packet(packet);
}
av_free(out_buffer);
av_free(pFrameYUV);
avcodec_close(pCodecCtx);
avformat_close_input(pFormatCtx);
}
六、编写Android.mk用来编译相关的.c文件,内容如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
FFMPEG_PATH := ../ffmpeg
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(FFMPEG_PATH)/include
LOCAL_MODULE := ffmpeg_player
LOCAL_SRC_FILES += ffmpeg_jni.c
LOCAL_SRC_FILES += ffmpeg.c
LOCAL_SHARED_LIBRARIES := ffmpeg
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
七、编写java文件中相关执行调用方法
package com.clarck.android.ffmpeg;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setDataSource("/sdcard/a.mp4");
}
public native void setDataSource(String path);
static {
System.loadLibrary("ffmpeg");
System.loadLibrary("ffmpeg_player");
}
}
如何在Android用FFmpeg+SDL2.0解码显示图像
创建一个VideoPicture结构体用来保存解码出来的图像。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* SDL_Lesson.c
*
* Created on: Aug 12, 2014
* Author: clarck
*/
#include jni.h
#include android/native_window_jni.h
#include "SDL.h"
#include "SDL_thread.h"
#include "SDL_events.h"
#include "../include/logger.h"
#include "../ffmpeg/include/libavcodec/avcodec.h"
#include "../ffmpeg/include/libavformat/avformat.h"
#include "../ffmpeg/include/libavutil/pixfmt.h"
#include "../ffmpeg/include/libswscale/swscale.h"
#include "../ffmpeg/include/libswresample/swresample.h"
#define SDL_AUDIO_BUFFER_SIZE 1024
#define MAX_AUDIO_SIZE (5 * 16 * 1024)
#define MAX_VIDEO_SIZE (5 * 256 * 1024)
#define FF_ALLOC_EVENT (SDL_USEREVENT)
#define FF_REFRESH_EVENT (SDL_USEREVENT + 1)
#define FF_QUIT_EVENT (SDL_USEREVENT + 2)
#define VIDEO_PICTURE_QUEUE_SIZE 1
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
typedef struct PacketQueue {
AVPacketList *first_pkt, *last_pkt;
int nb_packets;
int size;
SDL_mutex *mutex;
SDL_cond *cond;
} PacketQueue;
typedef struct VideoPicture {
SDL_Window *screen;
SDL_Renderer *renderer;
SDL_Texture *bmp;
AVFrame* rawdata;
int width, height; /*source height width*/
int allocated;
} VideoPicture;
typedef struct VideoState {
char filename[1024];
AVFormatContext *ic;
int videoStream, audioStream;
AVStream *audio_st;
AVFrame *audio_frame;
PacketQueue audioq;
unsigned int audio_buf_size;
unsigned int audio_buf_index;
AVPacket audio_pkt;
uint8_t *audio_pkt_data;
int audio_pkt_size;
uint8_t *audio_buf;
DECLARE_ALIGNED(16,uint8_t,audio_buf2) [AVCODEC_MAX_AUDIO_FRAME_SIZE * 4];
enum AVSampleFormat audio_src_fmt;
enum AVSampleFormat audio_tgt_fmt;
int audio_src_channels;
int audio_tgt_channels;
int64_t audio_src_channel_layout;
int64_t audio_tgt_channel_layout;
int audio_src_freq;
int audio_tgt_freq;
struct SwrContext *swr_ctx;
AVStream *video_st;
PacketQueue videoq;
VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];
int pictq_size, pictq_rindex, pictq_windex;
SDL_mutex *pictq_mutex;
SDL_cond *pictq_cond;
SDL_Thread *parse_tid;
SDL_Thread *audio_tid;
SDL_Thread *video_tid;
AVIOContext *io_ctx;
struct SwsContext *sws_ctx;
int quit;
} VideoState;
VideoState *global_video_state;
[img]android ffmpeg 是啥意思
FFmpeg是一闭信套可以用来记录、转换数腔态判字音伍改频、视频,并能将其转化为流的开源计算机程序。
用来开发音视频的~!
Android FFmage 修改视频分辨率,帧率,区域裁剪
String ffmpeg ="-y -i " +filePath +" -strict -2 -vcodec libx264 -preset ultrafast -crf 24 -acodec aac -ar 44100 -ac 2 -b:a 96k -s " + (int)(videoWidth /bili) +"x" + (int)(videoHeight /bili) +" -aspect 5:3 "+savePath;
filePath = 原视频地址
(int)(videoWidth /bili) +"x" + (int)(videoHeight /bili) = 分辨率(1080 * 1920)
5:3 = 分辨率比例
savePath = 保存地址
详细参轮灶数参考 = ;locationNum=3
"ffmpeg -i " + filePath +" -r 25 -strict -2 -vcodec libx264 -preset ultrafast -acodec aac -ar 44100 -ac 2 -b:a 96k " +frameFilePath;
25 = 帧率
String ffmpeg = "ffmpeg -i " + filePath + " -strict -2 -vf crop=" + (int)(videoWidth / bili) + ":" + (int)(videoHeight / bili) + ":0:0 -preset fast " + savePath;
(int)(videoWidth / bili) + ":" + (int)(videoHeight / bili) = 裁剪的尺寸,分辨率
:0:0 = 从什么位置开始裁剪 x y 不输入从0.0开始
String[] commands = ffmpeg.split(" ");
RxFFmpegInvoke.getInstance().runCommandRxJava(commands).subscribe(new RxFFmpegSubscriber() {
@Override
public void onFinish() {
Log.i(TAG,"onFinish: ");
}
@Override
public void onProgress(int progress,long progressTime) {
Log.i(TAG,"onProgress: ");
}
@Override
尺宴 public void onCancel() {
Log.i(TAG,"onCancel: ");
}
@Override
public void onError(String message) {
Log.i(TAG,"onError: "+message);
}
});
需要先导入FFmpge项目 github上一大堆。
文档用于记录ffmpge使用方法,因本人初次使用陵桐银,指令意思都不了解,方法找了很久才找到。
以上功能已经再项目中使用
如何在Android上集成ffmpeg
下面把具体编译步骤描述如下,假定NDK安装在~/android-ndk-r7:
1. 首先从FFmpeg官网下载最新的腊消release版迟局姿本源码ffmpeg-0.11.tar.gz解压缩到Android源码树的ffmpeg/下。
2 准备一个编译脚本build_android.sh并放在ffmpeg/下面,这个脚本也是Rockplayer提供的,需做一些修改,其内容附在后面。我目前用的也会附在后面。
3 在ffmpeg目录下运行./build_android.sh开始编译FFmpeg,编译好的libffmpeg.so会放在文件夹android里面,一共有3个版本分别对应3种ARM体系结构,包括armv7-a、armv7-a-vfp、armv6_vfp,根据所运行的硬件平台选取其中一个版本。为了编译使用FFmpeg的程序时可以方便地找到libffmpeg.so,可将它复制到$OUT/system/lib/和$OUT/obj/lib/,当然这一步也可以加在build_android.sh中做。
4. 接下来就是码绝编译可执行文件ffmpeg了,这个工具可以在命令行下完成FFmpeg提供的几乎所有功能包括编码、解码、转码等,也是用来调试和验证很有用的工具。其实上述编译完后在$ANDROID_BUILD_TOP/external/ffmpeg/下也会生成ffmpeg,但是在设备上无法运行。为了编出能在设备上运行的ffmpeg,可以写一个简单的Android.mk,
如何用Android NDK编译FFmpeg
Android NDK编译FFmpeg
配置编拦乱译环境
在 VirtualBox 中创建一个 Ubuntu 虚拟机
在 Ubuntu 虚拟机中使用 sudo passwd root 命令启动 root 账户
用 root 账户登录进入 Ubuntu
将 android-ndk-r4b-linux-x86.zip 中的内容解压缩到 /root 目录下
将 android-sdk_r07-linux_x86.tgz 中闭樱的内容解压缩到 /root 目录下
将 ffmpeg-0.6.1.tar.bz2 中的内容解压缩到 /root/ffmpeg/jni 目录下
三、准备编译 FFmpeg
编写 mk 文件
在简态档 /root/ffmpeg/jni 目录中创建一个 Android.mk 文件,内容如下
?1include $(all-subdir-makefiles)
在 /root/ffmpeg/jni/ffmpeg-0.6.1 目录中创建一个 Android.mk 文件,内容如下
6LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_WHOLE_STATIC_LIBRARIES := libavformat libavcodec libavutil
libpostproc libswscale
LOCAL_MODULE := ffmpeg
include $(BUILD_SHARED_LIBRARY)
include $(call all-makefiles-under,$(LOCAL_PATH))
在 /root/ffmpeg/jni/ffmpeg-0.6.1 目录中创建一个 av.mk 文件,内容如下
# LOCAL_PATH is one of libavutil, libavcodec, libavformat, or
libswscale
#include $(LOCAL_PATH)/../config-$(TARGET_ARCH).mak
include $(LOCAL_PATH)/../config.mak
OBJS :=
OBJS-yes :=
MMX-OBJS-yes :=
include $(LOCAL_PATH)/Makefile
# collect objects
OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes)
OBJS += $(OBJS-yes)
FFNAME := lib$(NAME)
FFLIBS := $(foreach,NAME,$(FFLIBS),lib$(NAME))
FFCFLAGS = -DHAVE_AV_CONFIG_H -Wno-sign-compare -Wno-switch
-Wno-pointer-sign
FFCFLAGS += -DTARGET_CONFIG=/"config-$(TARGET_ARCH).h/"
ALL_S_FILES := $(wildcard $(LOCAL_PATH)/$(TARGET_ARCH)/*.S)
ALL_S_FILES := $(addprefix $(TARGET_ARCH)/, $(notdir $(ALL_S_FILES)))
ifneq ($(ALL_S_FILES),)
ALL_S_OBJS := $(patsubst %.S,%.o,$(ALL_S_FILES))
C_OBJS := $(filter-out $(ALL_S_OBJS),$(OBJS))
S_OBJS := $(filter $(ALL_S_OBJS),$(OBJS))
else
C_OBJS := $(OBJS)
S_OBJS :=
endif
C_FILES := $(patsubst %.o,%.c,$(C_OBJS))
S_FILES := $(patsubst %.o,%.S,$(S_OBJS))
FFFILES := $(sort $(S_FILES)) $(sort $(C_FILES))
在 /root/ffmpeg/jni/ffmpeg-0.6.1/libavcodec 目录中创建一个 Android.mk 文件,内容如下
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../av.mk
LOCAL_SRC_FILES := $(FFFILES)
LOCAL_C_INCLUDES := /
$(LOCAL_PATH) /
$(LOCAL_PATH)/..
LOCAL_CFLAGS += $(FFCFLAGS)
LOCAL_LDLIBS := -lz
LOCAL_STATIC_LIBRARIES := $(FFLIBS)
LOCAL_MODULE := $(FFNAME)
include $(BUILD_STATIC_LIBRARY)
在 /root/ffmpeg/jni/ffmpeg-0.6.1/libavformat 目录中创建一个 Android.mk 文件,内容如下
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../av.mk
LOCAL_SRC_FILES := $(FFFILES)
LOCAL_C_INCLUDES := /
$(LOCAL_PATH) /
$(LOCAL_PATH)/..
LOCAL_CFLAGS += $(FFCFLAGS)
LOCAL_CFLAGS += -include "string.h" -Dipv6mr_interface=ipv6mr_ifindex
LOCAL_LDLIBS := -lz
LOCAL_STATIC_LIBRARIES := $(FFLIBS)
LOCAL_MODULE := $(FFNAME)
include $(BUILD_STATIC_LIBRARY)
在 libavfilter、libavutil、libpostproc 和 libswscale 目录中各创建一个 Android.mk
文件,内容如下
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../av.mk
LOCAL_SRC_FILES := $(FFFILES)
LOCAL_C_INCLUDES := /
$(LOCAL_PATH) /
$(LOCAL_PATH)/..
LOCAL_CFLAGS += $(FFCFLAGS)
LOCAL_STATIC_LIBRARIES := $(FFLIBS)
LOCAL_MODULE := $(FFNAME)
include $(BUILD_STATIC_LIBRARY)
修改 libm.h 文件和 Makefile 文件
编辑 /root/ffmpeg/jni/ffmpeg-0.6.1/libavutil 目录中的 libm.h 文件,删除以下 static
方法
#if !HAVE_LRINT
static av_always_inline av_const long int lrint(double x)
{
return rint(x);
}
#endif /* HAVE_LRINT */
#if !HAVE_LRINTF
static av_always_inline av_const long int lrintf(float x)
{
return (int)(rint(x));
}
#endif /* HAVE_LRINTF */
#if !HAVE_ROUND
static av_always_inline av_const double round(double x)
{
return (x 0) ? floor(x + 0.5) : ceil(x - 0.5);
}
#endif /* HAVE_ROUND */
#if !HAVE_ROUNDF
static av_always_inline av_const float roundf(float x)
{
return (x 0) ? floor(x + 0.5) : ceil(x - 0.5);
}
#endif /* HAVE_ROUNDF */
#if !HAVE_TRUNCF
static av_always_inline av_const float truncf(float x)
{
return (x 0) ? floor(x) : ceil(x);
}
#endif /* HAVE_TRUNCF */
编辑 libavcodec、libavfilter、libavformat、libavutil、libpostproc 和 libswscale
目录中的 Makefile 文件,删除
?1include $(SUBDIR)../subdir.mak
和
?1include $(SUBDIR)../config.mak
生成 config.h 文件
在 /root/ffmpeg/jni/ffmpeg-0.6.1 目录中创建一个 config.sh 文件,使用 Android NDK r4b
编译时内容如下
#!/bin/bash
PREBUILT=/root/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.4.0
PLATFORM=/root/android-ndk-r4b/build/platforms/android-8/arch-arm
./configure --target-os=linux /
--arch=arm /
--enable-version3 /
--enable-gpl /
--enable-nonfree /
--disable-stripping /
--disable-ffmpeg /
--disable-ffplay /
--disable-ffserver /
--disable-ffprobe /
--disable-encoders /
--disable-muxers /
--disable-devices /
--disable-protocols /
--enable-protocol=file /
--enable-avfilter /
--disable-network /
--disable-mpegaudio-hp /
--disable-avdevice /
--enable-cross-compile /
--cc=$PREBUILT/bin/arm-eabi-gcc /
--cross-prefix=$PREBUILT/bin/arm-eabi- /
--nm=$PREBUILT/bin/arm-eabi-nm /
--extra-cflags="-fPIC -DANDROID" /
--disable-asm /
--enable-neon /
--enable-armv5te /
--extra-ldflags="-Wl,-T,$PREBUILT/arm-eabi/lib/ldscripts/armelf.x
-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib
$PREBUILT/lib/gcc/arm-eabi/4.4.0/crtbegin.o
$PREBUILT/lib/gcc/arm-eabi/4.4.0/crtend.o -lc -lm -ldl"
使用 Android NDK r5 编译时内容如下
#!/bin/bash
PREBUILT=/root/android-ndk-r5/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86
PLATFORM=/root/android-ndk-r5/platforms/android-8/arch-arm
./configure --target-os=linux /
--arch=arm /
--enable-version3 /
--enable-gpl /
--enable-nonfree /
--disable-stripping /
--disable-ffmpeg /
--disable-ffplay /
--disable-ffserver /
--disable-ffprobe /
--disable-encoders /
--disable-muxers /
--disable-devices /
--disable-protocols /
--enable-protocol=file /
--enable-avfilter /
--disable-network /
--disable-mpegaudio-hp /
--disable-avdevice /
--enable-cross-compile /
--cc=$PREBUILT/bin/arm-eabi-gcc /
--cross-prefix=$PREBUILT/bin/arm-eabi- /
--nm=$PREBUILT/bin/arm-eabi-nm /
--extra-cflags="-fPIC -DANDROID" /
--disable-asm /
--enable-neon /
--enable-armv5te /
--extra-ldflags="-Wl,-T,$PREBUILT/arm-eabi/lib/ldscripts/armelf.x
-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib
$PREBUILT/lib/gcc/arm-eabi/4.4.0/crtbegin.o
$PREBUILT/lib/gcc/arm-eabi/4.4.0/crtend.o -lc -lm -ldl"
打开终端,进入 /root/ffmpeg/jni/ffmpeg-0.6.1 目录,运行下面的命令
关于androidffmpeg和android ffmpeg硬编码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。