c->width = 352;
c->height = 288;
/* frames per second */
- c->time_base = (AVRational){1,25};
+ c->time_base = (AVRational){1, 25};
+ c->framerate = (AVRational){25, 1};
+
- c->gop_size = 10; /* emit one intra frame every ten frames */
- c->max_b_frames=1;
+ /* emit one intra frame every ten frames
+ * check frame pict_type before passing frame
+ * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
+ * then gop_size is ignored and the output of encoder
+ * will always be I frame irrespective to gop_size
+ */
+ c->gop_size = 10;
+ c->max_b_frames = 1;
c->pix_fmt = AV_PIX_FMT_YUV420P;
+ if (codec->id == AV_CODEC_ID_H264)
+ av_opt_set(c->priv_data, "preset", "slow", 0);
+
/* open it */
if (avcodec_open2(c, codec, NULL) < 0) {
- fprintf(stderr, "could not open codec\n");
+ fprintf(stderr, "Could not open codec\n");
exit(1);
}