您当前的位置: 首页 > 

染指流年灬

暂无认证

  • 2浏览

    0关注

    194博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

ffmpeg各种函数详解

染指流年灬 发布时间:2022-05-18 21:38:16 ,浏览量:2

ffmpeg基本流程图

基本流程图,实际使用情况要复杂一些

在这里插入图片描述

av_register_all()

包含头文件:#include “libavformat/avformat.h” 作用:初始化 libavformat和注册所有的muxers、demuxers和protocols。基本所有的ffmpeg第一步都是它。

avformat_open_input()

作用:打开对应的文件 原函数:avformat_open_input(AVFormatContext **ps, const char *filename,AVInputFormat *fmt, AVDictionary **options)

AVFormatContext **ps:一般是avformat_alloc_context()申请的一个空间指针地址,类似于文件描述符,然后通过操作文件描述符来操作你打开的文件。

const char *filename:就是你要打开的文件名。

AVInputFormat *fmt:一般都写成NULL.

AVDictionary **options:附加选项写为NULL.

使用方法:

if (avformat_open_input(&pFormatCtx,url,NULL,NULL)!=0){
		printf("Couldn't open input stream.\n");
		return -1;
	}


int avformat_find_stream_info()

作用: 寻找对应的流信息。 原函数: int avformat_find_stream_info(AVFormatContext *ic, AVDictionary ** options)

AVFormatContext *ic: 文件描述符

AVDictionary **options : 附加选项写为NULL.

使用方法:

	if(av_find_stream_info(pFormatCtx)codec_id);
	if (pCodec == NULL) {
		printf("Codec not found.\n");
		return -1;
	}
	

avcodec_open2()

作用: 该函数用于初始化一个视音频编解码器的AVCodecContext。 原函数: int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);

AVCodecContext *avctx: 获取指向音频流的编解码器上下文的指针 const AVCodec *codec: 编码器名称 AVDictionary **options:附加选项写为NULL. 使用方法:

if (avcodec_open2(pCodecCtx, pCodec, NULL) = 0)
 {

}


avcodec_decode_video2()

作用: 该函数的作用是实现压缩视频的解码。 原函数: int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt);

AVCodecContext *avctx:文件描述符 AVFrame *picture:输出参数 int *got_picture_ptr:该值为0表明没有图像可以解码,否则表明有图像可以解码 const AVPacket *avpkt:输入参数,包含待解码数据。

关注
打赏
1665909078
查看更多评论
立即登录/注册

微信扫码登录

0.0427s