Gadgetguy
Posts: 100
Joined: Fri Aug 15, 2014 2:55 am

GPU accelerated mpv media player combined with smplayer gui

Sat May 14, 2016 8:19 pm

With a computer like the raspberry pi, a relatively weak cpu makes it essential for a satisfactory web experience involving media or for playing locally stored media, that the gpu decode and render as much as possible. With this constraint in mind it is handy to have a variety of tools and tricks in the raspberry pi's arsenal.
Of course Omxplayer- pi's native media player, is indispensible and uses minimal cpu and memory resources. A good idea to create a desktop shortcut icon which will open and stay open in teminal ( so that keyboard controls will work ) ( See http://jeffhoogland.blogspot.ca/2012/08 ... a-gui.html) This permits dragging and dropping a media file to the icon to activate omxplayer in full screen with keyboard control of playback. However it is also useful to have a gui so that you can open omxplayer in a resizable draggable window with volume, seeking , aspect., and other controls. This need is admirably fufilled by Guenter Kreidl's ingenious, well documented and scrupously maintained Omxplayergui which is a separate but integrated component downloaded as part of Kweb (Minimal Kiosk Browser) low resource,fast browser with some unique features and again an essential tool in the Pi's quiver.
(viewtopic.php?f=66&t=40860&sid=1a7b993f ... 513518675b).

It also has the additional benefit of integrating youtube-dl into Omxplayergui..
As is probably well known to most users of these forums kusti8 has devised an extension for chromium which will invoke omxplayergui when playing a youtube video. oir other supported sites. Another interesting and useful app for chromium using omxplayer to play you tube, can be found here: viewtopic.php?f=38&t=132460&p=882933
( these two chromium extensions/apps can peacefully coexist.)




However it is useful to have still more tools for the different challenges presented by demanding web multimedia. For a while now I have been using a hardware accelerated mpv media player on raspbian.
A precompiled installable binary version can be downloaded here :

https://nwgat.ninja/installing-mpv-with ... -2-3-zero/

and/or instructions for compiling can be found here

https://nwgat.ninja/compiling-mpv-with- ... -3-zero-2/

