FFMPEG write 函数

本文介绍了使用FFMPEG进行视频编码的详细步骤,包括初始化输出上下文、添加流、打开编解码器、初始化帧、写入头部信息、编码视频帧、写入交织帧及尾部信息等关键环节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

FFMPEG write 函数:

ffmpeg write:

int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat, const char *format_name, const char *filename);

//add stream
AVCodec *avcodec_find_encoder(enum AVCodecID id);
AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c);
int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);

//open video
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
AVFrame *avcodec_alloc_frame(void);
     //int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);

//open out put file
avio_open(AVIOContext **s, const char *url, int flags);

int avformat_write_header(AVFormatContext *s, AVDictionary **options);

//write video
void av_init_packet(AVPacket *pkt);
int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr);
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);

//write tail
int av_write_trailer(AVFormatContext *s);

//close
int avio_close(AVIOContext *s);
avcodec_close
av_free


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值