FFmpeg解析视频保存为yuv

[作为自己备份代码使用,尚未优化]


#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;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

了悟生死大事

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值