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

Pass additional parameters to load() #31

Closed AxelTerizaki closed 6 years ago

AxelTerizaki commented 6 years ago

copy/paste from #30 :

To avoid big volume differences when going from one song to another in the playlist, we calculated audio gain through a ffmpeg script beforehand.

We need to pass the gain modifier to mpv when loading a video so it adjusts the volume accordingly.

The load() command in node-mpv doesn't offer any parameters other than append/replace. However, if you use command() this way...

_player.command('loadfile',[video,'replace','replaygain-fallback='+gain]);

We pass the loadfile mpv command manually to mpv, with the video path as first argument, replace, and then another option which is replaygan-fallback=, with an adjustment variable in decibels, like -5.04 for example.

I think the node-mpv load() function should allow to pass on additional parameters (other than append/replace).

j-holub commented 6 years ago

Sounds good to me. Adding an argument like an array for additional arguments is the most flexible I think (and easy to implement).

Would be nice of course to have something like load(file, mode, gain) but then a few month later somebody else will need something else.

j-holub commented 6 years ago

But I'm glad I added the command() and freeCommand() methods way back, gives people just way more flexibility :D

AxelTerizaki commented 6 years ago

Indeed, it helped a lot to work around this :)

j-holub commented 6 years ago

I did not publish it to npm yet. Tell me if you need that right away and I will

AxelTerizaki commented 6 years ago

I'm in no hurry since I have the workaround I listed when I opened the issue. I'll keep an eyes on when it's published on npm and modify my code accordingly then :)