Skip to content

Using thread_type = "FRAME" and skip_frame = "NONKEY" doesn't seem to be multi-threaded #1980

@Yul963

Description

@Yul963
import time
import av
import av.datasets

container = av.open(
    r"E:\ori_videos\463.mp4"
)
# container.streams.video[0].codec_context.skip_frame = "NONKEY"
container.streams.video[0].codec_context.thread_type = "NONE"

start_time = time.time()
for packet in container.demux():
    for frame in packet.decode():
        pass

default_time = time.time() - start_time
container.close()

container = av.open(
    r"E:\ori_videos\463.mp4"
)

# container.streams.video[0].codec_context.skip_frame = "NONKEY"
container.streams.video[0].codec_context.thread_type = "FRAME"

start_time = time.time()
for packet in container.demux():
    for frame in packet.decode():
        pass

auto_time = time.time() - start_time
container.close()


print("Decoded with no threading in {:.2f}s.".format(default_time))
print("Decoded with frame threading in {:.2f}s.".format(auto_time))
Decoded with no threading in 94.13s.
Decoded with frame threading in 19.67s.

This works fine. But when I try to get keyframes only, there is almost no diffrence on decoding time and CPU usage.

Decoded with no threading in 10.71s.
Decoded with frame threading in 10.82s.

Is this intended? or am I using it wrong?

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