exiftool icon indicating copy to clipboard operation
exiftool copied to clipboard

"Error: write EOF" with Gopro MP4 files (large / no metadata?) - fix with stdin error handler

Open phhu opened this issue 10 years ago • 0 comments

When attempted to get data from a Gopro MP4 file, I sometimes get an error like this ;

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: write EOF
    at Object.exports._errnoException (util.js:870:11)
    at exports._exceptionWithHostPort (util.js:893:20)
    at WriteWrap.afterWrite (net.js:763:14)

This can be fixed by adding a handler like this to exiftool.js :

  exif.stdin.on("error", function (data) {
    errorMessage += data.toString();
  });

...which makes exiftool return gracefully.

Code used for testing was

var exif = require('exiftool');
var fs   = require('fs');

function getVideoMetadata(videoPath){
    return new Promise (function(resolve,reject){
        fs.readFile(videoPath, function (err, data) {
            if (err) {reject(err);}
            exif.metadata(data, function (err, metadata) {
                if (err){reject(err);}
                resolve(metadata);          
            });
        }); 
    });
};

getVideoMetadata("C:\\temp\\videos\\GOPR0333.MP4")   
.then(function(md){
    console.log(md.rotation);
}).catch(function(e){
    console.log("errored", e);
})

phhu avatar Feb 11 '16 12:02 phhu