Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I read and change details of file in nodejs?

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

like image 273
Phong Dao Avatar asked Dec 22 '14 03:12

Phong Dao


People also ask

How do you view file changes in node JS?

To watch any changes that are made to the file system, we can use the fs module provided by node. js that provides a solution here. For monitoring a file of any modification, we can either use the fs. watch() or fs.


1 Answers

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");
});
like image 121
pmverma Avatar answered Sep 29 '22 15:09

pmverma