[英]iPhone - A problem with decoding H264 using ffmpeg
我正在与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;
帧数据即将成功发送。
如何解决这个问题。
非常感谢。
看一下您的ffmpeg示例,在PATH / TO / FFMPEG / doc / example / decoder_encoder.c中,该链接如下:
http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/api-example_8c-source.html
请注意,此代码太旧,某些函数的名称已更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.