以下内容基于ffmpeg2.6.9
#include <jni.h>
#include <string>
#include <android/log.h>
extern "C" {
//编码
#include "libavcodec/avcodec.h"
//封装格式处理
#include "libavformat/avformat.h"
//像素处理
#include "libswscale/swscale.h"
#include "libswresample/swresample.h"
#include <unistd.h>
}
#define LOGE(FORMAT, ...) __android_log_print(ANDROID_LOG_ERROR,"Guo", FORMAT, ##__VA_ARGS__)
#define LOGI(FORMAT, ...) __android_log_print(ANDROID_LOG_INFO, "Guo", FORMAT, ##__VA_ARGS__)
extern "C"
JNIEXPORT void JNICALL
Java_com_hyhl_learning_ffmpegaudio_MainActivity_open(
JNIEnv *env,
jobject obj, jstring inputStr, jstring outputStr) {
const char *input = env->GetStringUTFChars(inputStr, JNI_FALSE);
const char *output = env->GetStringUTFChars(outputStr, JNI_FALSE);
//注册各大组件
av_register_all();
AVFormatContext * avFormatContext = avformat_alloc_context();
if (avformat