[英]ffmpeg +libx264 iPhone -> 'avcodec_encode_video' return always 0 . please advice
av_register_all();
AVCodec *codec;
AVCodecContext *c= NULL;
int out_size, size, outbuf_size;
//FILE *f;
uint8_t *outbuf;
printf("Video encoding\n");
/* find the mpeg video encoder */
codec =avcodec_find_encoder(CODEC_ID_H264);//avcodec_find_encoder_by_name("libx264"); //avcodec_find_encoder(CODEC_ID_H264);//CODEC_ID_H264);
NSLog(@"codec = %i",codec);
if (!codec) {
fprintf(stderr, "codec not found\n");
exit(1);
}
c= avcodec_alloc_context();
/* put sample parameters */
c->bit_rate = 400000;
c->bit_rate_tolerance = 10;
c->me_method = 2;
/* resolution must be a multiple of two */
c->width = 352;//width;//352;
c->height = 288;//height;//288;
/* frames per second */
c->time_base= (AVRational){1,25};
c->gop_size = 10; /* emit one intra frame every ten frames */
//c->max_b_frames=1;
c->pix_fmt = PIX_FMT_YUV420P;
c ->me_range = 16;
c ->max_qdiff = 4;
c ->qmin = 10;
c ->qmax = 51;
c ->qcompress = 0.6f;
'avcodec_encode_video' is always 0. 'avcodec_encode_video' 始终为 0。
I guess that because 'non-strictly-monotonic PTS' warning, do you konw same situation?我猜是因为“非严格单调 PTS”警告,你知道同样的情况吗?
For me also it returns 0 always.对我来说,它也总是返回 0。 But encodes fine.
但编码很好。 I dont think there is an issue if it returns 0. In the avcodec.h, you can see this
如果它返回 0,我认为没有问题。在 avcodec.h 中,你可以看到这个
"On error a negative value is returned, on success zero or the number * of bytes used from the output buffer." “出错时返回负值,成功时返回零或 output 缓冲区中使用的字节数 *。”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.