调用ffmpeg从Mp4中分离出H264文件并且保存,ffmpeg的API调用如下:
#include <stdio.h>
#include "libavutil/log.h"
#include "libavformat/avio.h"
#include "libavformat/avformat.h"
int main(int argc, char **argv)
{
AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
AVOutputFormat *output_fmt = NULL;
const char *in, *out;
int stream_index, errnum;
AVStream *o_stream = NULL, *i_stream = NULL;
AVIOContext *pb = NULL;
AVPacket pkt;
int qstride, qp_type;
// av_register_all();
av_log_set_level(AV_LOG_INFO);
//avcodecInfo();
if (argc != 3) {
av_log(NULL, AV_LOG_ERROR, "usage : a.out <in> <out>\n");
goto __failed__;
}
in = argv[1];
out = argv[2];
/********打开多媒体文件*******/
if ((errnum = avformat_open_input