You are not logged in.

#1 2017-03-13 03:22:17

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,661
Website

mpv wrapper script

Thought about reviving this issue while trimming down packages to squash in the Deuterium CD install. mpv is a very nice light media player but you can't just call it from a menu like vlc &co so it isn't a plug-in alternative for bl-media-player.
This wrapper looks to see if it's been called with any arguments (ie file, url...) and:

*) if not, run 'mpv --force-window --idle' which puts up an empty black window with (for me anyway) the uninviting title of "mpv - (unavailable)" but into which files can be dragged/dropped.

*) if there are arguments, call mpv in a terminal window, where you can see the usual info about bitrates etc.

Such a script, called eg 'bl-mpv' could be added to the alternatives for bl-media-player perhaps?

#!/bin/sh

# wrapper for mpv to enable use as alternative for bl-media-player

hash mpv || {
    echo "$0: Install mpv to use this script" >&2
    exit 1
}

if [ -n "$1" ]
then
    x-terminal-emulator -e mpv "$@"
else
    mpv --force-window --idle
fi

exit

...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#2 2017-03-13 08:01:11

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: mpv wrapper script

^ Brilliant idea, go for it smile

I would prefer this as the default tbh...

Offline

#3 2017-03-13 08:01:16

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: mpv wrapper script

johnraff wrote:

run 'mpv --force-window --idle' which puts up an empty black window with (for me anyway) the uninviting title of "mpv - (unavailable)" but into which files can be dragged/dropped.

never knew this was even possible.
nice.
can be pimped with --title:
mpv --force-window --idle --title="Drop media files here"

Last edited by ohnonot (2021-07-02 08:33:36)

Offline

#4 2017-03-13 08:28:57

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,661
Website

Re: mpv wrapper script

^for some reason I don't get that nice window - just a black square. Are you using a newer version than what's in Jessie?
Anyway, I've just tried the --title option and it works so thanks for that!


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#5 2017-03-13 08:53:47

Nili
Member
From: $HOME/♫♪
Registered: 2015-09-30
Posts: 1,271
Website

Re: mpv wrapper script

That's great johnraff, thanks for sharing. I'm trying to make resuming from last played once i launch the window.
...But because i am using old version 0.6.2-2 it is not possible unfortunately.

I'm trying to use one of these features

-r  --resume            will start playback from the resume bookmark,
                        if present.

-s  --start             will start playback from the default bookmark,
                        if present.

Maybe anyone can test the ^following two options, Do they work on your snippet?

Regards


Tumbleweed (Server) | KDE Plasma (Wayland)

Offline

#6 2017-03-13 16:25:22

Nili
Member
From: $HOME/♫♪
Registered: 2015-09-30
Posts: 1,271
Website

Re: mpv wrapper script

I ditched VLC for mpv since a while. I use too "save-position-on-quit" feature, also i let WM to handle other window features. It's great player, the best for my needs.


Tumbleweed (Server) | KDE Plasma (Wayland)

Offline

#7 2017-03-13 18:14:49

stevep
MX Linux Developer
Registered: 2016-08-08
Posts: 381

Re: mpv wrapper script

The current mpv 0.24 in upstream Debian can be backported on a Jessie base if some other prerequisites are backported first.  Notably, a minimum of ffmpeg 3.2.2; jessie-backports has 3.2.4 currently. Gnome-mpv isn't a candidate for any backport, though, since it would require a newer version of GNOME.

It's also possible to build a version of mpv which uses internal versions of ffmpeg, etc, so it's independent of those outside system libraries, but then you're straying away from the way Debian handles it.

Offline

#8 2017-03-13 19:34:14

nobody
The Great
Registered: 2015-08-10
Posts: 3,655

Re: mpv wrapper script

stevep wrote:

The current mpv 0.24 in upstream Debian can be backported on a Jessie base if some other prerequisites are backported first.  Notably, a minimum of ffmpeg 3.2.2; jessie-backports has 3.2.4 currently. Gnome-mpv isn't a candidate for any backport, though, since it would require a newer version of GNOME.

It's also possible to build a version of mpv which uses internal versions of ffmpeg, etc, so it's independent of those outside system libraries, but then you're straying away from the way Debian handles it.

Yes, linking ffmpeg statically would be the way to go.

Though there should be no mistake about what mpv 0.24 is: it is NOT STABLE, or a proper, planned RELEASE, it is a random snapshot of mpv git master made at a time when a) some time had passed since the last release, b) things looked stable and c) the developers said "hm, how about now". It literally is just a means to give distros something to package.

