This topic was automatically generated from Slack. You can find the original thread here.
I’ve been banging my head on this for hours and searching the slack isn’t helpful at all…
I’m trying to run ffmpeg inside a python step and I dont have it install locally…many suggestions have suggested to apt-get install it or pip install but the process cannot find neither pip nor apt-get…anyone have any ideas?
In case it helps, ffmpeg seems to work in Node.js code steps. For example:
import fs from "fs";
import stream from "stream";
import { promisify } from "util";
import { exec as childProcessExec } from "child_process";
import { path } from "@ffmpeg-installer/ffmpeg";
export default {
props: {
videoUrl: {
type: "string"
},
filename: {
type: "string"
},
subtitlesFileUrl: {
type: "string"
}
},
async run({ steps, $ }) {
const { default: got } = await import("got");
// This code downloads the video file to the /tmp directory
const f = `/tmp/${this.filename}`
const pipeline = promisify(stream.pipeline);
await pipeline(
got.stream(this.videoUrl),
fs.createWriteStream(f)
);
// This code downloads the subtitles file to the /tmp directory
const subFile = `/tmp/subtitles-en.vtt`
await pipeline(
got.stream(this.subtitlesFileUrl),
fs.createWriteStream(subFile)
);
// Get file info
const ffmpegPath = path;
const exec = promisify(childProcessExec);
return await exec(`${ffmpegPath} -i ${f} -i ${subFile} -codec:v "copy" -codec:a "copy" -codec:s "mov_text" -metadata:s:s:0 'language=eng' -f "mp4" -movflags "+faststart" /tmp/video.avi`);
}
};
You could potentially use a Node.js step to run ffmpeg and use Python for the rest of the workflow. Or Pi might be able to convert your Python step to Node.js.
To get ffmpeg working in Python on Pipedream, you can use the imageio-ffmpeg and imageio packages. Here’s how you can do it: At the top of your Python script, add the following magic comments to ensure the necessary packages are installed: ```
``` These comments will instruct Pipedream to install the imageio-ffmpeg and imageio packages, which are necessary for working with ffmpeg in Python. This approach is useful for anyone looking to use ffmpeg in their Pipedream workflows. If you have any further questions or need additional support, feel free to visit Pipedream Support.