FFmpeg control of the code rate

Source: Internet
Author: User

MEDIAXYZ is a research ffmpeg has three years of tall, these days have been tossing ffmpeg in the x264, is not know how to control the rate, the main parameter is too much, do not know how to set , Search on Google, this aspect of the introduction of 0, then find MEDIAXYZ Consult, these can be experience, very valuable!

The following is the chat with mediaxyz QQ record, only part, because QQ to delete the previous conversation, but basically the essence can be here. MEDIAXYZ 23:40:26 You said Qsable was C->global_quality, Leon. The setting rule for the 23:40:44BR value is 100kbps for 100*1024? MEDIAXYZ 23:41:07yesmediaxyz 23:41:26 have you noticed that FFmpegIt's 100*1000mediaxyz. 23:41:37 not 100*1024leon 23:41:28 Yes, Leon 23:42:13 I see this sentence: Qscale based on < value > Quality VBR, Take the value 0.01-255, the smaller the quality the better mediaxyz 23:42:30 and in the back of the processing is still/1000mediaxyz 23:42:43 Yes mediaxyz 23:42:51 the smaller the quality the better, the greater the bitrate Leon 23:42:55 the 0.01-255 range is too big! MEDIAXYZ 23:43:29 This is for fine control, actually no need mediaxyz 23:43:42 I test 0. 01-50 on it. mediaxyz 23:43:52 big picture. What's the role of Leon 23:43:55global_quality? MEDIAXYZ 23:44:18 Anyway, the foreigner always thought very thoughtful mediaxyz 23:44:35global_quality you said < value > Quality Leon 23:44:36 is the Qscale value I said? mediaxyz 23:45:01 Yes Leon 23:45:01 can this value be dynamically adjusted? MEDIAXYZ 23:45:56 I didn't try mediaxyz 23:46:07 follow FFmpegCall rules, not like Leon 23:46:32 as you speak, VBR sets the following values: C->flags |= codec_flag_qscale;c->rc_min_rate =min;c->rc_max_ Rate = Max;c->bit_rate = BR; BR is the average bitrate like this? MEDIAXYZ 23:47:06 Yes mediaxyz 23:47:51 that's it. Set the bit rateWill fluctuate between the Min,max mediaxyz 23:48:11 if SetQscale, the range of fluctuations is very large, mediaxyz 23:48:21c->rc_min_rate =min;c->rc_max_rate = max can not control Leon 23:48:27 see you, Leon. 23:48:29 There is also a frame rate problem, in the x264 encoding mode, I set the 5 frame, why does not work? Avrational Time_base;time_base.num = 1;time_base.den = 5;c->time_base= time_base;mediaxyz 23:49:05 are you in real time or transcoding? Leon 23:48:55 Real-time mediaxyz 23:49:23 transcoding no mediaxyz 23:49:27 real-time control mediaxyz 23:49:38 control method is to control the image capture frame rate incoming on the line mediaxyz 23:49:48 by x264 itself not Leon 23:49:42 Oh, understand! Leon 23:50:04 I was going to rely on FFmpegTo control, is not! MEDIAXYZ 23:51:12 Frame rate control is said: playback is the frame rate Leon 23:51:03 in FFmpeg, Time_base just plays a time stamp increment, and does not control frame rate, right! MEDIAXYZ 23:51:31 Whether you choose 5 or 10, the timestamp is followed by the playback SetMEDIAXYZ 23:52:11 playback, read the time stamp calculated according to 5 or 10 to set the playing time interval, this time only the role of Leon 23:53:21 if the input stream is 25 frames, and I set is 5, what will be the consequences? Does my test result here have any effect? MEDIAXYZ 23:53:37 but FFmpeg the bit rateControl to x264 does not work mediaxyz 23:53:53 not Leon 23:54:02 FFmpeg the bit rateControl doesn't work for x264? According to the previous setting, we can't control x264. the bit rate? MEDIAXYZ 23:54:30 If it is captured in real time, the capture program discards MEDIAXYZ 23:54:42 I've tested this for mediaxyz 23:55:07, and I wanted to write a FFmpegExperience, there is no time Leon 23:55:10 if it is captured in real time, then the capture program is discarded? How to understand? MEDIAXYZ 23:56:09 The Capture program has a cache that is automatically discarded if the data in the cache has not been emptied to a specific time mediaxyz 23:56:23DIRECTSHOW,VFW is like that, Leon. 23:56:16 I now want to pass the real-time acquisition of video, with x264 encoding, using VBR, is that you said before a few parameter settings, can play a role? MEDIAXYZ 23:56:57 then you'd better take the second way Leon 23:57:01 is: c->flags |= codec_flag_qscale;c->rc_min_rate =min;c->rc_max_ Rate = Max;c->bit_rate = br;mediaxyz 23:57:29 wrong mediaxyz 23:57:32 is the first mediaxyz 23:57:34 (2006-04-16 23:30:54)   MEDIAXYZ (17328860) c->bit_rate = br;                C->rc_min_rate =br;&nbsp ;               c->rc_max_rate = br;              & nbsp C->bit_rate_tolerance = br;                c->rc_buffer_size=br;  &nbs P             c->rc_initial_buffer_occupancy = c->rc_buffer_size*3/4;    & nbsp           c->rc_buffer_aggressivity= (float) 1.0;                c->rc_initial_cplx= 0.5; Leon 23:57:29why? MEDIAXYZ 23:57:56 The first kind of fluctuation is too big mediaxyz 23:58:09 said to be confused, sorry mediaxyz 23:58:14 the second fluctuation is too great Leon 23:59:20 but the fluctuation is too big and its benefits, when the picture is still, the code flow is very small, Activity, the code flow came up, is this it? MEDIAXYZ 23:59:49 Yes mediaxyz 23:59:58 if it's on the internet, it's going to be a terrible situation. Leon 00:00:12 I think: transmission on the network, this situation should be more appropriate mediaxyz 00:00:32 "code stream just come up", It's probably going to be very big. MEDIAXYZ 00:00:52 Yes, more appropriate, if very large, how to do? Leon 00:01:24 very big? Not through c->rc_max_rate = max; Can you control its maximum bitrate? MEDIAXYZ 00:02:15 I just said, theoretically it is, but FFmpegActually not implemented MEDIAXYZ 00:02:19 FFmpegThe disadvantage of Leon 00:02:21max is the maximum load I expected the network to carry. Leon 00:02:31 Oh, come on! MEDIAXYZ 00:03:02 FFmpegIn the h263,h263p than MPEG4 to control the good mediaxyz 00:03:07x264 worse mediaxyz 00:04:39 Sleep, another day to talk about Leon 00:04:32 but at the same rate, x264 video quality is better than others, Comparison of delicate. However, its coding efficiency is not high. MEDIAXYZ 00:05:13windows's x264 has been very good. Leon 00:05:18 If you don't mind, I will send the contents of today to the forum, it is your experience!  MEDIAXYZ 00:05:54 don't matter Leon 00:05:46 good night! concluded that: FFmpegIn CBR (fixed bit rate control) Set: C->bit_rate = BR;                C->rc_min_rate =BR;                C->rc_max_rate = BR;                C->bit_rate_tolerance = BR;                c->rc_buffer_size=br;                C->rc_initial_buffer_occupancy = c->rc_buffer_size*3/4;                c->rc_buffer_aggressivity= (float) 1.0; c->rc_initial_cplx= 0.5; FFmpegMedium VBR (variable rate control) Set: C->flags |= Codec_flag_qscale;                C->rc_min_rate =min;                C->rc_max_rate = max; C->bit_rate = BR; Just after the experiment, we can draw the following conclusions: FFmpegThe CBR can be very well controlled, very close to the set value BR FFmpegVBR control is very bad, maximum stream Max does not limit the mediaxyz to speak exactly.  Thank mediaxyz for giving such invaluable experience. I have a cursory look at the dialogue content I can certainly say: more than 80% of the content is wrong, the standard fraught! Codec_flag_qscale: Fixed quantization, no relationship to VBR! Specifically how to use you to see the members of the Mpegenccontext: Fixed_qscale, and Avframe in the quality will know in fact FFmpegThe VBR and CBR are poorly controlled but from the experimental data, FFmpegCBR really control the good, I set the value is 50kbps, the actual test value of average 49.7kbps, Encoder Deviceis X264,CIF format, 5fps.  VBR has not yet found a good solution, fastreaming you can put your VBR set value parameters to discuss. I according to the landlord said CBR and VBR Set, br=12*1000 and br=10*1000 test, after the encoded data in seconds to calculate the average, the result is almost, do not know what is wrong, the test code is as follows: In_c->time_base.den = 25;        In_c->time_base.num = 1;        {         bitrate=12000;  &nbs P  in_c->bit_rate = bitrate;     in_c->rc_min_rate =bitrate;    &NBSP;IN_C-&GT;RC_ Max_rate = bitrate;     in_c->bit_rate_tolerance = bitrate;     in_c->rc_buffer_ size=bitrate;     in_c->rc_initial_buffer_occupancy = in_c->rc_buffer_size*3/4;     in_c->rc_buffer_aggressivity= (float) 1.0;     in_c->rc_initial_cplx= 0.5;       }        in_c->bit_rate=2000;//bitrate/100;  //12*1000K/S, low code stream. The larger the value, the better the video quality, and the lower the value the smaller the stream. Mpegenccontext.qscale---quantization parameters.         in_c->gop_size = 10; /* Emit one intra frame every ten frames */        in_c->max_b_frames=0;//TwoThe maximum number of B frames between a non-B frame.        in_c->flags        IN_C-&GT;PIX_FMT = pix_fmt_yuv420p;   I test x264 cbr, found that Qcomp = 0, it is easy to VBV buffer underflow, but added, found that the control is very good, and did not appear VBV buffer underflow, what is the purpose of this qcomp. '-qcomp compression ' video Quantizer scale compression (VBR) (default 0.5). Constant of Ratecontrol equation. Recommended range for default rc_eq:0.0-1.0 who can tell, what's the impact on video quality? One effect currently found is CPU (P6100) 100% .... 1fps I use the command: FFmpeg-I d:\\test_video\\hd\\js.mpg-bufsize 1835008-maxrate 6000000-minrate 6000000-b 6000000-packetsize 2048-muxrate 1008 0000-vcodec Libxavs D:\\test_video\\6kbps.mpg

FFmpeg control of the code rate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.