Skip to content

Conversation

@ladaapp
Copy link

@ladaapp ladaapp commented Jan 12, 2026

Was trying to use QSV encoders but noticed that the property they use for quality-based mode is unavailable. This PR exposes it in PyAV.

Couldn't think of a useful test for this as QSV wouldn't be available in CI and i'm not aware of another video encoder that uses this (tested with libx264 but it's ignored).

Reference:

Example

import av
import av.datasets

input_container = av.open(av.datasets.curated("pexels/time-lapse-video-of-night-sky-857195.mp4"))
output_container = av.open("hevc_qsv_encoded.mp4", "w", options={})

input_stream = input_container.streams.video[0]
output_stream = output_container.add_stream('hevc_qsv', input_stream.average_rate)
output_stream.width = input_stream.width
output_stream.height = input_stream.height

output_stream.pix_fmt = "nv12"
output_stream.codec_context.global_quality = 20
output_stream.codec_context.qscale = True

for frame in input_container.decode(video=0):
    packet = output_stream.encode(frame)
    if packet: output_container.mux(packet)

input_container.close()
output_container.close()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant