How can I run a function on files in tmp while keeping the temporary file it creates in tmp, and how do I rebuild binaries for ffmpeg?

This topic was automatically generated from Slack. You can find the original thread here.

I opened this ticket, however I am still stuck. [BUG] · Issue #4874 · PipedreamHQ/pipedream · GitHub I was asked to post here so someone can help…could anyone?

I want to temporarily store an image and audio file in the tmp directory, run a function on them to merge them with moviepy package, and the resulting mp4 should also be created in the tmp directory. Once the file is created, I am going to use YouTube API to upload the file there, and then delete it from tmp.

The problem I am facing is the function that I am using from moviepy is creating a temporary file “while it is running” that is not getting created in tmp. And possibly therefore it is throwing an error. How can I run a function on files on tmp, while keeping the temporary file function creates in the tmp itself?

Also, apparently I have to rebuild binaries if they need to be built. I am using ffmpeg and not sure how to build them to use in my function. Can you help?

Please note that I am new to coding in general :slight_smile:

Hi Ashay, I also responded to your email, but I’d recommend the following options to get help using the moviepy package (unless someone here has experience with the package and can help)

• Try asking https://chat.openai.com/chat . I posted your question and it produced some good code examples.
• Try asking in the moviepy GitHub repo: GitHub - Zulko/moviepy: Video editing with Python
• Try asking on Stack Overflow

I’d also recommend setting the current working directory in the Python script to /tmp , which may store the moviepy temp files there:

import os

def handler(pd: "pipedream"):
    # Set the current working directory to the tmp directory
    tmp_dir = "/tmp"
    os.chdir(tmp_dir)

    # Your moviepy code here...

The last solution did the trick. I cannot thank you enough.