Offline

#9 2017-03-13 19:36:06

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,754

Re: mpv wrapper script

Well, I think iam using 4 versions of ffmpeg
- compiled one with screen-grabbing facilities (just make and script the scripts to use its absolute path)
- static compiled one for the rest of scripting (with x265 and all the stuff), 3rd party compile
- system one
- the one that mpv-build pulls in

So how much worse can it get?

Offline

#10 2017-03-13 20:19:00

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: mpv wrapper script

johnraff wrote:

^for some reason I don't get that nice window - just a black square. Are you using a newer version than what's in Jessie?
Anyway, I've just tried the --title option and it works so thanks for that!

yes newer version:

$> mpv --version
mpv 0.24.0 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
 built on Sun Feb 12 12:54:08 CET 2017

also setting the --title has a disadvantage: it stays like that even after dropping a file.

but the newer version has a slightly nicer title: "No file - mpv".


I use too "save-position-on-quit" feature

me too, but it creates a crapload of files in ~/.config/mpv/watch_later - i think they're never deleted! i have 1200 or so!

Offline

#11 2017-03-14 06:28:38

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,661
Website

Re: mpv wrapper script

earlybird wrote:

mpv has a .desktop file which specicies the options for a "as nice as possible" desktop-application-like experience

I had a look at that first off, but '/usr/bin/mpv --no-terminal --force-window -- %U' is appropriate for a "nice" player of some file(s); however '--idle' is needed to keep the window open while waiting for a drag/drop. We could add '--no-terminal' to the command, though. Does it make a difference?

Meanwhile, for actually playing a file passed on the command line, I thought more of our users might prefer the standard terminal interface, with all the data displayed, hence the 'x-terminal-emulator -e ...' wrapper. I'm quite ready to be persuaded to go for the --force-window approach, though, if it seems more popular.

If in doubt, we should adapt and ship that: `xdg-open mpv.desktop`.

This does nothing unfortunately. xdg-open wants a path to a file to open. It will open an audio file with the OP wrapper if it is set as the 'bl-media-player' option, as I now have it:
Screenshot_140317_15_16_26.jpg

Old releases of mpv have three things in common: a) They are entirely unsupported, b) Full of bugs fixed in later versions and c) Almost always not as nice....
Which is why I would supported introducing mpv upstream builds into the standard Helium package pool to ensure that BL users always have the latest mpv.

Debian Stretch now has mpv 0.23. Are there any major problems with that? Considering:

nobody wrote:

there should be no mistake about what mpv 0.24 is: it is NOT STABLE, or a proper, planned RELEASE, it is a random snapshot ...

...and, wouldn't media players be a likely target for security vulnerabilities, requiring us to keep watching upstream and patch our builds whenever fixes came down? Personally, I'd rather leave that to Debian Security.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#12 2017-03-14 13:14:19

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,157
Website

Re: mpv wrapper script

ohnonot wrote:

I use too "save-position-on-quit" feature

me too, but it creates a crapload of files in ~/.config/mpv/watch_later - i think they're never deleted! i have 1200 or so!

They're tiny text files that contain the time-stamp of where you left off. In gnome-mpv, they're stored in ~/.config/gnome-mpv and they're deleted when the media file reached its end.


I don't care what you do at home. Would you care to explain?

Online

#13 2017-03-15 02:20:26

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,661
Website

Re: mpv wrapper script

Sorry if I didn't make this clear enough in the OP, but that wrapper was proposed as something to add to the DEUTERIUM bunsen-configs. Helium/Stretch sort of crept in with the discussion of mpv versions, which I wasn't really concerned about - I just wanted something that would be a usable choice as a Debian alternative for bl-media-player. That way the CD iso could drop vlc, install the much smaller mpv, and still have usable menu entries, right-click options etc. The small wrapper script could just sit in default systems using vlc, doing nothing at all till the user installed mpv.

