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

Is play() really completed once the video starts playing? #51

Closed AxelTerizaki closed 4 years ago

AxelTerizaki commented 5 years ago

I know you have little time lately but I'm leaving it here for later.

One of the features we'd like to add to our karaoke player using node-mpv is to display the user's avatar in the lower right corner of the screen (the one who requested for a video to be played)

To do this, we need the video's width and height to properly place and resize the user's avatar on screen.

I'm still working on it but I'm having trouble getting a reliable information on width and height. On the first video I play, the results are correct, but on the second one, width and height are set to null. There are other properties I observed but all of them are null'd when I try to get them. I turned on verbose/debug on node-mpv and noticed these are indeed changed to null, but never changed back to the correct width/height

I'm thus not sure if it's a node-mpv or a mpv issue.

From what I gathered, width and height get populated with correct values once the first video frame has been decoded, hence why I was wondering if play() wasn't returning early or something like that, which means that I'd be trying to read width and height before they get set to the correct sizes...

It's a small feature we'd like to be added sometime in the future, but there's absolutely no hurry.

You might perhaps get a better understanding with trying out the app itself and see what it does. Whenever you have some time for this, ask me and we'll see via discord or IRC or whatever how to set up Karaoke Mugen and debug this together.

Thanks in advance :)

j-holub commented 5 years ago

Sorry I haven't replied in almost a month. You're talking about Version 2 right?

I just checked the code and the possible exists. I promisified the send method in the low level parts of the module but it might not work correctly for some commands.

You say it works for the first video every time but not anymore for another one?

AxelTerizaki commented 5 years ago

That's correct. It's been a while since I tried this out, but from what I remember, width and height don't get defined anylmore after the first video (they're set to null instead)

j-holub commented 4 years ago

Hey there, could you give me a few lines of code to reproduce this issue?

j-holub commented 4 years ago

Hey, the code of the play() method has changed a little by now, could you maybe try again?

AxelTerizaki commented 4 years ago

Hmmm, not sure if it's relevant anymore : I initially wanted this to find out how I should size up an avatar picture being displayed on scree ndepending on the size of the video. However, we found there was some nifty libavfilter hacks and tricks to get the rendered size and determine what to do to display an avatar in the corner of the screen (to display who requested a song for 8 econds at the beginning of the song)

So for me, this issue should be closed if you're absolutely sure it workds better now :)

For the curious : https://lab.shelter.moe/karaokemugen/karaokemugen-app/-/blob/fb6428bc63c76acd931b06aecb77c30ded4b9e0b/src/components/mpv.ts#L430

j-holub commented 4 years ago

Okay, then I'll close this for now. I would assume that the behaviour with width and height is a problem on the mpv side of things anyway.