Showing results for 
Search instead for 
Did you mean: 

H264 frame rate

Hello all,
I am trying to encode in H264 baseline at real time.
I would like to produce H264 stream which is 25 fps, but up to now produced stream was always 15 fps.
I am calling GetFrame method of encoder 25 times per second. I am sure about this because I tested with JPEG and I can encode 25 JPEG picture per second.
Most probably I'm missing something in my parameters file.
So I have two questions related to this.
1) Can you provide me a parameter file with which I can encode at 25 fps?
Please note that output stream size is not so important, my first concern isminimumCPU usage without degrading input video quality.
I will be appreciated if you can give some hints related to parameters, which affects mostCPU usage andstream size.
2) Why there is 3 different frame_rate_code value for 30 fps?

BTW below is my problematic parameter file;
/* CommentLine: H.264 Sequence.*/
stream.yuv /* name of source files */
0 /* number of frames to encode */
1 20 0 /* 1(reserved) , N (# of frames in between I frames), IDR interval. */
0 1 /* Number of B frames between I (or P) and next P, treat B as a reference (only 0 is supported!) */
2 1 1 /* num_ref_frames (2-16), minimum length of list1 for backward prediction (only 1 is supported!), number of slices. */
66 0 /* profile_idc (77-main, 100-high); level_idc (set 0 for automatic selection) (check that num_ref_frames and frame size are in accordance with the level) */
720 /* horizontal_size */
576 /* vertical_size */
3 /* frame_rate_code [0,8] (0-30 fps,1-15 fps,2-24 fps,3-25 fps,4-30 fps,5-30 fps,6-50 fps,7-60 fps,8-60 fps)*/
1 8 8 /* High profile: chroma_format_idc (0 - monochrom, 1 - 420, 2 - 422), bit_depth_luma [8,12], bit_depth_chroma [8,12] */
0 8 0 0 0 /* High profile: aux_format_idc: [0,3], bit_depth_aux: [8,12], alpha_incr_flag: 0, 1; alpha_opaque_value: [0, 2^(bit_depth_aux + 9) -1]; alpha_transparent_value: [0, 2^(bit_depth_aux + 9) - 1] */
2 30 30 30 1000000 /* RC method(0 - quant_codes, 1 - CBR MBwise, 2 - CBR framewise, 3 - Debug); start qp values for I, P, B slices; bitrate (bits per second) */
2 2 12 12 /* ME method (1-6), subblock split, search x,search_y */
0 0 0 /* weighted prediction, weighted biprediction implicit weighted biprediction (not supported!)*/
1 1 /* direct type (0 - temporal 1 - spatial 2 - auto); direct_inference_flag */
0 0 0 /* disable_deblocking_idc: 1-- off, 0 - on, 2 -- on(without crossing slice boundaries); deblocking_filter_alpha, deblocking_filter_beta */
1 0 0 /* High profile: transform_8x8_mode: 0 -- off, 1 - on; 0 -- use standard, 1 -- use default scaling matrices for 8x8 quantization; qpprime_y_zero_transform_bypass_flag: (0, 1) */
720 /* display_horizontal_size */
576 /* display_vertical_size */
1 2 /* entropy coding mode (0-cavlc,1-cabac); cabac_init_idc (0,1,2) */
0 /* picture coding type (0 - only FRM, 1 - only FLD , 2 - only AFRM, 3 - pure PicAFF(no MBAFF) 4 PicAFF + MBAFF). Only 0 (FRM) is supported! */
3 1 /* speed/quality grade [0,3] (0-maximum speed, 3-maximum quality); OptimalQuantization (0, 1) */
0 Kudos
8 Replies

Hi Victor,
Please note first, that it is not real-time encoder. It means that there is no way to limit or control frame encoding duration. It can be considered as RT provided that there is significant performance reserve.
The next point. Talking about FPS, you, most probably, mean encoding performance, while in encoder it is considered as playback frame rate. If it is the case, you should increase the performace using encoder settings. Otherwise make sure that you didn't change the order and the quantiity of strings in par file.

Frame rate codes used correspond to some extent to mpeg2 codes, so there are few repetitions where mpeg2 uses 1.001 denominator for FR. 0 is default value.

To encrease performace try the following:
- RC method 0 followed by 3 values of quantizer to control the compression. Otherwise use higher bitrate, say 3M, unless you have close to static video.
- entropy coding mode CAVLC is faster than CABAC, but provides worse compression
- use 0 or 1 for speed/quality grade and 0 for OptimalQuantization to get performance

Good Luck!

Hello Leonid,
many thanks for reply.
Actually there is no CPU bottleneck since it is around 15% while encoding.
And I also checked encoderparams varaiable after reading par file and framerate member is 30 so par file is parsed correctly.
I'm saving encoded stream into file and than playing with simpleplayer.exe
And it says that stream is 15 FPS and rendering around 15 fps. No matter what value I stated it always says it is 15 fps.
And one more observation, I tried calculating frame rate during the encoding. I am calculating at every 50. encoded frame. (50/time elapsed since previous 50.) and I can see that 24.8 fps. But there is one more point, CPU is always around 15% but at some calculations(occuring periodically) fps becomes around 17
Any comments about this?

if I decrease fps to 5 from camera (input source) my calculation obviously shows that encoding rate decreases to 5 fps. So it seems that encoding frame rate depends on number of GetFrame function calls (if there is no performance bottleneck)
But why am I always seeing 15 fps when watching?
Can this 15 fps problem be related to stream header?

Hello Victor,
Most probably frame rate information is not present in the stream. timing_info_present_flag can be left unset. Try to set this flag to 1 in the code on initialization.
If you provide your encoded bitstream it would be easy to check if it is the case. Just few encoded frames.

Many thanks for your support Leonid.
Please find sample encoded stream attached.
If it is the case, any code samples to set timing_info_present_flagwill be appreciated.

One more update, I counted number of successfully decoded and encoded frames.
For example 1500 (25*60) frames are decoded and encoded in one minute.
But when playing encoded stream, it is still showing 15 fps.
One more question, normally I am decoding live stream with mpeg4 decoder provided in IPP but when I try to play same stream with simpleplayer.exe it says fps is 0.0 and shows nothing. However I am playing same stream after decoding and encoding into h.264

Any comments about this?
Many thanks.

did you have the chance to see video?
is there any update?
Many thanks,

Hi Victor, I've checked the stream. timing_info is really missed in SPS. VUI parameters are poorly supported in the sample.
Please try to add to the end of SetSequenceParameters() the following lines:
core_enc->m_SeqParamSet.vui_parameters.timing_info_present_flag = 1;
core_enc->m_SeqParamSet.vui_parameters.num_units_in_tick = 1;
core_enc->m_SeqParamSet.vui_parameters.time_scale = 2 * (Ipp32u)core_enc->;
core_enc->m_SeqParamSet.vui_parameters.fixed_frame_rate_flag = 1;

It should be enough.
Good Luck,


I am facing a similar issue.

I am trying to set encoder frame rate to 30 fps.

I tried your above comment to set vui parameters. Still I am getting a 15 fps output.

Adding a screenshot of SPS parameter on wireshark.

Can someone help me with this.