So @hhh I didn't ignore your suggestion of gnome-mpv at all, but it's something only available in Stretch. I think (if it's any good) it should certainly be added to the multimedia menu options and alternatives for bl-media-player, and possibly considered as a replacement for vlc in Helium. It could certainly co-exist with the mpv wrapper.

About mpv versions, @nobody, agreed mpv in Jessie is very old. But we're talking about another 6 months, perhaps, till we switch to Stretch, where the much newer 0.23 is available? The only reason I raised mpv at all at this point was that it seemed like a reasonable alternative to vlc for the CD, even at version 0.6.2. If you feel like backporting (and maintaining) a newer version of mpv for Jessie/Hydrogen I'm sure plenty of users would appreciate it. Just as long as it goes in backports, not the main repo. @hhh that would be no problem, right?


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#14 2017-03-15 02:54:39

stevep
MX Linux Developer
Registered: 2016-08-08
Posts: 381

Re: mpv wrapper script

I already have mpv 0.24 in my own jessie multimedia repo on the openSUSE build service, but that's from Sid and will break any in-place upgrades to Stretch for sure! But it is possible to backport 0.23 without much difficulty.

Offline

#15 2017-03-15 06:42:17

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,157
Website

Re: mpv wrapper script

@hhh that would be no problem, right?

No problem and very desirable! Thanks for clarifying.

re:gnome-mpv, no man page is a drag, but they have an active GitHub page. I posted feedback on an issue this morning that helped close it, the maintainer(s) responded within the hour.

The player behaves for me like gnome-mplayer did back in the day, not like what you're reporting. Would someone running stretch or sid do some testing to verify?

Whatever we decide, I'll be using it for the foreseeable future.


I don't care what you do at home. Would you care to explain?

Online

#16 2017-03-15 07:13:49

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,661
Website

Re: mpv wrapper script

^To give gnome-mpv a proper test I guess I'd have to install Stretch on a piece of real hardware and try it there. That won't happen too soon, so indeed any reports most welcome.

---
About the wrapper for plain mpv. When called with an audio file as argument, it could be set to display the usual mpv-in-terminal (which is what it does now) or alternatively the "semi-nice" sort-of-gui offered by 'mpv --force-window'.

IE
This:
Screenshot_150317_term.jpg
or this:
Screenshot_150317_gui.jpg
If most people preferred the GUI-ish interface it's easily done.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#17 2017-03-15 08:09:02

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: mpv wrapper script

^ I think the GUI-ish window looks rather useful  smile

I can't help but wonder if there is an ncurses option though...

EDIT: weirdly:

vlc -I ncurses

8)

Last edited by Head_on_a_Stick (2017-03-15 21:10:30)

Offline

#18 2017-03-15 12:52:54

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,157
Website

Re: mpv wrapper script

Epic fail. I split the posts that mostly talked about gnome-mpv to a new thread, then deleted the thread. I'll start a new thread, and at least this thread can stay on topic now.

My bad. roll


I don't care what you do at home. Would you care to explain?

Online

#19 2017-03-15 16:34:12

geekosupremo
Member
Registered: 2016-04-27
Posts: 169

Re: mpv wrapper script

I think the second option is a nice mix of the "simple" focus of BL while still offering a nice "easy" UI. And this will be less likly to send former Windows and MacOS users running for the hills. wink

Offline

#20 2017-03-16 02:29:02

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,661
Website

Re: mpv wrapper script

OK we've got 2 votes for the simple-gui option, 3 if you count earlybird's mention, so let's go for that.
It would be easy enough to change in the future with an upgrade of bunsen-configs, and I'll leave (my preferred) option of a plain terminal interface as a commented-out line that users can edit if they want.

So, like this:

#!/bin/sh

# wrapper for mpv to enable use as alternative for bl-media-player

hash mpv || {
    echo "$0: Install mpv to use this script" >&2
    exit 1
}

if [ -n "$1" ]
then
    if [ "$#" -gt 1 ]
    then
        title='mpv' # $title is only needed for terminal
    else
        title="mpv - ${1##*/}"
    fi
# uncomment the next line to run mpv in a terminal
#   x-terminal-emulator -T "$title" -e mpv "$@"
# comment out the next line if you use x-terminal-emulator
    mpv --no-terminal --force-window "$@"
else
    mpv --no-terminal --force-window --idle --title='mpv - ${filename:Drop media files here}'
fi

exit

Fixed the title for empty windows - mpv allows substitutions. cool

I thought the default 640x480 was annoyingly big, so tried adding a --geometry='450x250' - that's fine for audio files, but forces the video playback to be that size too. Trying to identify audio files in advance would be overkill for something like this perhaps. If you play mostly audio you could add it to the two mpv lines; videos can still be full-screened easily enough.

In fact it could all be boiled down to a single 'mpv --no-terminal --force-window --idle  --title='mpv - ${filename:Drop media files here}' "$@"' if it was OK for the window to remain open after playing the file chosen, but I find it mildly irritating to have to close it myself...

The '--no-terminal' option turned out to be indeed necessary because otherwise ~/.xsession-errors gets filled up with junk.

Last edited by johnraff (2017-03-16 02:30:28)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

Board footer

Powered by FluxBB