[Libav-user] Programmatically setting bit_rate ?
pjschneider at earthlink.net
Fri Nov 21 18:57:53 CET 2014
The source material: the 3D app has the ability to render a sequence of frames, with each frame being a raw RGBA image raster in memory (a C char pointer to a memory block of size width * height * 4 * sizeof(char)). To create the movie, some initial setup is done, and each frame is successively 3D-rendered in the app; the frame is then converted to yuv420p using sws_scale, and then encoded via avcodec_encode_video2, and appended to the movie file. Essentially we have a sequence of static images, which are concatenated into a movie via FFmpeg.
By “how do I set the bit rate”, I do indeed mean “what value should I choose” :-) I multiplied the default value of 400000 (from the sample code) by a factor of 10 arbitrarily, to see what would happen. That larger value produced much better results. But this was simply lucky on my part, as I don’t really know how to compute the “correct/good/sufficient” bit rate, given the input data, the frame size, frame rate (and whatever else might have an impact).
On Nov 21, 2014, at 9:23 AM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> Philip Schneider <pjschneider at ...> writes:
>> The sample code has "c->bit_rate = 400000”. For a
>> moderate-sized image (1280 x 720) at 30fps, the
>> resulting movie shows terrible visual artifacts
> What kind of source material is this?
> If is is interlaced, you have to tell the encoder.
> If you don't tell the encoder, you either get very
> bad quality or you need a very high bitrate.
>> Given those caveats, can someone explain how I
>> can programmatically set the bit_rate?
> Do you mean "how do I set the bitrate"? Since you
> answered it above, I don't understand the question.
> Or do you mean "what value should I choose for
> birate"? If you ask the question, I consider it an
> indication that you actually want constant
> quantiser instead.
> Using a bitrate makes mostly sense if you have a
> known upper limit.
> Carl Eugen
> Libav-user mailing list
> Libav-user at ffmpeg.org
More information about the Libav-user