Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
baryluk opened this issue Dec 10, 2020 · 0 comments
Open

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

baryluk opened this issue Dec 10, 2020 · 0 comments
Labels

Comments

@baryluk
Copy link

@baryluk baryluk commented Dec 10, 2020

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.

@baryluk baryluk added the enhancement label Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant