node.js - 如何使用 node.js 将作者、标题和缩略图等标签添加到 .m4a 音频文件?

标签 node.js metadata thumbnails id3 m4a

使用 Node.js 下载 .m4a 格式的包含音乐的文件。

问题:我找不到将标签和封面艺术(缩略图)添加到 .m4a 文件的方法。

我在使用另一个程序之前已经完成了此操作:通过 MediaHuman youtube -> mp3 下载器实现(即使它下载为 m4a,我想要的格式)https://ufile.io/yzyzt

(P.S.我愿意使用另一种语言,只要该语言可以将其链接到 Node ,但如果它可以纯粹在node.js中完成,那绝对是非常首选的)

非常感谢有关此主题的任何线索。

最佳答案

一种方法是使用 node-taglib2 ,一个基于 taglib 的 Node.js C++ 插件,可在 npm 存储库中找到。

该模块可以轻松编辑 mpeg 元数据:

const fs = require('fs');
const taglib = require('taglib2');

let props = {
  artist: 'Howlin\' Wolf',
  title: 'Evil is goin\' on',
  pictures: [
    {
      "mimetype": 'image/jpeg',
      "picture": fs.readFileSync('./thumbnail.jpg')
    } 
  ]
}

taglib.writeTagsSync('./file.m4a', props);

现在我们可以检查元数据是否已更新:

let tags = taglib.readTagsSync('./file.m4a')

console.log(tags.artist, '-', tags.title)  // Howlin' Wolf - Evil is goin' on
console.log(tags.pictures)  // [ { mimetype: 'image/jpeg', picture: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff db 00 43 00 03 02 02 03 02 02 03 03 03 03 04 03 03 04 05 08 05 05 04 04 05 0a 07 07 06 ... > } ]

但是当然还有其他选项可以做同样的事情,我相信您也可以使用 ffmpeg,正如 Brad 在他的评论中提到的那样。如果您尝试一下,我会对您的反馈感兴趣。

关于node.js - 如何使用 node.js 将作者、标题和缩略图等标签添加到 .m4a 音频文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52795601/

相关文章:

javascript - 覆盖模型错误: Cannot overwrite `teams` model once compiled

node.js - docker -/bin/sh : nodemon: not found

ffmpeg - MP4 文件的 "location"和 "location-eng"元数据有什么区别?

ffmpeg - 使用 ffmpeg 或其他软件从视频中每个场景变化的中间生成缩略图

iphone - 如何获取捕获视频的缩略图并显示在 UIImageView 中

node.js - 使用 connect 进行路由 - 类似于express

node.js - 我的 websocket 服务器会影响 Nodejs 服务器吗?

ios - 如何正确使用 AVAssetExportSession 为音频 Assets 设置元数据?

go - 向贡献者指定在 go 项目中使用的 go 版本

html - 从 img 的 thumb "alt"或 "title"属性中提取文本并将其用作放大弹出照片的签名