node-ytdl icon indicating copy to clipboard operation
node-ytdl copied to clipboard

Downloading video file and converting to mp3 error

Open JustinMarchi opened this issue 4 years ago • 5 comments

I've tried to reinstall and insure correct filepath in my system environment variables for FFMPEG however every time I try to convert a YouTube link to an mp3 I'm given a "pipe:0: Invalid data found when processing input"

Any insight?

Thanks!

JustinMarchi avatar Dec 05 '20 01:12 JustinMarchi

how exactly are you calling ffmpeg?

TimeForANinja avatar Dec 05 '20 12:12 TimeForANinja

Same issue here. Was working fine few days ago, then got this issue "pipe:0: Invalid data found when processing input"

Tried running the given example ytdl http://www.youtube.com/watch?v=_HSylqgVYQI | ffmpeg -i pipe:0 -b:a 192K -vn myfile.mp3 , same error.

Save to file ytdl "http://www.youtube.com/watch?v=_HSylqgVYQI" > myvideo.mp4 , then the resulting myvideo.mp4 is corrupted and cannot be opened.

However, the other format of save to file ytdl -o "myvideo.mp4" "http://www.youtube.com/watch?v=_HSylqgVYQI" actually works.

So my temporary workaround

ytdl -o "myvideo.mp4" "http://www.youtube.com/watch?v=_HSylqgVYQI" ; ffmpeg -i myvideo.mp4 -b:a 192K -vn "myvideo.mp3" ; rm myvideo.mp4

package.json

"ytdl": "^1.4.1",
"ytdl-core": "^4.1.4"

jimmy5312 avatar Dec 14 '20 18:12 jimmy5312

🤔 can't replicate on Linux

TimeForANinja avatar Dec 15 '20 08:12 TimeForANinja

Hi, not sure is it my configuration issue, upon further checking, it seems this issue only arise when I use Windows PowerShell to execute the commands. Running the command from normal cmd.exe and from Mac terminal is fine.

jimmy5312 avatar Dec 15 '20 11:12 jimmy5312

ytdl uses process.stdout.isTTY to know if the program is piping to a terminal. if that property is false, it will assume the program is being piped to another program, so will print the video output directly. in contrast, if it is piping to a terminal, then it will print a few video details plus a progress bar. which is i think is what's being printed, and then piped to ffmpeg.

so there might be some sort of incompatibility with powershell and the isTTY check

if this check can't be fixed, i could add a special output like --output=- that could instruct ytdl to pipe output directly to stdout.

fent avatar Dec 18 '20 04:12 fent