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

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

Open
MalikElate opened this issue Jul 18, 2024 · 11 comments
Open

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

MalikElate opened this issue Jul 18, 2024 · 11 comments

Comments

@MalikElate
Copy link

MalikElate commented Jul 18, 2024

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

@MalikElate MalikElate changed the title YTDL downloads blank files, with no data YTDL-core downloads blank files, with no data Jul 18, 2024
@EnzoDev10
Copy link

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
Copy link
Author

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
Copy link

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

@phyzical
Copy link

phyzical commented Jul 20, 2024

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 #1299

@corwin-of-amber
Copy link

I noticed the fix in yt-dlp from today:
yt-dlp/yt-dlp@f099339

It is quite substantial, though. Needs porting.

@Meiscool125
Copy link

Meiscool125 commented Jul 27, 2024

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
Copy link

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

@phyzical
Copy link

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

@rudrasgithub
Copy link

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
Copy link

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();

@satyamkr203
Copy link

@MalikElate Yup, I'm getting same thing
you should use latest package of ytdl-core => @distube/ytdl-core, I fix the error while doing this!

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