This includes a compiled version of ffmpeg.(As an aside another thing i did afterward was to download winff from the repository for transcoding hoping to get hardware accelerated transcoding but the winff presets in the repository vesion apparently don't match the compiled ffmpeg version)


Again it is useful to create a desktop shortcut icon for mpv which will open and stay open in terminal so as to retain keyboard control( using sudo pcmanfm to open icon in desktop go to properties/ desktop entry and check appropriate boxes.) This enables you to drop local media files directly onto the mpv icon and and mpv will spring into action. I used this version of mpv to play without a hiccup and without a mpeg license a 1920x1080p mpeg2 transport stream encoded at 17225 kbps . However it wouldn't seek- presumably because a transport stream would not be indexed.. It also played the sample hevc 720p encoded video entitled surfing found at : http://www.elecard.com/en/download/videos.html
and of course the big buck bunny video smoothly.

The best known most widely used gui for mpv player and mplayer is smplayer. The repository version of smplayer is old and does not support mpv but rather only mplayer. The repository version of smplayer using the mplayer version also in the repository is pretty good if properly configured in preferences using user defined ,xv as the video output and alsa for audio output and 4 threads under performance.etc. It allows you to drag and drop hd youtube videos into the player and plays them well in a resizable draggable window or full screen with fast keyboard control and seeking options. It is fairly easy on cpu but uses considerably more cpu resources than omxplayer and omxplayer gui. One very annoying drawback to the repository version of smplayer is that I at least could't get it to hardware scale a low resolution eg320x240 video to full screen but rather would play it postage stamp size albeit in proper aspect ratio surrounded by black borders. My search for solutions led me to stumble upon this hardware accelated mpv.

There are more recent versions of smplayer (a gui for mplayer//mpv player) than the version of smplayer found in raspbian's repository. These have an advantage over the repository version in that they allow smplayer to use either the mplayer found in raspbian or mpv player as its version of mplayer and thereby utilize mpv's enhanced qualitly and it's support for youtube-dl. Using this hardware accelerated version of mpv lowers cpu resource usage considerably. A precompiled installable binary of smplayer version 16.10 that works in raspbian and/or instructions for compiling can be found here :


http://ubuntu-mate.community/t/tutorial ... pport/3888

In smplayers preferences under the general tab you pick mpv as player, giving path to mpv executable found under local binaries and rpi or default as video output. I found smplayer using this mpv hardware scales standard definition videos to full screen in proper aspect ratio (press f on keyboard to get full screen with black borders.) This version of smplayer using both mplayer or mpv also supports dragging and dropping youtube videos. Unfortunately I with my almost zero knowledge of linux (something I must try to remedy one of these days) was not able to configure mpv in smplayer so as to use youtube-dl and its support for numerous other video sites.

Mpv has a configuration file located at : /home/pi/.config/mpv/mpv.conf. Instructions for using the configuration file can be found at the mpv website:
https://mpv.io/manual/master/


One in someways unfortunate aspect of this hardware acclerated version of mpv is that is compiled using the very efficient mmal (whatever that is !) which has the unfortunate result that the video is rendered in a full screen overlay which removes the visibilty of the gui controls in smplayer. I was able to somewhat remedy this conundrum by a rather imperfect but useable hack specifing the following in smplayer preferences.: I am using a television with 1360x768 native resolution ,overscan disabled ,so i specified in smplayer preferences advanced tab options for mplayer/mpv “ --autofit=1360x720 “ -without apostophes. This enabled smplayer to output in almost full screen aspect ration preserved but allowed smplayers animated floating control to appear when the mouse is dragged to the bottom of the screen.
I was not able presumably because of mmal and overlay to use mpv's configuration file to get mpv to display osd and osc information which i believe are normally enabled by default. However Omxplayer also outputs an overlay video yet still shows osd info like time position etc. Any solutions.? The new version of Ubuntu 16.04 also has an accelerated version of mpv and newer smplayer in its repository .I tried ubuntu 16.04 and the video played by it's mpv wasn't displayed in the correct aspect ratio and for some reason did not seem as fast or efficient as the mpv player I have referenced here..

Note If at some point you lose keyboard control of full screen omxplayer or mpv you might try pressing alt-tab to regain control

As final digression that may or may not be helpful to other pi users I had a few multimedia ideas i stumbled upon partcularly with regard to using flashgot in firefox/iceweasel and the chromium url media internals for ferreting out the true urls of embedded web videos that I referenced in this post other users may find these ideas useful or have better suggestions
: viewtopic.php?t=135895&p=903851
Last edited by Gadgetguy on Sun May 15, 2016 1:35 am, edited 2 times in total.

gkreidl
Posts: 6108
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: GPU accelerated mpv media player combined with smplayer

Sat May 14, 2016 8:30 pm

I have not read all of this but a few things are definitely wrong;
1) 1080p MPEG TS streams are always H264 encoded, and not with MPEG2. So you never need the MPEG 2 license for them. You are mixing up container formats and codecs.
2) There's no problem with seeking in TS streams. I do a lot of HTDV recording of such streams and if I play the recorded files with omxplayer(GUI) seeking works like a charm.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Gadgetguy
Posts: 100
Joined: Fri Aug 15, 2014 2:55 am

Re: GPU accelerated mpv media player combined with smplayer

Sat May 14, 2016 9:11 pm

 By the way thanks Mr Kreidl for kweb and omxplayergui. I use both all the time they at times indispensable when using the Raspberry Pi. I also like Chromium and sometimes firefox so that I can use some of its extensions like flashgot. Perhaps you are right about the ostensible mpeg 2 ts I referred to. I wondered about that myself. I hate to quibble with perhaps the go to guy on all matters video along with Dom and others however I would point out that this particular video was recorded from my hd tv tuner in Canada which uses the ATSC high definition standard unlike Europe Here iare the video file proprties as taken off smplayer info utility





CKLT-DT_08_06_2012_15_29_55.mpg
General
File
/media/pi/LEXAR/movies/CKLT-DT_08_06_2012_15_29_55.mpg
Size
981184 KB (958 MB)
Length
00:07:23
Demuxer
lavf

Clip info
Name
CKLT-DT_08_06_2012_15_29_55.mpg

Video
Resolution
1920 x 1080
Aspect ratio
1.77778
Format
mpeg2video
Bitrate
17225 kbps
Frames per second
29.970030
Selected codec
lavc:mpegvideo

Initial Audio Stream
Format
ac3
Bitrate
383 kbps
Rate
48000 Hz
Channels
2
Selected codec
lavc:ac3

Audio Streams
#
Language
Name
ID
0
eng
<empty>
1
1
eng
<empty>
2

Subtitles
#
Type
Language
Name
ID
0
SUB
<empty>
<empty>
1

gkreidl
Posts: 6108
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: GPU accelerated mpv media player combined with smplayer

Sat May 14, 2016 11:29 pm

I've never seen an MPEG coded stream of such a resolution before. Could you run mediainfo on the file, please?
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Gadgetguy
Posts: 100
Joined: Fri Aug 15, 2014 2:55 am

Re: GPU accelerated mpv media player combined with smplayer

Sun May 15, 2016 12:33 am

gkreidl wrote:I've never seen an MPEG coded stream of such a resolution before. Could you run mediainfo on the file, please?
As per your request here is the Media info as text:


General
ID : 16807 (0x41A7)
Complete name : /media/pi/LEXAR/movies/CKLT-DT_08_06_2012_15_29_55.mpg
Format : MPEG-TS
File size : 958 MiB
Duration : 7mn 22s
Overall bit rate : 18.2 Mbps
Law rating : E

Video
ID : 177 (0xB1)
Menu ID : 9 (0x9)
Format : MPEG Video
Format version : Version 2
Format profile : [email protected]
Format settings, BVOP : Yes
Format settings, Matrix : Custom
Format settings, GOP : M=3, N=15
Format settings, picture structure : Frame
Codec ID : 2
Duration : 7mn 22s
Bit rate : 16.8 Mbps
Maximum bit rate : 17.2 Mbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Active Format Description : Letterbox 16:9 image
Frame rate : 29.970 fps
Standard : Component
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Interlaced
Scan order : Top Field First
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.270
Time code of first frame : 10:54:04;20
Time code source : Group of pictures header
Stream size : 884 MiB (92%)
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709

Audio #1
ID : 179 (0xB3)
Menu ID : 9 (0x9)
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : 129
Duration : 7mn 22s
Bit rate mode : Constant
Bit rate : 384 Kbps
Maximum bit rate : 458 Kbps
Channel(s) : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Delay relative to video : 60ms
Stream size : 20.2 MiB (2%)
Language : English
Name : en:Primary Audio

Audio #2
ID : 180 (0xB4)
Menu ID : 9 (0x9)
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : 129
Duration : 7mn 22s
Bit rate mode : Constant
Bit rate : 128 Kbps
Maximum bit rate : 246 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Delay relative to video : 18ms
Stream size : 6.75 MiB (1%)
Language : English
Name : en:Secondary Audio

Text #1
ID : 177 (0xB1)-CC1
Menu ID : 9 (0x9)
Format : EIA-608
Muxing mode : A/53 / DTVCC Transport
Muxing mode, more info : Muxed in Video #1
Duration : 7mn 22s
Bit rate mode : Constant
Stream size : 0.00 Byte (0%)

Text #2
ID : 177 (0xB1)-1
Menu ID : 9 (0x9)
Format : EIA-708
Muxing mode : A/53 / DTVCC Transport
Muxing mode, more info : Muxed in Video #1
Duration : 7mn 22s
Bit rate mode : Constant
Stream size : 0.00 Byte (0%)
Language : English

Menu
ID : 176 (0xB0)
Menu ID : 9 (0x9)
List : 177 (0xB1) (MPEG Video) / 179 (0xB3) (AC-3, English) / 180 (0xB4) (AC-3, English)
Language : / English / English
Law rating : E
Maximum bit rate : 18861200

Gadgetguy
Posts: 100
Joined: Fri Aug 15, 2014 2:55 am

Re: GPU accelerated mpv media player combined with smplayer

Sun May 15, 2016 1:08 am

gkreidl wrote:I've never seen an MPEG coded stream of such a resolution before. Could you run mediainfo on the file, please?
Incidentally I recorded this sample video from an over the air broadcast with the ATI Theater HD 750 USB TV Tuner :

http://www.amazon.com/Diamond-TVW750USB ... op?ie=UTF8

It records over the air broadcasts in high definition as ts but will only record cable tv broadcasts in sd via a composite video input. I watch tv over cable and over the years I recorded a lot of cable content in sd but haven't really used it for hi definition recording. as in my area there are not many over the air stations worth recording. It is my understanding that that in North America the over the air broadcasts using the ATSC standard are uncompressed ts and of signifigantly higher quality than the compressed hd tv broadcast over cable.
A few months back I bought a new toy on a great sale the Hauppauge HD PVR Rocket Portable Stand Alone HD 1080p Video Recorder::
https://www.amazon.ca/Hauppauge-Rocket- ... pvr+rocket

It has component ( not composite) hd inputs and I was successful in recording in hd some cable tv programs from the set top box.
with it's one touch button. I was involved with some other things like moving and was unable to try it for a while. Last time I tried to use it I was unsuccessful. Either it had developed some glitch or I had made some error in setting it up. I plan to try it again soon

Gadgetguy
Posts: 100
Joined: Fri Aug 15, 2014 2:55 am

Re: GPU accelerated mpv media player combined with smplayer

Sun May 15, 2016 3:16 am

I also meant to elaborate in my original post( recently re-edited to correct at least some of my atrocious spelling and grammatical errors !) that after installing the compiled version of ffmpeg I installed the repository version of winff (a ffmpeg gui )to try and see if I could get hardware accelerated transcoding. During this process I used the media player " ffplay " which is a utility integrated into winff for previewing the videos to be transcoded. Again using this ffplay utility i was able to play both sd and hd videos in a resizable window with keyboard control of playback including seeking in the transport stream mpeg. The video quality was not as good as with mpv player however and it used more cpu resources. I should also mention the mpeg ts stream referred to by G. Kreidl would seek very slowly in smplayer using mpv but not in mpv player used standalone.
Is anyone aware of an ffplay gui that would work in raspbian?

wiak
Posts: 7
Joined: Sun Sep 02, 2012 9:57 pm

Re: GPU accelerated mpv media player combined with smplayer

Thu Sep 29, 2016 4:37 pm

gkreidl wrote:I have not read all of this but a few things are definitely wrong;
1) 1080p MPEG TS streams are always H264 encoded, and not with MPEG2. So you never need the MPEG 2 license for them. You are mixing up container formats and codecs.
2) There's no problem with seeking in TS streams. I do a lot of HTDV recording of such streams and if I play the recorded files with omxplayer(GUI) seeking works like a charm.
hey there i just updated the guides for mpv 0.20, libass 0.13.3, ffmpeg 3.0.3 with https
Installing https://nwgat.ninja/installing-mpv-with ... -2-3-zero/
Compiling https://nwgat.ninja/compiling-mpv-with- ... -3-zero-2/
hmm to be more correct a .ts file can have any mpeg video codec in it, it can be MPEG-2, AVC (H264) and even HEVC (H.265)

ferrisutanto
Posts: 2
Joined: Sun Jul 30, 2017 2:12 pm

Re: GPU accelerated mpv media player combined with smplayer gui

Sun Jul 30, 2017 2:18 pm

I'm already use your guide from https://nwgat.ninja/quick-easy-compilin ... pberry-pi/ and success..

my question is, can we show OSC (on screen controller), because when in fullscreen, mouse become not visible ..

thanks

Return to “Raspbian”