Skip to content

How do I set the value of slices? #1422

Answered by WyattBlue
kuncoding asked this question in 1. Help
Discussion options

You must be logged in to vote

Something like this?

import av

av.logging.set_level(av.logging.VERBOSE)


def reencode_with_slices(
    input_filename: str, output_filename: str, slices: int
) -> None:
    input_container = av.open(input_filename)
    output_container = av.open(output_filename, mode="w")

    video_stream = output_container.add_stream("h264", rate=30)
    video_stream.codec_context.options = {"slices": f"{slices}"}

    input_video_stream = input_container.streams.video[0]
    video_stream.width = input_video_stream.width
    video_stream.height = input_video_stream.height
    video_stream.pix_fmt = "yuv420p"

    for frame in input_container.decode(input_video_stream):
        for packet in video_stream.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by WyattBlue
Comment options

You must be logged in to vote
2 replies
@diogommartins
Comment options

@kuncoding
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1420 on June 11, 2024 07:22.