ffmpegwasm / ffmpegwasm/ffmpeg.wasm
(bug/question) How to properly use one ffmpeg.exec() execution output as another's ffmpeg.exec() input?
- Dominant language
- C
- Stars
- 17.8k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Whenever I'm using previous `ffmpeg.exec()` output filename (i.e `output-temp.mp4`) in next `ffmpeg.exec` operation is input (by passing string with filename to `-i`), transformations do not stack - instead only first operation called gets presented.
**To Reproduce**
Here's a code simillar to which I run in my project. For this scenario let's assume all conditionals are met (As I do in my environment, with console output). In the final stage, video is presented in `` element and blob data is used in `src` attribute, to return effect of ffmpeg processing to the user visually.
To verify that it's not problem with logic or ffmpeg commands, all that I need is to specify in some step different output name i.e `output.mp4` and then use that as data for blob. This way I can verify that my transformation are working properly (just as in debugging bash script I maintain).
```javascript
NAME_TEMP_OUTPUT = "output_temp.mp4";
...
async function convertVideo(file) {
await ffmpeg.exec([
"-i",
DATA.NAME_GREENSCREEN_PNG,
"-i",
file.name,
"-filter_complex",
"... (transformation)",
"-c:v",
"libx264",
"-c:a",
"copy",
"-preset",
"ultrafast",
DATA.NAME_TEMP_OUTPUT,
]);
}
if (conditional1) {
console.log("conditional 1 runs");
await ffmpeg.writeFile(
DATA.NAME_TEMPLATE_VIDEO,
await fetchFile(DATA.PATH_TEMPLATE_VIDEO),
);
await ffmpeg.exec([
"-i",
DATA.NAME_TEMP_OUTPUT,
"-i",
DATA.NAME_TEMPLATE_VIDEO,
"-filter_complex",
"...",
"-map",
"[v]",
"-map",
"[a]",
"-preset",
"ultrafast",
DATA.NAME_TEMP_OUTPUT,
]);
}
....
if (conditional2) {
console.log("Conditional 2 runs");
await ffmpeg.writeFile(
DATA.NAME_INTRO_AUDIO,
await fetchFile(DATA.NAME_INTRO_AUDIO),
);
await ffmpeg.exec([
"-i",
DATA.NAME_TEMP_OUTPUT, // Input video file
"-i",
DATA.NAME_INTRO_AUDIO, // Input audio file
"-filter_complex",
"..."
"-c:v",
"copy", // Copy video stream without re-encoding
DATA.NAME_TEMP_OUTPUT, // Output file name
// "output.mp4", // Output file name
]);
// await ffmpeg.writeFile(DATA.NAME_TEMP_OUTPUT, DATA.NAME_TEMP_OUTPUT);
}
const data = await ffmpeg.readFile("output.mp4");
// const data = await ffmpeg.readFile(DATA.NAME_TEMP_OUTPUT);
```
**Expected behavior**
Whenever I use name for output, such as 'temp_output.mp4', and use this name in string format as another `ffmpeg.exec()` input file (i.e `-i temp_output.mp4` ), ffmpeg wil use the latest version of the file with latest applied transformations in memory.
**Screenshots**
-
**Desktop (please complete the following information):**
- OS: Windows 10
- Browser: MS Edge
- Version
**Additional context**
Add any other context about the problem here.
Contributor guide
Assessment
This issue has not been assessed yet.