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;/开发者_StackOverflow社区/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 .
I guess that because 'non-strictly-monotonic PTS' warning, do you konw same situation?
For me also it returns 0 always. But encodes fine. I dont think there is an issue if it returns 0. In the avcodec.h, you can see this
"On error a negative value is returned, on success zero or the number * of bytes used from the output buffer."
精彩评论