JamesKyburz/youtube-audio-stream

fluent-ffmpeg: Maximum call stack size exceeded

Closed this issue ยท 8 comments

Getting error sporadically when invoking youtube-audio-stream sometimes with various video URLs. Should this error be reported to ytdl or fluent-ffmpeg?

/home/omgimanerd/backburner/audio-spatializer/node_modules/fluent-ffmpeg/lib/processor.js:419
    function emitEnd(err, stdout, stderr) {
                    ^

RangeError: Maximum call stack size exceeded
    at emitEnd (/home/omgimanerd/backburner/audio-spatializer/node_modules/fluent-ffmpeg/lib/processor.js:419:21)
    at PassThrough.<anonymous> (/home/omgimanerd/backburner/audio-spatializer/node_modules/fluent-ffmpeg/lib/processor.js:455:15)
    at emitOne (events.js:125:13)
    at PassThrough.emit (events.js:221:7)
    at writeAfterEnd (_stream_writable.js:239:10)
    at PassThrough.Writable.write (_stream_writable.js:288:5)
    at PassThrough.Writable.end (_stream_writable.js:554:10)
    at emitThree (events.js:150:20)
    at DestroyableTransform.emit (events.js:227:7)
    at emitThree (events.js:150:20)

I also just started hitting this. I've been using this package for 6 months, and suddenly it went from no problems to hitting this for certain valid URLs.
I saw my first failure in an environment that had not been changed for 2 months, so I'm inclined to believe this is a change on the YouTube side.

I think so too, I haven't touched my environment and this error occurs. It seems to me that this type of error could be somewhere down the chain though. Should I file this bug to both ytdl and fluent-ffmpeg and see if they have any input?

That seems like a good course of action :)

I think I may have found the issue.
I just happened to come accross this article, which suggests YouTube has been restricting a lot of videos from embedded playback:
https://medium.com/@listenonrepeat/blocked-videos-issue-ea9ac5189111
I tried to embed the video I'm hitting this error for, and it is indeed blocked from embedding.

Could you try with the URLs you're getting this for? Just create this html file & open it:

<!DOCTYPE html>
<html>

<head>
    <meta charset=utf-8>
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>

<body>
    <iframe width="560" height="315" src="https://www.youtube.com/embed/TJUVNg5zxAs" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</body>

</html> 

I tried with this video file https://www.youtube.com/watch?v=sBo52--2XU4 and it worked. This was the same link which I used for this Issue follow up.
events.js:160throw er; // Unhandled 'error' event #2

It might make sense to isolate the fluent-ffmpeg invocations in this package and write a more graceful failure condition.

@omgimanerd @TechRaY This lib is using outdated ytdl-core. You can either upgrade it yourself or use ytdl-core directly.

const uri = 'https://www.youtube.com/watch?v=t1TcDHrkQYg';
const passThrough = new PassThrough();
const video = ytdl(uri, {filter: 'audioonly', quality: 'lowest'}).pipe(passThrough);
...

Closing as I think the error is in outside of this library.