Skip to content

How to run encoding using multiple cores? #1014

@kundanshrivastava

Description

@kundanshrivastava

Overview

Unable to run PyAV container encoding on multiple CPU's

Expected behavior

by adding flags:
self.stream.thread_count = 4
self.stream.thread_type = 3
Its should work on 4 thread but i don't see that is working as performance not improved at all

Actual behavior

Encoding should start working on multicore passed by self.stream.thread_count = 4 and self.stream.thread_type = 3 arguments.

Research

I have done the following:
Inside _init():
self.container = av.open(path, mode="w")
self.stream = self.container.add_stream("h264", rate=round(frame_rate))
self.stream.pix_fmt = "yuv420p"
self.stream.thread_count = 4
self.stream.thread_type = 3
self.stream.bit_rate = bit_rate

Adding data to container:
#type of src is numpy array
frame = av.VideoFrame.from_ndarray(src, format="rgba")
self.container.mux(self.stream.encode(frame))

Additional context

I am writing the webm video form numpy array data and its working fine but its too slow, therefor exploring the multi core option

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