Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault while creating a text clip #55

Open
Gandhi-Sagar opened this issue Jun 6, 2023 · 0 comments
Open

Segmentation fault while creating a text clip #55

Gandhi-Sagar opened this issue Jun 6, 2023 · 0 comments

Comments

@Gandhi-Sagar
Copy link

Gandhi-Sagar commented Jun 6, 2023

Problem

Segmentation fault.
In the logs, I see that PIL throws an error: PIL.Image - DEBUG - Error closing: Operation on closed image - 2023-06-05 20:45:11,107
Celery logs:

  | Traceback (most recent call last):   File "/Users/user1/opt/anaconda3/envs/bab/lib/python3.10/site-packages/billiard/pool.py", line 1265, in mark_as_worker_lost     raise WorkerLostError( billiard.exceptions.WorkerLostError: Worker exited prematurely: signal 11 (SIGSEGV) Job: 0.
-- | --

Code

I don't have a minimal example that replicates the error at the moment, but will add that tomorrow.
Code layout basically is as follows:

  1. API receives a request, and starts a celery task
  2. In the task, after some other sub-tasks, I render text as follows
       text_clip_mask = VideoClip(
            lambda t: make_frame_double_text(t)[:, :, 3] / 255.0,
            duration=render_duration,
            ismask=True,
        )
  1. in the make_frame_double_text function:
        text_segments = broken_text.split("\n")
        text_elements = []
        for i, t in enumerate(text_segments):
            x = 0 + TEXT_BOX_BORDER + 25 if i else 0 + TEXT_BOX_BORDER
            y = start_y + (i * LINE_BREAK_HEIGHT)
            text_elements.append(
                gizeh.text(
                    "  " + t,
                    fontfamily=FONT_FAMILY,
                    fontsize=SCALED_FONT_SIZE,
                    h_align="left",
                    v_align="top",
                    xy=[x, y],
                    fontslant="normal",
                    stroke=(0, 0, 0),
                    stroke_width=2,
                    fill=(1, 1, 1),
                )
            )
        for te in text_elements:
            te.draw(surface)

And this is where I get the segfault.
Here is a bit more of log if that is going to be helpful:

PIL.PngImagePlugin - DEBUG - STREAM b'IHDR' 16 13 - 2023-06-05 20:45:11,060
PIL.PngImagePlugin - DEBUG - STREAM b'pHYs' 41 9 - 2023-06-05 20:45:11,060
PIL.PngImagePlugin - DEBUG - STREAM b'PLTE' 62 12 - 2023-06-05 20:45:11,061
PIL.PngImagePlugin - DEBUG - STREAM b'IDAT' 86 6972 - 2023-06-05 20:45:11,061
PIL.PngImagePlugin - DEBUG - STREAM b'IHDR' 16 13 - 2023-06-05 20:45:11,062
PIL.PngImagePlugin - DEBUG - STREAM b'pHYs' 41 9 - 2023-06-05 20:45:11,062
PIL.PngImagePlugin - DEBUG - STREAM b'PLTE' 62 12 - 2023-06-05 20:45:11,062
PIL.PngImagePlugin - DEBUG - STREAM b'IDAT' 86 6972 - 2023-06-05 20:45:11,062
PIL.Image - DEBUG - Error closing: Operation on closed image - 2023-06-05 20:45:11,107

What has been tried and zeroed down:

I tried debugging by stepping inside gizeh, and error occurs on the first line of the (text's) draw function.

Environment

OS: macOS Monterey
Python version: 3.10.11
celery version: 5.2.7
moviepy: 1.0.3

Any help is appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant