YTDL and FS creating broken mp3 on windows (node.js)

1

I am trying to download a youtube video to mp3 and setting the mp3 ID3 tags afterwards. I am using node.js for this and the additional library node-id3. This Library does work on normal mp3 files, setting the tags like artist or album. This is the code I am using:

import nodeid3 from 'node-id3';
import ytdl from 'ytdl-core';
import fs from 'fs'
const tags = {
  title: "Yesterday",
  artist: "Kevin Penkin",
  album: "TV BlaBla",
  TRCK: "42",
};

function downloadYt() {
  console.log("start downloading");
  ytdl('https://www.youtube.com/watch?v=PvAOeAwadbI', {
    filter: 'audioonly',
    quality: 'highestaudio',
    highWaterMark: 1 << 25,
  }).pipe(fs.createWriteStream('./test_tags.mp3')).on('close',()=>{
    setTags('./test_tags.mp3');
    console.log("Tags set");
  });

}

function setTags(filepath) {
  nodeid3.write(tags, filepath)
}

When downloading the file, the resulting mp3-file is "sort of" broken. It can still be played and tagprograms like mp3tag do still recognize the provided tags.

However windows does not. The version of ID3 Tags is 2.3, but Windows does not show the tags and the tags cannot be edited by windows. This will result in an 0x8007000D error, which is commonly known for broken mp3 tags (google search). However using small tools to fix the mp3 or using MP3Tag (by deleting all tags) as suggested in many forums does NOT fix the file. The file is completly broken in that regard.

I need another option to either retrieve the ytdl stream (if that is the problem) or save the stream to mp3 (if that is the problem).

javascript
node.js
audio
fs
asked on Stack Overflow Apr 3, 2020 by Scorix

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0