[作为自己备份代码使用,尚未优化]
#include "MyFilterVideo.h"
#define __STDC_CONSTANT_MACROS
#include "MyEncodeYUV.h"
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/avfiltergraph.h>
#include <libavfilter/avcodec.h>
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>
#include <libavutil/eval.h>
#include <libavutil/display.h>
#include "MyMuxerToMP4.h"
#include "MyDecodAudioToAac.h"
#define ENABLE_YUVFILE 1
//add by nil 旋转角度
#define MT_VIDEO_ROTATE_0 0
#define MT_VIDEO_ROTATE_90 90
#define MT_VIDEO_ROTATE_180 180
#define MT_VIDEO_ROTATE_270 270
const char *filter_descr = "movie=my_logo.png[wm];[in][wm]overlay=5:5[out]";
AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx;
AVFilterContext *buffersink_ctx;
AVFilterContext *buffersrc_ctx;
AVFilterGraph *filter_graph;
//add by nil
AVDictionary *format_opts = NULL;
//=======
static int video_stream_index = -1;
static int64_t last_pts = AV_NOPTS_VALUE;
int frameCount=0;//一个多少帧
int getRotateAngle(AVStream* avStream)
{
AVDictionaryEntry *tag = NULL;
int m_Rotate=-1;
tag = av_dict_get(avStream->metadata, "rotate", tag, 0);
if (tag==NULL)
{
m_Rotate = 0;
}
else
{
int angle = atoi(tag->value);
angle %= 360;
if (angle == 90)
{
m_Rotate = MT_VIDEO_ROTATE_90;
}
else if (angle == 180)
{
m_Rotate = MT_VIDEO_ROTATE_180;
}
else if (angle == 270)
{
m_Rotate = MT_VIDEO_ROTATE_270;
}
else
{
m_Rotate = MT_VIDEO_ROTATE_0;
}
}
return m_Rotate;
}