ffmpeg 新老接口问题及对照集锦

来源:互联网 发布:医生都善良知乎 编辑:程序博客网 时间:2024/05/19 22:44
网上很多关于ffmpeg (libav)的资料都是N年以前的,而事实上ffmpeg数年来一直在“以时俱进”,因此无论是一些新手,或者号称为老手的人,有时候难免出头痛。。。。。。

为了解决大家的头痛的问题,特列一个贴子,把ffmpeg相关的一些常见的、版本的问题列举出来,供大家参考,同时也请大家一起补充。

1) 不认识guess_format.
解决:  #define guess_format  av_guess_format 
接口不变。

2) 不认识av_alloc_format_context
解决:  #define   av_alloc_format_context  avformat_alloc_output_context
接口调整。

3) 不认识CODEC_TYPE_VIDEO 和 CODEC_TYPE_AUDIO
解决:
#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO
#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO

4) 不认识audio_resample_init
解决:#define audio_resample_init av_audio_resample_init
接口调整。

5) avcodec_decode_video 到 avcodec_decode_video2接口调整
旧代码:
  1. len = avcodec_decode_video(c, (short *)outbuf, &out_size, inbuf_ptr, size);
新代码:
  1. av_init_packet(&pkt);
  2. pkt.data = (unsigned char*)inbuf_ptr;
  3. pkt.size = size;
  4. len = avcodec_decode_video2(c, &tmpFrame, &got_picture, &pkt);
6)url_fopen变成新的接口 avio_open
新版代码:
/**
 * Create and initialize a AVIOContext for accessing the
 * resource indicated by url.
 * @note When the resource indicated by url has been opened in
 * read+write mode, the AVIOContext can be used only for writing.
 *
 * @param s Used to return the pointer to the created AVIOContext.
 * In case of failure the pointed to value is set to NULL.
 * @param flags flags which control how the resource indicated by url
 * is to be opened
 * @return 0 in case of success, a negative value corresponding to an
 * AVERROR code in case of failure
 */
int avio_open(AVIOContext **s, const char *url, int flags);


7)av_write_header变成了avformat_write_header
新版代码:
/**
 * @addtogroup lavf_encoding
 * @{
 */
/**
 * Allocate the stream private data and write the stream header to
 * an output media file.
 *
 * @param s Media file handle, must be allocated with avformat_alloc_context().
 *          Its oformat field must be set to the desired output format;
 *          Its pb field must be set to an already openened AVIOContext.
 * @param options  An AVDictionary filled with AVFormatContext and muxer-private options.
 *                 On return this parameter will be destroyed and replaced with a dict containing
 *                 options that were not found. May be NULL.
 *
 * @return 0 on success, negative AVERROR on failure.
 *
 * @see av_opt_find, av_dict_set, avio_open, av_oformat_next.
 */
int avformat_write_header(AVFormatContext *s, AVDictionary **options);

8)旧版宏定义:PKT_FLAG_KEY     新版宏定义:AV_PKT_FLAG_KEY

持续更新中.....................
不全的地方,知道的给补上
http://blog.csdn.net/dgyanyong/article/details/32140119
0 0
原创粉丝点击