#include
#include
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "libavutil/log.h"
#ifdef ANDROID
#include
#include
#define LOGE(format, ...) __android_log_print(ANDROID_LOG_ERROR, "(>_
#define LOGI(format, ...) __android_log_print(ANDROID_LOG_INFO, "(=_=)", format, ##__VA_ARGS__)
#else
#define LOGE(format, ...) printf("(>_
#define LOGI(format, ...) printf("(^_^) " format " ", ##__VA_ARGS__)
#endif
AVFormatContext *ofmt_ctx;
AVStream* video_st;
AVCodecContext* pCodecCtx;
AVCodec* pCodec;
AVPacket enc_pkt;
AVFrame *pFrameYUV;
int framecnt = 0;
int yuv_width;
int yuv_height;
int y_length;
int uv_length;
int64_t start_time;
//Output FFmpeg's av_log()
void custom_log(void *ptr, int level, const char* fmt, va_list vl){
FILE *fp=fopen("/storage/emulated/0/av_log.txt","a+");
if(fp){
vfprintf(fp,fmt,vl);
fflush(fp);
fclose(fp);
}
}
JNIEXPORT jint JNICALL Java_com_zhanghui_test_MainActivity_initial
(JNIEnv *env, jobject obj,jint width,jint height)
{