Using libavcodec to encode at 15fps

Status
Not open for further replies.

chennes

Ars Scholae Palatinae
701
Subscriptor++
I'm trying to use libavcodec to encode a video at 15fps. On the command line ffmpeg seems perfectly content to do this, and passing the -pixfmt yuv420p option gives me a video with good video player compatibility. I can't figure out how to make this work in code, however. I'm basing mine on the encoding_decoding.c example. If I simply change the frame rate in that example (setting tb to 1/15), the encoder complains that the timebase isn't supported. If I switch from the MPEG1 encoder to H.264 it appears to encode, but I don't get a playable video (even VLC just gives a black screen).

I've tried blindly setting a bunch of H.264 options I found on Stack Overflow:
Code:
c->pix_fmt = AV_PIX_FMT_YUV420P;
c->bit_rate = 500*1000;
c->bit_rate_tolerance = 0;
c->rc_max_rate = 0;
c->rc_buffer_size = 0;
c->gop_size = 40;
c->max_b_frames = 3;
c->b_frame_strategy = 1;
c->coder_type = 1;
c->me_cmp = 1;
c->me_range = 16;
c->qmin = 10;
c->qmax = 51;
c->scenechange_threshold = 40;
c->flags |= CODEC_FLAG_LOOP_FILTER;
c->me_method = ME_HEX;
c->me_subpel_quality = 5;
c->i_quant_factor = float(0.71);
c->qcompress = float(0.6);
c->max_qdiff = 4;

ETA: I've also tried removing all the settings and letting the
Code:
av_opt_set(c->priv_data, "preset", "slow", 0);
set whatever it wants (I still have to set pix_fmt, tb, width, and height, but that's it).

This didn't appear to affect anything. Does anyone have a set of libavcodec codec settings that result in a file that plays in Windows Media Player and VLC at 15 fps?
 
Status
Not open for further replies.