j-holub / Node-MPV

A NodeJs Module for MPV Player
https://www.npmjs.com/package/node-mpv
MIT License
116 stars 73 forks source link

[Node-MPV-2] addSubtitles and rejected promises #46

Closed AxelTerizaki closed 6 years ago

AxelTerizaki commented 6 years ago

Hello.

Not sure if you'll be able to reproduce this but here goes.

While testing out Karaoke Mugen's database I stumbled on a corrupted ASS file (most likely) which does not load in mpv when I run the addSubtitles command. Thanks to your error handling I got ontified on the error.

Here's my code :

if (subFile) try {
  await player.addSubtitles(subFile);
} catch(err) {
  logger.error(`[Player] Unable to load subtitles : ${err}`);
}

I added the try/catch because I received an unhandled rejection on this particular command when using that ass file.

However, the try/catch doesn't seem to work and I still get an unhandled rejection 👍

12:49:44 - info: [Engine] Playing Kaizoku Ôji - Kaizoku Ôji
Unhandled Rejection at: Promise Promise {
  <rejected> { errcode: 3,
  verbose: 'ipcCommand invalid',
  method: 'addSubtitles()',
  arguments:
   [ 'D:\\dev\\karaokemugen-app\\app\\data\\lyrics\\JAP - Kaizoku Ouji - OP - Kaizoku Ouji.ass' ],
  errmessage: 'error running command' } } reason: { errcode: 3,
  verbose: 'ipcCommand invalid',
  method: 'addSubtitles()',
  arguments:
   [ 'D:\\dev\\karaokemugen-app\\app\\data\\lyrics\\JAP - Kaizoku Ouji - OP - Kaizoku Ouji.ass' ],
  errmessage: 'error running command' }

I'm attaching the ass file so you can try it out on any video. (had to rename it to txt so it would get accepted by github) JAP - Kaizoku Ouji - OP - Kaizoku Ouji.txt

I'm running mpv 0.27.0

Not sure if it's a bug on my end or on yours, tell me if you're able to reproduce it?

Thanks in advance.

j-holub commented 6 years ago

Thanks for reporting that, I'll have a look at it.

The error sounds like something is wrong with the message itself (might be a bug in node-mpv though), I'll see if I can reproduce it.

Having an unhandled rejection is for sure something that should not happen, I'll fix that of course.

j-holub commented 6 years ago

The unhandled Promise error was a missing return on my part (I'll fix that ASAP), unfortunately I can't tell yet why the subtitle doesn't work.

I sent the command myself using scout and the only error I got on the IPC part was {"error":"error running command"}. That's the reason why it is so difficult to give proper error messages. Until MPV changes something on their side it's very difficult to tell why a command failed since all it says is error running command as you can see.

MPV in the command line said Can not open external file JAP.-.Kaizoku.Ouji.-.OP.-.Kaizoku.Ouji.AA. so maybe the Subtitle file really is corrupted or wrong?

Did it work at any time for you?

AxelTerizaki commented 6 years ago

Great :)

Don't you worry about the .ass file being corrupted, I sent it to you to make sure you could reproduce the error. It is probably indeed corrupted but our karaoke database team hasn't got time to take a look at it just yet.

My point with this issue was to fix the error handling :) Fixing the error is up to me.

j-holub commented 6 years ago

Okay nice, thank you :)