node-ffmetadata icon indicating copy to clipboard operation
node-ffmetadata copied to clipboard

Problem reading metadata in Windows

Open azcn2503 opened this issue 11 years ago • 12 comments

read is returning an empty object when used on Windows. ffmpeg was installed using chocolatey, so this should have taken care of dependencies. I am able to use read on the same file successfully on the Mac, with ffmpeg installed via homebrew. Is there some additional configuration required on Windows for it to work?

azcn2503 avatar Dec 04 '14 16:12 azcn2503

I think there are two scenarios where this is possible:

  1. The input file actually does not have any metadata.
  2. ffmpeg fails but still returns with an success exit code of 0. I think there are a some bugs in ffmpeg that can cause this to happen.

I suggest debugging this and seeing what ffmpeg’s stderr output is. Right now if the exit code is 0, we assume success ignore stderr. You can use a debugger or edit the source to see the stderr output (see here, or you can use the dryRun option to see the arguments being used to run ffmpeg are and run ffmpeg manually yourself with the same arguments to see what happens. (I just added the dryRun option and released in v1.3.0.)

/cc @egoroof: I think you are using ffmetadata under windows - have you seen this issue?

parshap avatar Dec 04 '14 22:12 parshap

No, I have no problems. Also even when I use ffmetadata with an input file which does not have any ID3 tags I get an object with "encoder" property. It works great with russian language) @azcn2503 I think the problem may be in PATH property in system variable. Can you run ffmpeg using command line just typing "ffmpeg"?

egoroof avatar Dec 05 '14 01:12 egoroof

Ok, if I run ffmpeg directly from the console with the command: ffmpeg -i "D:/Music/Altitude - Homecoming.mp3" -f ffmetadata pipe:1 I can see the metadata without any problems. ffmpeg is added to the PATH, so I am able to run it without using the absolute path. I'll continue to investigate.

azcn2503 avatar Dec 05 '14 07:12 azcn2503

What about js? What code do you use? What version of nodejs do you use? Try to run included tests.

egoroof avatar Dec 05 '14 08:12 egoroof

Here is a sample of code I am using:

var dir = require('node-dir');
var ffmetadata = require('ffmetadata');

dir.files('D:/Music/Anjunabeats Vol. 11/Split/CD 1', function(err, files) {
    if(err) { throw err; }
    (function iterateFiles(n) {
        n = n || 0;
        if(n == files.length - 1) { return; }
        console.log(files[n]);
        if(!/.(mp3|wav|aac)$/.test(files[n])) { iterateFiles(n + 1); return; }
        ffmetadata.read(files[n], function(err, metadata) {
            if(err) { console.error('Could not read file'); }
            else { console.log(metadata); }
            setTimeout(function() {
                iterateFiles(n + 1);
            }, 1000);
        });
    })();
});

I managed to get a screenshot as the ffmpeg process was closing. In the screenshot you can see that ffmpeg is grabbing the metadata correctly but it is not brought back to ffmetadata for whatever reason.

I tried to run the test by browsing to the node_modules/ffmetadata/test directory and running node test.js but it failed with the error:

module.js:340
    throw err;
          ^
Error: Cannot find module 'tape'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (D:\Git\id3\node_modules\ffmetadata\test\test.js:7:9)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

Update: I was using node v0.10.22. I since upgraded to v0.10.33, but the error persists.

screenshot - 05_12_2014 12_50_04

azcn2503 avatar Dec 05 '14 12:12 azcn2503

Before running tests install tape module to D:\Git\id3\node_modules\ffmetadata via npm.

egoroof avatar Dec 05 '14 15:12 egoroof

@azcn2503 to run tests, run npm install then npm test from the root directory of the ffmetadata project.

The output form ffmpeg looks alright at first glance. There could be a problem with the parsing of the output. Maybe try to see what's going on around here.

Have you tried the same exact mp3 file on osx and it works?

parshap avatar Dec 05 '14 19:12 parshap

@azcn2503: Did you ever get this working? If you can share the mp3 file with me I can try to debug it locally.

parshap avatar Dec 19 '14 23:12 parshap

Apologies for the delay, I'm traveling for the next few weeks and will try to continue working on this project in early January. On 20 Dec 2014 00:33, "Parsha Pourkhomami" [email protected] wrote:

@azcn2503 https://github.com/azcn2503: Did you ever get this working? If you can share the mp3 file with me I can try to debug it locally.

— Reply to this email directly or view it on GitHub https://github.com/parshap/node-ffmetadata/issues/9#issuecomment-67712710 .

azcn2503 avatar Dec 24 '14 08:12 azcn2503

I had the same issue on windows 10. A quick change on line 118 to change the detached value from true, to false fixed it for me:

return ffmpeg(args, { detached: false, encoding: "binary" });

jcorbett avatar Jan 24 '17 05:01 jcorbett

I'm not sure why detached was true in the first place. Interested in sending a PR to change that?

parshap avatar Jan 24 '17 06:01 parshap

@parshap Please merge the pr.

gritex avatar Jan 12 '19 22:01 gritex