6

I have a .mp4 file, I want to read and change this file details (Right mouse click file -> Properties -> Details tab) . I want to read and change Description property (Title, Subtitle, Rating, Tags, Comments). How i can do it with nodejs.

Thank so much

Phong Dao
  • 139
  • 1
  • 1
  • 14

1 Answers1

6

Use the ffmetadata npm module for reading/writing files properties.

Following is the example from ffmetadata npm site.

var ffmetadata = require("ffmetadata");

// Read song.mp3 metadata
ffmetadata.read("song.mp3", function(err, data) {
    if (err) console.error("Error reading metadata", err);
    else console.log(data);
});

// Set the artist for song.mp3
var data = {
  artist: "Me",
};
ffmetadata.write("song.mp3", data, function(err) {
    if (err) console.error("Error writing metadata", err);
    else console.log("Data written");
});
pmverma
  • 1,653
  • 13
  • 27
  • Thank you but when I try, I got error "Error reading metadata { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }" – Phong Dao Dec 22 '14 at 04:14
  • Did you read "https://github.com/parshap/node-ffmetadata/blob/v1.3.0/README.md" carefully, it says two dependency must be instlled. – pmverma Dec 22 '14 at 04:23
  • How do I add metadata to an existing file @pmverma? I'm successfully creating an **mp3** file. The next step is adding the right meta data for the **mp3's** image. `tempAudioFile = path.join(os.tmpdir(), audioFileName); const writeFile = util.promisify(fs.writeFile); return writeFile(tempAudioFile, responses[0].audioContent, 'binary')` – AdamHurwitz Dec 24 '18 at 22:38