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

Importing Streams not working #1013

Open
thefran1412 opened this issue May 18, 2020 · 10 comments
Open

Importing Streams not working #1013

thefran1412 opened this issue May 18, 2020 · 10 comments

Comments

@thefran1412
Copy link

Version information

  • fluent-ffmpeg version: 2.1.2
  • ffmpeg version: 20200122 & 20181217
  • OS: Windows 10

Code to reproduce

If I run the following code it throws an error, but if instead I change the createReadStream for the path directly it works just fine. I need to use an input stream for my application and I can't figure out why it's not working. Thanks in advance 😄

const inputPath = path.resolve('/path/to/resource/file.gif')
const outputPath = path.resolve('/path/to/output/file.webm')

ffmpeg(fs.createReadStream(path))
   .inputFormat('gif')
   .videoCodec('libvpx-vp9')
   .format('webm')
   .output(outputPath)
   .run()

This is the ffmpeg command generated:

ffmpeg -f gif -i pipe:0 -y -vcodec libvpx-vp9 -f webm /absolute/path/to/output/file.webm

Expected results

Processing the file correctly

Observed results

Throws following error:

Error: ffmpeg exited with code 1: pipe:0: I/O error
@poppinlp
Copy link

poppinlp commented Jul 9, 2020

Seems I got the same error when I try to use a stream as input or use a stream for output. But will work fine after I change the stream to file path.

@nastari
Copy link

nastari commented Aug 11, 2020

SAME

@nastari
Copy link

nastari commented Aug 11, 2020

someone solved?

@federicocarboni
Copy link

This is mentioned nowhere in the FFmpeg Docs, but to use a streaming gif you have to set the input format as gif_pipe. @poppinlp @nastari @thefran1412

@nbusser
Copy link

nbusser commented Jun 15, 2022

Hey @federicocarboni . Good insight. It works now with ffprobe CLI but it still fails with fluent-ffmpeg.

const ffmpeg = require('fluent-ffmpeg');
const fs = require('fs');

const file = fs.createReadStream('gif');
ffmpeg(file).inputFormat('gif_pipe').ffprobe((err, data) => {
  console.log(data, err)
})

@nbusser
Copy link

nbusser commented Jun 15, 2022

Hey @federicocarboni . Good insight. It works now with ffprobe CLI but it still fails with fluent-ffmpeg.

const ffmpeg = require('fluent-ffmpeg');
const fs = require('fs');

const file = fs.createReadStream('gif');
ffmpeg(file).inputFormat('gif_pipe').ffprobe((err, data) => {
  console.log(data, err)
})

Why is this not working ?

Actually, fluent-ffmpeg, when using ffprobe, ignores all the arguments given to ffmpeg command. I suppose the reason behind that is that ffprobe binding was initially a separate project that has been merged with fluent-ffmpeg.

Ugly workaround

By looking at ffprobecode's, it appears that you can provide an options argument that will be concatenated to the command.
You just have to prove -f gif_pipe to ffprobe by setting ["-f", "gif_pipe"] as options array.

Thus you can simply do:

const ffmpeg = require("fluent-ffmpeg");
const fs = require("fs");

const file = fs.createReadStream("nyan-gif");
ffmpeg(file).ffprobe(["-f", "gif_pipe"], (err, data) => {
  console.log(data, err);
});

@slax57
Copy link

slax57 commented Mar 24, 2023

I had a very similar error message with the same use-case (using Ubuntu, not sure if that's the source of the difference or not):

ffmpeg exited with code 1: pipe:0: Input/output error

And @federicocarboni 's solution to add .inputFormat('gif_pipe') fixed it!
Thank you so much!


EDIT: actually it does not 🙁 . When processing multiple files with this, the error is no longer thrown but the resulting files are corrupted (not all of them but most of them).

@shtse8
Copy link

shtse8 commented Feb 20, 2024

I have the same issue, work well with filename but failed with stream.

Spawned Ffmpeg with command: ffmpeg -i pipe:0 -y tests/output.webm
An error occurred: ffmpeg exited with code 1: pipe:0: Invalid data found when processing input
Cannot determine format of input stream 0:0 after EOF
Error marking filters as finished
Conversion failed!

@federicocarboni
Copy link

@shtse8 What's the original format? e.g. what are you converting from? .mp4?

For example MP4 does not support streaming along with many other formats.

@shtse8
Copy link

shtse8 commented Feb 26, 2024

@shtse8 What's the original format? e.g. what are you converting from? .mp4?

For example MP4 does not support streaming along with many other formats.

@federicocarboni The original format I was working with is indeed MP4. Thanks for pointing out that MP4 doesn't support streaming, along with several other formats. Appreciate the clarification.

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

7 participants