Skip to content

Transition from v2 ffmpeg read/write to v3 pyav read/write: quality, batching #1062

@tfaehse

Description

@tfaehse

Hi!

I'm currently trying to switch to v3's read and write functionality for videos. For the most part everything works smoothly, I just have a few understanding issues on my side that I'd love to get some help with.

  1. My write code looks as follow:
with iio.imopen(temp_output, "w", plugin="pyav") as writer:
    writer.init_video_stream("libx264", fps=fps)
    ...
    writer.write(batch)

This works great, but I can't seem to figure out how to control the quality - in v2's FFmpeg writer there's the quality keyword that allows a quality between 0 and 10. How can I achieve something similar in v3 with pyav?

  1. My read works as follows:
with iio.imopen(input_path, "r", plugin="pyav") as reader:
    for batch_index, frame_buffer in enumerate(chunked(reader.iter(thread_type="FRAME"), batch_size)):
        ...

I feel like I'm losing out on performance here, because I don't understand how to do a batch read properly. This snippet absolutely works, but do I understand the batching correctly? My goal is to load a batch of images into memory as fast as possible, process it and move on with the next batch.

I have, of course, tried to read the docs, but for these two questions I can't seem to come up with a solution. Thanks in advance for your feedback, and please tell me if there's any information I'm missing!

System information: python 3.11 on macOS (arm), av 9.2.0 and imageio 2.33.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions