Skip to content

How to specify output bitrate and encoder effort / quality? #726

@baryluk

Description

@baryluk

I am using python3-av 8.02-1+b2 from Debian testing, and after 30 minutes of playing got a prototype working. Nice.

I am writing a configurable re-compositor. It takes multiple input video files, a config with time and region ranges, and then splits it into separate output files, as well into one composited file (i.e. grid) with multiple frames interposed, all time aligned. It will work with about 16 video stream offline. The purpose is to create composited video of events captured multiple cameras. All the time alignment, resizing, pasting is working.

I got the prototype working, and it does everything I want basically.

There is one things that I don't know how to setup (other than outputting to uncompressed TS stream and using ffmpeg manually after that). How to configure the average / max bitrate and encoding effort / quality for output stream? Or which tune paramters to use? Or which profile to use? I am using h264 at the moment, but would like to use h265 in the future too.

When I create an output stream, i.e.

output_size = (2*1920, 2*1080)
output_fps = 30
output = av.open('remuxed.mkv', 'w')
output_encoder = 'h264'
#out_stream = output.add_stream(template=spacex_stream)
out_stream = output.add_stream(output_encoder, rate=output_fps)  # for Video, it is fps. for Audio it is sampling rate I.e. 48000
out_stream.width = output_size[0]
out_stream.height = output_size[1]
out_stream.pix_fmt = 'yuv420p'

If I read from out_stream.codec_context.max_bit_rate it returns None.
If I try to write to it a numbers (Mbsg?), it gives an error, saying it is not writeable only read only.

I couldn't find anything in the reference documentation.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions