Skip to content

Performance and Recursion Limit Issues with Large Filter Chains #721

@lucemia

Description

@lucemia

Hi @jidasheng,

Thanks for the detailed report!

The “Argument list too long” issue has been addressed and released in v3.5.2. You can now avoid this by enabling use_filter_complex_script=True when calling run():

import ffmpeg
import sys

sys.setrecursionlimit(1000)

f = ffmpeg.input("in.mp4")
for _ in range(100):
    f = f.drawtext(
        text="123",
        x="100",
        y="100",
        fontsize=100,
        fontcolor="red",
        fontfile="/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
    )
f = f.output("out.mp4")
print(f.run(use_filter_complex_script=True))

This will switch to using -filter_complex_script instead of passing everything via the command line, which avoids hitting system argument limits.

As for the other two issues:
• RecursionError: maximum recursion depth exceeded
• Slow execution of compile_line() on very large filter chains

I don’t have a clean fix for those yet. Manually increasing the recursion limit with sys.setrecursionlimit() can help as a temporary workaround. I’ll go ahead and open a separate issue to track these performance limitations.

Thanks again for flagging this!

Originally posted by @lucemia in #706

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