ffmpeg编解码的流程和主要使用的api有哪些

常用的结构体

  • AVCodec:编解码结构体
  • AVCodecContext:编解码上下文
  • AVFrame:解码后的帧

结构体的常用api

  • av_frame_alloc():生成AVFrame结构体的
  • av_frame_free():释放AVFrame结构体
  • avcodec_alloc_context3():生成编解码器上下文
  • avcodec_free_context:释放解码器上下文

解码的步骤

  1. 查找解码器:avcodec_find_decoder
  2. 打开解码器:avcodec_open2
  3. 解码:avcodec_decode_video2

H264的编码流程

  1. 查找解码器:avcodec_find_encoder_by_name
  2. 设置编码参数,并打开编码器:avcodec_open2
  3. 编码:avcodec_encode_video2
原文地址:https://www.cnblogs.com/fandx/p/12174411.html