1

Following is a simple ffmpeg command line for encoding an input video into a AV1 output with CRF 30:

ffmpeg -i input.mkv -c:v libsvtav1 -crf 30 output.mkv

Converting that command line into the syntax of ffmpeg-python is pretty straight-forward:

(
    ffmpeg
    .input('input.mkv')
    .output('output.mkv', vcodec='libsvtav1', crf=30)
    .run()
)

However, what happens if we want to specify the fast-decode option? In ffmpeg that would mean extending our command line to include -svtav1-params fast-decode=1, i.e.:

ffmpeg -i input.mkv -c:v libsvtav1 -crf 30 -svtav1-params fast-decode=1 output.mkv

How do we specify the same thing in ffmpeg-python? Adding svtav1-params='fast-decode=1' into the output arguments results in invalid Python code since variables are not allowed to have dash in the name:

(
    ffmpeg
    .input('input.mkv')
    .output('output.mkv', vcodec='libsvtav1', crf=30, svtav1-params='fast-decode=1')
    .run()
)
# Error: Expected parameter name

Replacing the dash with an underscore in the name makes ffmpeg-python read it literally which doesn't translate into a valid ffmpeg command line.

How is it possible to specify fast-decode and other svtav1-params specific arguments in ffmpeg-python?

1 Answer 1

3

According to the documentation, you can use the ** syntax to pass additional arguments for Special option names like this

(
    ffmpeg
    .input('input.mkv')
    .output('output.mkv', vcodec='libsvtav1', crf=30, **{'svtav1-params': 'fast-decode=1'})
    .run()
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.