【发布时间】:2011-08-24 23:58:45
【问题描述】:
我正在使用 ffmpeg 从服务器解码 H264 流。
我从http://github.com/dropcam/dropcam_for_iphone引用了DecoderWrapper。
编译成功了,不知道怎么用。
这是有问题的功能。
- (id)initWithCodec:(enum VideoCodecType)codecType
colorSpace:(enum VideoColorSpace)colorSpace
width:(int)width
height:(int)height
privateData:(NSData*)privateData {
if(self = [super init]) {
codec = avcodec_find_decoder(CODEC_ID_H264);
codecCtx = avcodec_alloc_context();
// Note: for H.264 RTSP streams, the width and height are usually not specified (width and height are 0).
// These fields will become filled in once the first frame is decoded and the SPS is processed.
codecCtx->width = width;
codecCtx->height = height;
codecCtx->extradata = av_malloc([privateData length]);
codecCtx->extradata_size = [privateData length];
[privateData getBytes:codecCtx->extradata length:codecCtx->extradata_size];
codecCtx->pix_fmt = PIX_FMT_YUV420P;
#ifdef SHOW_DEBUG_MV
codecCtx->debug_mv = 0xFF;
#endif
srcFrame = avcodec_alloc_frame();
dstFrame = avcodec_alloc_frame();
int res = avcodec_open(codecCtx, codec);
if (res < 0)
{
NSLog(@"Failed to initialize decoder");
}
}
return self;
}
这个函数的privateData参数是什么?不知道怎么设置参数...
现在 avcodec_decode_video2 返回 -1;
framedata 来成功了。
如何解决这个问题。
非常感谢。
【问题讨论】:
标签: iphone ffmpeg h.264 decoding