fent / node-ytdl-core

YouTube video downloader in javascript.
MIT License
4.47k stars 788 forks source link

YTDL-core downloads blank files, with no data #1303

Open MalikElate opened 1 month ago

MalikElate commented 1 month ago

Hey, I'm trying to use ytdl-core but its stopped working across several version. When I download a video I get a blank file that is zero bytes. I'm expecting that videos should download as normal.

I'm running the most basic download but it work work. `const fs = require('fs'); const ytdl = require('ytdl-core');

ytdl('http://www.youtube.com/watch?v=aqz-KE-bpKQ') .pipe(fs.createWriteStream('video.mp4'));`

Screenshot 2024-07-18 at 4 57 53 PM

Any help on this would be greatly appreciated

EnzoDev10 commented 1 month ago

The same thing happened to me today, from what i read in other recent issues it seems to be related to some changes made by Youtube, maybe made to stop this kind of libraries from working. hope it gets solved soon.

MalikElate commented 1 month ago

The same thing happened to me today, from what i read in other recent issues it seems to be related to some changes made by Youtube, maybe made to stop this kind of libraries from working. hope it gets solved soon.

Im not sure, did also notice other libraries were affect.

I was able to restart my computer (mac) and it working normally now

EnzoDev10 commented 1 month ago

good to know that it works for you, i tried restarting mine(windows) and it still doesn't work.

phyzical commented 1 month ago

try out https://www.npmjs.com/package/youtube-dl-exec

until a fix it pushed

const download = await ytdl.exec(link, { x: true });'

Or see this https://github.com/fent/node-ytdl-core/issues/1299

corwin-of-amber commented 1 month ago

I noticed the fix in yt-dlp from today: https://github.com/yt-dlp/yt-dlp/commit/f0993391e6052ec8f7aacc286609564f226943b9

It is quite substantial, though. Needs porting.

Meiscool125 commented 1 month ago

try out https://www.npmjs.com/package/youtube-dl-exec

I tried using the link referenced, and copy-pasted the first code under the usage section const youtubedl = require('youtube-dl-exec')... and it gives this error. since im new i have no idea whats going on but any support would be greatly appreciated.

\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\format-utils.js:226
  return formats.filter(format => !!format.url && fn(format));
                                                  ^

TypeError: Array.prototype.filter called on null or undefined
    at filter (<anonymous>)
    at C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\format-utils.js:226:51
    at Array.filter (<anonymous>)
    at exports.filterFormats (C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\format-utils.js:226:18)
    at exports.chooseFormat (C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\format-utils.js:104:23)
    at downloadFromInfoCallback (C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\index.js:86:26)
    at C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\index.js:20:5
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on PassThrough instance at:
    at downloadFromInfoCallback (C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\index.js:88:12)
    at C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\index.js:20:5
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.11.1
rudrasgithub commented 1 month ago

Not able to download a youtube video as it is showing that video file is not supported by the files

phyzical commented 1 month ago

just switch to https://www.npmjs.com/package/@distube/ytdl-core it should be a drop in replacement i.e https://github.com/SwapnilSoni1999/spotify-dl/commit/a0605c825ac718d2de68c1bef1a9e15c2747078c

rudrasgithub commented 1 month ago

Thanks @phyzical How to ffmpeg a video Error during extraction: Error: ffmpeg exited with code 1: pipe:1: Invalid argument

ffmpeg(fs.createReadStream('video.mp4')) .setStartTime(0) .setDuration(15) .output(fs.createWriteStream('outputPath.mp4')) .on('end', () => { console.log('Segment extraction finished'); }) .on('error', (err) => { console.error('Error during extraction:', err); }) .run();

rudrasgithub commented 1 month ago

Able to solve it on my own here is the corrected code:

ffmpeg('video.mp4') .setStartTime(0) .setDuration(15) .output(outputPath.mp4') .on('end', () => { console.log('Segment extraction finished'); }) .on('error', (err) => { console.error('Error during extraction:', err); }) .run();