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

write EPIPE error for certain arguments #67

Open
jamesdools opened this issue Mar 20, 2021 · 2 comments
Open

write EPIPE error for certain arguments #67

jamesdools opened this issue Mar 20, 2021 · 2 comments

Comments

@jamesdools
Copy link

jamesdools commented Mar 20, 2021

Issue:

Hey Amish - appreciate all the work on this!

I'm using discord-ytdl-core to effectively trim a youtube clip with a start & end time (-ss / -to flags in FFmpeg).

Some flags work okay, but those two together consistently throws a write EPIPE error, which I can't handle gracefully. Seems like an error with the readable stream upon after the ffmpeg process.

Wondering if you know what this might be?

Steps to reproduce:

Originally opened an issue in the above mentioned repo but apparently is happening directly with prism-media.

Code snippet inside this issue:
twlite/discord-ytdl-core#20

Further details:

  • Operating System: OSX 10.13.6
  • Node.js version: 14.15.5
  • FFmpeg version: 4.0.2
  • prism-media version (in node modules): 1.2.8
  • @discordjs/opus version (node modules): 0.4.0
@amishshah
Copy link
Owner

Hi James!

I took a look at your code snippet and I managed to reproduce the EPIPE error. It seems to come from discord-ytdl-core not properly propagating errors. If you take a look at its source code, you'll notice that the only errors that are actually propagated are the ones from inputStream.

A quick fix for me was adding the following directly after the declaration of outputStream on line 81:

output.on('error', e => outputStream.emit('error', e));

I'd recommend that the author of that package makes sure that they propagate all of these errors, or consider using stream.pipeline to really reduce on some of the boilerplate there.

Note that this won't remove the EPIPE error entirely (it will still be thrown, but with this fix it won't crash the process), so you'll have to make sure to ignore errors once you've stopped playing that stream.

Let me know if this works for you!

@jamesdools
Copy link
Author

jamesdools commented Mar 20, 2021

Hey Amish!

Thanks so much for that - makes a lot of sense. Running that fix locally it does catch the error, and I can run with that for now. Have made a quick PR for that with discord-ytdl-core 👍

Was still curious about the error itself:

Error: write EPIPE
    at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:94:16) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

It does seem to trim the clip at the right start / end point, but error on onWriteComplete.

Any thoughts on if that's just down to the usage of discord-ytdl-core (or maybe my ffmpeg args?) 😄

As mentioned previous, I'm supplying['-ss', '2:10', '-to', '2:30'] while discord-ytdl-core adds a few boilerplate ones too.

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

2 participants