ios ffmpeg h264 decode

这篇博客详细介绍了在iOS平台上如何利用FFmpeg库进行H264视频流的解码和封装操作,重点讨论了相关步骤和技术要点。
摘要由CSDN通过智能技术生成

ios使用ffmpeg解码h264数据封装。

#import "FFMpegAVCDecoder.h"
#ifdef __cplusplus
extern "C" {
#endif
    
#include <libavutil/opt.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
    
#ifdef __cplusplus
};
#endif

@interface FFMpegAVCDecoder(){
    AVCodec *_videoCodec;
    AVCodecContext *_pCodecCtx;
    AVFrame *_pFrame;
    char* _yuvBuf;
}

@end

@implementation FFMpegAVCDecoder

-(int)initDecoder{
    
    av_register_all();
    
    /* find the video encoder */
    _videoCodec = avcodec_find_decoder(AV_CODEC_ID_H264);
    _pCodecCtx = avcodec_alloc_context3(_videoCodec);
    
    if (!_videoCodec)
        return -1;

    _pCodecCtx->time_base.num = 1;
    _pCodecCtx->frame_number = 1; //每包一个视频帧
    
    if(avcodec_open2(_pCodecCtx, _videoCodec,NULL) >= 0)
        _pFrame = av_frame_alloc();// Allocate vide
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值