ffmpeg视频生成jpg图片截图(一)
实现目标:输入本地文件,实现截图生成jpeg图片到本地,功能点请看注释,注意:注释很重要。
//ffmpeg.h
#ifndef __FFMPEG_H__
#define __FFMPEG_H__
#include "info.h"
extern "C"
{
#include <libavutil/imgutils.h>
#include <libavformat/avformat.h>
#include "libavformat/avio.h"
#include "libavcodec/avcodec.h"
#include "libswscale/swscale.h"
#include "libavutil/avutil.h"
#include "libavutil/mathematics.h"
#include "libswresample/swresample.h"
#include "libavutil/opt.h"
#include "libavutil/channel_layout.h"
#include "libavutil/samplefmt.h"
#include "libavdevice/avdevice.h"
#include "libavfilter/avfilter.h"
#include "libavutil/error.h"
#include "libavutil/mathematics.h"
#include "libavutil/time.h"
#include "inttypes.h"
#include "stdint.h"
};
#pragma comment(lib,"avformat.lib")
#pragma comment(lib,"avcodec.lib")
#pragma comment(lib,"avdevice.lib")
#pragma comment(lib,"avfilter.lib")
#pragma comment(lib,"avutil.lib")
#pragma comment(lib,"postproc.lib")
#pragma comment(lib,"swresample.lib")
#pragma comment(lib,"swscale.lib")
#define INPUTURL "../flv/test.flv"
#define OUTFILEPATH "../jpg/"
extern AVFormatContext * m_in_format_ctx;
extern int video_stream_idx;
void initialize_all();
int init_input(char * filename,AVFormatContext ** in_format);
int open_codec_context(int *stream_idx, AVFormatContext ** in_format_ctx, enum AVMediaType type);
void uinit_input(AVFormatContext * in_format_ctx);
int read_frame(AVFormatContext * in_format,char * filepath);
int save_picture_init(AVFormatContext** out_format_ctx,AVStream * video_st,AVCodecContext* pCodecCtx,c