我想实现以下目标:
- 读取 MP3 元数据
- 修改该元数据的编码(如果我可以修改该元数据的内容,那就更好了)
- 保存对该 MP3 文件的修改
所有这些操作都可以基于本机 Node.js(无需浏览器)。是否有任何模块提供这样的功能或者我可以基于它开发?
我想实现以下目标:
所有这些操作都可以基于本机 Node.js(无需浏览器)。是否有任何模块提供这样的功能或者我可以基于它开发?
对于那些通过谷歌提出这个问题的人,有一个节点模块可以做到这一点,读取和写入元数据: https ://www.npmjs.org/package/ffmetadata
我不知道是否有办法在 NodeJS 中实际进行元数据操作。这是一种变通方法,但您可以使用child_process.exec
perl 来做到这一点:
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);
}
});
#!/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
类似的东西。您显然想为您实际想要将元数据更改为的内容提供更多论据......祝您好运!
到目前为止,我发现jsmediatagsnpm
是读取ID3v2
标签的最佳包
var jsmediatags = require("jsmediatags");
jsmediatags.read("./song.mp3", {
onSuccess: function(tag) {
console.log(tag);
},
onError: function(error) {
console.log(':(', error.type, error.info);
}
});