How to modify a MP3 metadata and save by Node.js?
10,145
Solution 1
For those coming to this question through Google, there is a node module that can do this, both read and write metadata: https://www.npmjs.org/package/ffmetadata
Solution 2
I don't know whether there's a way to actually do the meta data manipulation in NodeJS. This is a work around way but you could do this using child_process.exec
and perl:
NodeJS Code
var exec = require('child_process').exec,
child;
child = exec('perl changeTags.pl file.mp3',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
Perl code
#!/usr/bin/perl
use MP3::Tag;
$mp3 = MP3::Tag->new(@ARGV[0]); # create object
$mp3->get_tags(); # read tags
print "Attempting to print tags for @ARGV[0]\n";
if (exists $mp3->{ID3v2}) {
print "Comments: " . $mp3->{ID3v2}->comment . "\n";
print "Zip: " . $mp3->{ID3v2}->album . "\n";
print "Tags: " . $mp3->{ID3v2}->title . "\n";
} else {
print "@ARGV[0] does not have ID3v2 tags\n";
}
$mp3->close(); # destroy object
Something like that. You'd obviously want to give more arguments for what you actually want to change the meta data to.... Good luck!
Solution 3
So far i found jsmediatags is best npm
package to read ID3v2
tags
var jsmediatags = require("jsmediatags");
jsmediatags.read("./song.mp3", {
onSuccess: function(tag) {
console.log(tag);
},
onError: function(error) {
console.log(':(', error.type, error.info);
}
});
Related videos on Youtube
Comments
-
Zation over 1 year
I want to achieve below goals:
- Read a MP3 metadata
- Modify the encoding of that metadata (if I could modify the content of that metadata, that would be better)
- Save the modification to that MP3 file
All these operations could be based on native Node.js (without browser). Is there any module provide such function or I can develop based on?
-
mak almost 11 yearsReading metadata: github.com/aadsm/JavaScript-ID3-Reader github.com/Tim-Smart/node-id3
-
kentcdodds almost 11 yearsWhy in the world did this get a down-vote?
-
inf3rno about 10 yearsmaybe because it is in perl ;-)
-
Denys Vitali almost 10 years-1 because is not a native node module but a workaround instead
-
finiteloop over 9 yearsIts worth noting that this has a dependence on ffmpeg.
-
Tacticus almost 8 yearsFor compatability with Windows Explorer, the plugin provides the
id3v2.3
option which may be set to true. See the documentation offfmetadata
. -
Mordred almost 6 yearsThis seems to work well, but supports only a basic subset of tags.
-
oldboy over 4 yearsis there a package to that will allow me to edit the metadata of any file type?
-
oldboy over 4 yearsis there a package to that will allow me to edit the metadata of any file type?
-
user202729 over 3 yearsffmpeg isn't a native node module either...