Node-ytdl-core: No sound on some Youtube URL

Created on 22 Dec 2019  路  13Comments  路  Source: fent/node-ytdl-core

My code works with 99,99% of youtube videos. But on some cases, i.e.: location='Z0blBD6_nfg'
the downloaded video has no audio. If I download that video with the mac app 4K Video Downloader the audio is ok, so hopefully there's a way to sort it out... Thanks for your nice work and help.

  const location=  'Z0blBD6_nfg';
  const url = 'https://www.youtube.com/watch?v=' + location;

            ytdl.getInfo(url, { quality: 'highest' }, function(err, info) {
                const stream = ytdl.downloadFromInfo(info, {
                    quality: 'highest',
                    requestOptions: { maxRedirects: 5 }
                })
                    .pipe(file);
            });

Most helpful comment

new version published

All 13 comments

some formats contain no sound. try using filter: 'audioandvideo' in the options

As long as I can find, there's no 'audioandvideo麓option any more :

     filter?: 'video' | 'videoonly' | 'audio' | 'audioonly' | ((format: videoFormat) => boolean);

index.d.ts L8

So it throws ERROR in src/app/services/provision.service.ts(131,53): error TS2322: Type '"audioandvideo"' is not assignable to type '"audio" | "video" | "videoonly" | "audioonly" | ((format: videoFormat) => boolean)'.

Additionally I have found, the issue only happens when I run the build app (an Electron one), not when I ran npm start

On my tsconfig.json I got:

"compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "alwaysStrict":true,
    "importHelpers": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "esModuleInterop": true,
    "moduleResolution": "node",
    "noImplicitAny": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "strict":true,
    "strictFunctionTypes":true,
    "strictNullChecks": false,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],

Possibly I need to change something there to behave the same as when running on server ...
But if emulate the built by running npm run electron:localit works. It only fails when build it by npm run build:prod && npx electron-builder build --mac , and only with this video url.

Aditionally I have tried compiling with this filter, by updating the index.d.ts L8, but the issue is not solved.

ok, I just published a fix for the types issue, the 'audioandvideo' filtering option should be there now

I guess that the problem isnt the filter because i looked into the videoinfos output and all the videos have audioBitrate: null except one 360p video

Same issue here. Can't see the "audioandvideo" option in index.d.ts:

https://github.com/fent/node-ytdl-core/blob/44bf980713a5d875c4bcb288dfc386ad98bc7282/typings/index.d.ts#L5-L20

update to latest, v1.0.4 had typings updated

I am using the latest version (v1.0.5) but can't find it in neither v1.0.5 nor v1.0.4. Commit message says

fix: types now have `filter: 'audioandvideo'`"

but there is no such option in index.d.ts. See here:

https://github.com/fent/node-ytdl-core/blob/44bf980713a5d875c4bcb288dfc386ad98bc7282/typings/index.d.ts#L5-L7

Am I doing something wrong?

nope, you're not doing anything wrong... guess fent forgot to add the audioandvideo option after moving the Filters

oh crap I did

new version published

It works like a charm, thanks peeps!

Not working for me...

It seems that it doesn't work when I select the 1080p quality with --filter-resolution 1080, or set quality to 299 (-q 299)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NeuronButter picture NeuronButter  路  6Comments

GamerXD4 picture GamerXD4  路  5Comments

jan-tennert picture jan-tennert  路  6Comments

cloudrac3r picture cloudrac3r  路  5Comments

ajgeiss0702 picture ajgeiss0702  路  5Comments