gravityaddiction
Posts: 11
Joined: Sat Nov 02, 2019 6:03 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Tue Feb 25, 2020 8:51 pm

the waf error has usally been a lack of libmpv1 or libmpv-dev

Code: Select all

sudo apt install libmpv1 libmpv-dev
Then

Code: Select all

cd /home/pi/Vidware_Build/mpv
env LIBRARY_PATH=/opt/vc/lib PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig CPATH=/opt/vc/include ./waf configure --prefix=/usr --enable-rpi --enable-cdda --enable-dvdnav --enable-libbluray
./waf build -j4
sudo checkinstall -y --pkgname mpv --pkgversion 0.29.0 ./waf install
sudo ldconfig

davidhq
Posts: 17
Joined: Mon May 21, 2018 4:15 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Thu Feb 27, 2020 10:37 pm

So what should be done here? If our hero is really gone, then that's it? Was he the only person on the planet with enough patience and desire to make this work? And the rest of us are just incapable of producing a script that would provide an obvious bit of functionality for this shiny new computer?

Maybe this is really something for the foundation to organize or take over? It would really benefit the whole ecosystem long-term.

It seems that this task takes non-trivial amount of resources to do properly and maintain. I'm sure the foundation could find a few capable and knowledgeable people to dedicate to this and pay them accordingly... the benefit for the ecosystem would be asymmetric -- probably by a factor of a few thousand... resources invested vs. benefits for everyone.

davidhq
Posts: 17
Joined: Mon May 21, 2018 4:15 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Thu Feb 27, 2020 10:40 pm

PS: just wanted to let you all know that I posted a comment on the new blog post https://www.raspberrypi.org/blog/new-pr ... -pi-4-2gb/ --- I just asked them if there is any chance they are able to help, then linking to this forum topic. "Comment is awaiting moderation".

If some of you have some other channels of reaching the right people to at least consider it, then please do whatever you can :) If they say they won't or can't do it and explain why (hopefully), then that's it and we should all probably start looking into other ways of achieving our goal. Perhaps even opening a crypto-funding campaign through DAO structure for people to chime in with their work and knowledge and get compensated?

The time is now! Multimedia on RPi4 needs YOU! :)

User avatar
scruss
Posts: 4485
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Fri Feb 28, 2020 6:48 am

ffmpeg and mpv are available as packages in the repo. Maybe not the most recent versions, but that's what you get with Debian. The packaged ones might work fine for you.

The script is difficult to maintain and lacks basic error checking. As is, the Foundation's unlikely to touch it. The OP was spectacularly resistant to helpful suggestions from experienced programmers. Build scripts for other people's software are not the place for self-aggrandizing drama.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 30149
Joined: Sat Jul 30, 2011 7:41 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Tue Mar 03, 2020 4:50 pm

Sooooo...what does this all do that we are not already doing with ffmpeg? Not going to read 14 pages of stuff.

Note that we are moving to more upstream stuff for codecs etc, and working on providing open source drivers for H265 and H264 that work with ffmpeg, VLC and the like. So not sure what the previous few posts asking for Foundation input are all about.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Applications Team.

idfwhywnrp
Posts: 1
Joined: Wed Mar 04, 2020 1:32 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Wed Mar 04, 2020 1:46 pm

davidhq is right.

Drama :
Is there any way to use the raspberrypi 3 or 4 as a media player using mpv ?

On pi 3 or 4 buster the only way to play watchable video (meaning smooth and without screen-tearing on standard videos, no care about 4k 60fps) is to use omxplayer or vlc. But they fail to play many streams.

For mpv the only solution is to use the script of the OP on debian stretch on a raspberry pi 3.

davidhq
Posts: 17
Joined: Mon May 21, 2018 4:15 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Thu Mar 05, 2020 1:14 pm

First of all, thank you for unbanning me... I got banned (by someone) by jumping too hastily with my post and obviously I added irritation on top of some other irritations it seems.

Let me try explaining my view in easier words again: we can all agree that RPi_Mike's language was 'interesting' and colorful... I'm normally also sensitive to this but in this case his work was actually so good that I think this can be overlooked as a rare case of such behaviour... some comments about how his script doesn't handle each edge case etc. are indeed true... but this is the easy part and this particular engineer decided he doesn't want to do it, that's all... I can personally understand him 100% because even with what he did (expect a clean system, have his script execute perfectly and dismiss any other comment from "random people" because you can go crazy finding each person's particular problem with their configuration etc.)

And thank you idfwhywnrp for further clarifyng what is the issue... I'm not an expert in all the various ways codecs etc. work for this whole platform, trying to learn more as I go but for now... If I specifically want MPV and not VLC or something else, then this script is the only thing that produced usable (and actually more or less perfect) results on RPi3 stretch... We can call that "reality freeze"... the whole community knows of only one way to achieve the desired result and this only works on one particular hardware model and one software OS release...

Everyone probably has their own reasons why they want MPV in particular, for me is that I have built a decentralized multimedia system on top of it and it uses mpv's API. For others it may very well be as idfwhywnrp is suggesting that other solutions don't even work reliably... whatever it is, it seems that the above-mentioned solution through this RPi_Mike guy's script is the only thing that really works.

And from here on I don't have a clue what has to be done to make this "reality freeze" more fluid and permanent so that no black magic (as this script seems to be) is needed and that it would work on RPi 3, 4 and hopefully 5 on current and futher Raspbian releases.

If as a first point we can investigate what would be needed for this, then I think this is the first step.

idfwhywnrp wrote:
Wed Mar 04, 2020 1:46 pm
davidhq is right.

Drama :
Is there any way to use the raspberrypi 3 or 4 as a media player using mpv ?

On pi 3 or 4 buster the only way to play watchable video (meaning smooth and without screen-tearing on standard videos, no care about 4k 60fps) is to use omxplayer or vlc. But they fail to play many streams.

For mpv the only solution is to use the script of the OP on debian stretch on a raspberry pi 3.

davidhq
Posts: 17
Joined: Mon May 21, 2018 4:15 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Fri Mar 06, 2020 11:35 am

Hi James,

I copied the exact script that I've been using for some time now into a gist: https://gist.github.com/davidhq/91ecf46 ... bd63e36854

I removed some blank lines etc. so it's better readable... I hope this helps a bit so that you can see exactly what is happening and you don't have to hunt over this lengthy discussion.
jamesh wrote:
Tue Mar 03, 2020 4:50 pm
Sooooo...what does this all do that we are not already doing with ffmpeg? Not going to read 14 pages of stuff.

Note that we are moving to more upstream stuff for codecs etc, and working on providing open source drivers for H265 and H264 that work with ffmpeg, VLC and the like. So not sure what the previous few posts asking for Foundation input are all about.

gravityaddiction
Posts: 11
Joined: Sat Nov 02, 2019 6:03 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Tue Mar 10, 2020 11:57 pm

mpv, with the right configure settings works great on the raspberry pi 4 buster.. it actually works well with the latest ffmpeg too.

davidhq
Posts: 17
Joined: Mon May 21, 2018 4:15 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Wed Mar 11, 2020 1:41 am

gravityaddiction wrote:
Tue Mar 10, 2020 11:57 pm
mpv, with the right configure settings works great on the raspberry pi 4 buster.. it actually works well with the latest ffmpeg too.
Can you give exact instructions maybe? Would appreciate that... then in a day or two I will let you know if it works without glitches. Usually people think it works because they tried a video, two or even ten... but with serious usage all kinds of edge cases appear which negate the whole promise of mpv working well... I actually tried a few things and was happy at first, thinking that it is fine but soon many problems in specific places appeared.

gravityaddiction
Posts: 11
Joined: Sat Nov 02, 2019 6:03 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Fri Mar 13, 2020 1:48 am

davidhq wrote:
Wed Mar 11, 2020 1:41 am
Can you give exact instructions maybe? Would appreciate that... then in a day or two I will let you know if it works without glitches.
raw.githubusercontent.com/gravity-addiction/rpi-mpv/master/install-mpv.sh You can run this and re-run this on the same system. It cleans and re-downloads the build folders each time. I've run it on fresh raspberrian and already running systems, Raspberry Pi 3a+, 3b+, and Pi4. Thinkin about it, I should try to grab a copy of a lite edition and give it a try.

most of the downloaded libraries involved can be updated to the latest versions, most already are tho. I've compiled several different versions of ffmpeg including a recent github master branch. the Key here is using waf-2.0.9 to compile mpv with whatever ffmpeg you compiled. Likely any issue you're having isn't with mpv as much as it's likely with ffmpeg. There are some different config switches for the rpi4 vs the rpi3 for compiling ffmpeg, --extra-cflags specifically. There are a couple patches to help compile mpv on the rpi platform.

Always looking for constructive feedback, it's hard to be perfect, even after several tries. With some patience we can work through the edge case problems and pass those fixes onto the community.

There is a ton of work done in the LibreElec repo github.com/LibreELEC/LibreELEC.tv/tree/master/packages/multimedia/ffmpeg/patches that you should try including and help along your way as well. I poked at using their patches a little bit, I was able to compile ffmpeg and a few firmware library links from compiling mpv. At some point i'll get back and get through that hump, the patches mainly focused around 4k hvec, v4l2, a sprinkle of fixes.. When I get those all figured out i'll add them to the install-mpv.sh script.. for now if you want to patch them yourself use something like..

to patch, cd to the ffmpeg source folder and run

Code: Select all

patch -p0 -i filename.patch


to reverse the patch goto the same ffmpeg source folder and add -R

Code: Select all

patch -p0 -R -i filename.patch

Viniuau
Posts: 2
Joined: Wed Mar 25, 2020 2:47 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Wed Mar 25, 2020 2:54 am

I've used gravityaddiction's script and it works great, but I doesn't compile with Lua support.
What could it be? It's a main problem for me as I use it mainly to play YouTube videos and to use other Lua scripts. And the OSC is very handy.

gingis
Posts: 5
Joined: Sun Jul 02, 2017 10:11 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sat Mar 28, 2020 1:30 pm

Hello ,

thank you very much for your help!

Tried this today on my Raspberry Pi2-B with Raspian 10.3 Buster

the error occured here

Code: Select all

[122/238] Compiling video/filter/refqueue.c
../video/out/opengl/hwdec_vaegl.c: In function ‘mapper_map’:
../video/out/opengl/hwdec_vaegl.c:373:24: error: ‘EGL_DMA_BUF_PLANE1_FD_EXT’ undeclared (first use in this function); did you mean ‘EGL_DMA_BUF_PLANE0_FD_EXT’?
             ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _FD_EXT, \
                        ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:334:31: note: in definition of macro ‘ADD_ATTRIB’
     attribs[num_attribs++] = (name);                    \
                               ^~~~
../video/out/opengl/hwdec_vaegl.c:383:13: note: in expansion of macro ‘ADD_PLANE_ATTRIBS’
             ADD_PLANE_ATTRIBS(1);
             ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:373:24: note: each undeclared identifier is reported only once for each function it appears in
             ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _FD_EXT, \
                        ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:334:31: note: in definition of macro ‘ADD_ATTRIB’
     attribs[num_attribs++] = (name);                    \
                               ^~~~
../video/out/opengl/hwdec_vaegl.c:383:13: note: in expansion of macro ‘ADD_PLANE_ATTRIBS’
             ADD_PLANE_ATTRIBS(1);
             ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:375:24: error: ‘EGL_DMA_BUF_PLANE1_OFFSET_EXT’ undeclared (first use in this function); did you mean ‘EGL_DMA_BUF_PLANE0_OFFSET_EXT’?
             ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _OFFSET_EXT, \
                        ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:334:31: note: in definition of macro ‘ADD_ATTRIB’
     attribs[num_attribs++] = (name);                    \
                               ^~~~
../video/out/opengl/hwdec_vaegl.c:383:13: note: in expansion of macro ‘ADD_PLANE_ATTRIBS’
             ADD_PLANE_ATTRIBS(1);
             ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:377:24: error: ‘EGL_DMA_BUF_PLANE1_PITCH_EXT’ undeclared (first use in this function); did you mean ‘EGL_DMA_BUF_PLANE0_PITCH_EXT’?
             ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _PITCH_EXT, \
                        ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:334:31: note: in definition of macro ‘ADD_ATTRIB’
     attribs[num_attribs++] = (name);                    \
                               ^~~~
../video/out/opengl/hwdec_vaegl.c:383:13: note: in expansion of macro ‘ADD_PLANE_ATTRIBS’
             ADD_PLANE_ATTRIBS(1);
             ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:373:24: error: ‘EGL_DMA_BUF_PLANE2_FD_EXT’ undeclared (first use in this function); did you mean ‘EGL_DMA_BUF_PLANE0_FD_EXT’?
             ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _FD_EXT, \
                        ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:334:31: note: in definition of macro ‘ADD_ATTRIB’
     attribs[num_attribs++] = (name);                    \
                               ^~~~
../video/out/opengl/hwdec_vaegl.c:385:13: note: in expansion of macro ‘ADD_PLANE_ATTRIBS’
             ADD_PLANE_ATTRIBS(2);
             ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:375:24: error: ‘EGL_DMA_BUF_PLANE2_OFFSET_EXT’ undeclared (first use in this function); did you mean ‘EGL_DMA_BUF_PLANE0_OFFSET_EXT’?
             ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _OFFSET_EXT, \
                        ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:334:31: note: in definition of macro ‘ADD_ATTRIB’
     attribs[num_attribs++] = (name);                    \
                               ^~~~
../video/out/opengl/hwdec_vaegl.c:385:13: note: in expansion of macro ‘ADD_PLANE_ATTRIBS’
             ADD_PLANE_ATTRIBS(2);
             ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:377:24: error: ‘EGL_DMA_BUF_PLANE2_PITCH_EXT’ undeclared (first use in this function); did you mean ‘EGL_DMA_BUF_PLANE0_PITCH_EXT’?
             ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _PITCH_EXT, \
                        ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:334:31: note: in definition of macro ‘ADD_ATTRIB’
     attribs[num_attribs++] = (name);                    \
                               ^~~~
../video/out/opengl/hwdec_vaegl.c:385:13: note: in expansion of macro ‘ADD_PLANE_ATTRIBS’
             ADD_PLANE_ATTRIBS(2);
             ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:373:24: error: ‘EGL_DMA_BUF_PLANE3_FD_EXT’ undeclared (first use in this function); did you mean ‘EGL_DMA_BUF_PLANE0_FD_EXT’?
             ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _FD_EXT, \
                        ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:334:31: note: in definition of macro ‘ADD_ATTRIB’
     attribs[num_attribs++] = (name);                    \
                               ^~~~
../video/out/opengl/hwdec_vaegl.c:387:13: note: in expansion of macro ‘ADD_PLANE_ATTRIBS’
             ADD_PLANE_ATTRIBS(3);
             ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:375:24: error: ‘EGL_DMA_BUF_PLANE3_OFFSET_EXT’ undeclared (first use in this function); did you mean ‘EGL_DMA_BUF_PLANE0_OFFSET_EXT’?
             ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _OFFSET_EXT, \
                        ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:334:31: note: in definition of macro ‘ADD_ATTRIB’
     attribs[num_attribs++] = (name);                    \
                               ^~~~
../video/out/opengl/hwdec_vaegl.c:387:13: note: in expansion of macro ‘ADD_PLANE_ATTRIBS’
             ADD_PLANE_ATTRIBS(3);
             ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:377:24: error: ‘EGL_DMA_BUF_PLANE3_PITCH_EXT’ undeclared (first use in this function); did you mean ‘EGL_DMA_BUF_PLANE0_PITCH_EXT’?
             ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _PITCH_EXT, \
                        ^~~~~~~~~~~~~~~~~
../video/out/opengl/hwdec_vaegl.c:334:31: note: in definition of macro ‘ADD_ATTRIB’
     attribs[num_attribs++] = (name);                    \
                               ^~~~
../video/out/opengl/hwdec_vaegl.c:387:13: note: in expansion of macro ‘ADD_PLANE_ATTRIBS’
             ADD_PLANE_ATTRIBS(3);
             ^~~~~~~~~~~~~~~~~

Waf: Leaving directory `/home/pi/Vidware_Build/mpv/build'
Build failed
 -> task in 'objects' failed with exit status 1 (run with -v to display more information)

gingis
Posts: 5
Joined: Sun Jul 02, 2017 10:11 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sat Mar 28, 2020 6:08 pm

i tried also with
uDistributor ID: Raspbian
Description: Raspbian GNU/Linux 9.11 (stretch)
Release: 9.11
Codename: stretch
and there are also errors

Code: Select all

Checking for Raspberry Pi support                                 : no 
You manually enabled the feature 'rpi', but the autodetection check failed.



------------------------------
Now building mpv. This will take about 2 minutes.
------------------------------

The project was not configured: run "waf configure" first!



------------------------------
Now installing mpv. This will take about 1 minute.
------------------------------


checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.


The package documentation directory ./doc-pak does not exist. 
Should I create a default set of package docs?  [y]: y

Preparing package documentation...OK

*****************************************
**** Debian package creation selected ***
*****************************************

This package will be built according to these values: 

0 -  Maintainer: [ root@raspberrypi ]
1 -  Summary: [ Package created with checkinstall 1.6.2 ]
2 -  Name:    [ mpv ]
3 -  Version: [ 0.29.0 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ armhf ]
8 -  Source location: [ mpv ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ mpv ]
12 - Conflicts: [  ]
13 - Replaces: [  ]

Enter a number to change any of them or press ENTER to continue: 

Installing with ./waf install...

========================= Installation results ===========================
The project was not configured: run "waf configure" first!

****  Installation failed. Aborting package creation.

Cleaning up...OK

Please advise on how to proceed, thank you!

gingis
Posts: 5
Joined: Sun Jul 02, 2017 10:11 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sat Mar 28, 2020 6:15 pm

the rror i get is

Code: Select all

You manually enabled the feature 'rpi', but the autodetection check failed.
this on a fresh installation of Raspbian Stretch -

is this because i am using Raspberry Pi2?

gravityaddiction
Posts: 11
Joined: Sat Nov 02, 2019 6:03 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Wed Apr 01, 2020 8:16 pm

gingis wrote:
Sat Mar 28, 2020 6:15 pm
is this because i am using Raspberry Pi2?
I believe so Yes, i have only tested it on 3a+, 3b+ and 4b+

gravityaddiction
Posts: 11
Joined: Sat Nov 02, 2019 6:03 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Wed Apr 01, 2020 8:27 pm

Viniuau wrote:
Wed Mar 25, 2020 2:54 am
I've used gravityaddiction's script and it works great, but I doesn't compile with Lua support.
What could it be? It's a main problem for me as I use it mainly to play YouTube videos and to use other Lua scripts. And the OSC is very handy.

It's a bit odd that lua support isn't compiled for you. I was just able to successfully test it with the mpv.io example. I put the script into

~/.config/mpv/scripts/

airon11
Posts: 15
Joined: Fri Apr 03, 2020 5:16 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Fri Apr 03, 2020 5:18 pm

I was able to run the script and compile everything without errors in my raspberry pi 4 with raspbian latest...but when i start a video with mpv i get:

Playing: 2020.AMA.Supercross.Rd.09.Atlanta.720p.HDTV.x264-WRCR.mkv
(+) Video --vid=1 (*) (h264 1280x720 59.940fps)
(+) Audio --aid=1 --alang=eng (*) (aac 2ch 48000Hz)
Using hardware decoding (mmal).
AO: [alsa] 48000Hz stereo 2ch float
VO: [rpi] 1280x720 mmal
* failed to add service - already in use?

any help please?
thank you

gingis
Posts: 5
Joined: Sun Jul 02, 2017 10:11 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sat Apr 04, 2020 10:33 am

gingis wrote:
Sat Mar 28, 2020 6:15 pm
the rror i get is

Code: Select all

You manually enabled the feature 'rpi', but the autodetection check failed.
this on a fresh installation of Raspbian Stretch -

is this because i am using Raspberry Pi2?
can play bluray even on the raspberry pi1 model+, so i think it should not be problem to adapt the script for the raspberry pi2?
or are there so big differences between model 2 and 3?

Thank you!

redhotiron2004
Posts: 1
Joined: Tue Apr 14, 2020 12:09 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Tue Apr 14, 2020 12:13 am

I am on stretch 9.11 with my raspberry pi3b not the plus version. Can anyone confirm that this original script on the first page still works. I am having a fresh install and would like to try it out. Thanks.

AtTheHakShack
Posts: 3
Joined: Wed Apr 29, 2020 6:56 pm

FIXED! Build FFmpeg and mpv – Automatically in 54 Minutes!

Wed Apr 29, 2020 7:54 pm

I finally got Mike's script to work with some updates and modifications. I am using a Raspberry PI 3B+ with Raspbian Buster.

At the bottom of this post is my updated script that I now use to automatically download and build a GPU accelerated mpv on my Raspberry Pi.

WARNING: The lame decoder occasionally fails to download from sourceforge for some reason. If lame fails to download, just download it manually and move it to the /home/pi/Vidware_Downloads folder and run the script again. The command to download it manually is

Code: Select all

wget -q --show-progress --no-use-server-timestamps https://downloads.sourceforge.net/lame/lame-3.100.tar.gz
Then copy it to the proper folder with

Code: Select all

cp lame-3.100.tar.gz /home/pi/Vidware_Downloads
Also, remember that to use GPU rendering in mpv, you still need to make change sure you have allotted at least 128 to the GPU by adding gpu_mem=128 to /boot/config.txt.

Otherwise, the script seems to download, build, and install everything successfully. Hopefully, this will save some people out there a LOT of wasted time and frustration that I had to deal with to mpv working properly.

Below is the updated script:

Code: Select all

#!/bin/bash

##### Vidware_Downloads: My script philosophy is to keep things clean and simple. That's why my first step is to create 3 different folders to keep the main elements of my script completely separate from each other. Before anything can be built, we first have to download 6 files in the form of "stable release tarballs". This is the raw source code my script will use to build the 6 programs. We also need 4 GPU-related files from the Raspberry Pi Foundation's official GitHub site that provide OpenGL ES and EGL support (they allow mpv to "talk" to the Raspberry's VideoCore GPU and thus facilitate hardware acceleration). Finally, we need a "waf" file that will allow us to build mpv. All of this will go inside the "Vidware_Downloads" folder – which we're creating with the mkdir command:


mkdir Vidware_Downloads






##### Vidware_Build: This is the folder where all our "building" will take place – the folder where the raw source code of 6 programs will be compiled and transformed into working software. The "primary" programs are FFmpeg and mpv. But my script also builds a mandatory library called libass – a subtitle renderer that mpv requires. It also builds an advanced H.264 video encoder (x264) and two advanced audio encoders (Fraunhofer AAC and LAME MP3):


mkdir Vidware_Build






##### Vidware_Packages: This folder will remain empty until the very end of the script. When the script is about 95% complete, all 6 programs will be fully built, installed, and "packaged". These packages are free-standing Debian installers (commonly known as .deb files). What makes these so incredibly useful is that at any time, you can use them to automatically install (or re-install) all the programs on another Raspberry or your existing Raspberry in the future – IN ONLY ONE MINUTE! No scripts or "building" required! My script will conveniently place all of them in the Vidware_Packages folder – so be sure to back them up to a safe place!


mkdir Vidware_Packages






##### I've discovered an odd quirk about checkinstall: If we don't manually create a standard usr doc path before running it, checkinstall will fail to install some of our programs. This affects the LAME MP3 encoder – but not having the path up to "doc" also affects FFmpeg (even if you don't build or install LAME). This command line takes care of that:

sudo mkdir -p /usr/share/doc/lame






##### You'll see a lot of "echo" commands in my script. Why? Because I like VISUAL SEPARATION. A simple echo command inserts a blank line in Terminal's output:


echo; echo






##### The echo command is also the tool I'm using to "print" information on the Terminal screen – such as letting the user know that we're about to download the tarballs. I also "pipe" the output of echo through the "fold" command with the "-s" option. This ensures my longer sentences are properly "word wrapped" and that my words aren't abruptly cut in half when they hit the edge of your Terminal screen:


echo "------------------------------"
echo "Now downloading the source code tarballs and other essential files for building FFmpeg, mpv, and the 3 advanced encoders. At a connection speed of 1 MB per second, it will take less than 20 seconds." | fold -s
echo "------------------------------"
echo






##### We're about to download all the files that the script needs. It may look like a lot, but the grand total is less than 18 MB! This is quite impressive when you consider that FFmpeg alone contains more than one MILLION lines of source code! Before we do the downloads, however, we need to change our current working directory to the Vidware_Downloads folder with the cd command:


cd /home/pi/Vidware_Downloads






##### This is where my script downloads the 11 files it needs. At the time of this writing – August 2018 – all URLs link to the most recent versions available. Be careful if you think you can simply update these links to get even more recent versions in the future! Other parts of my script make specific assumptions about these particular versions. So unless you fully understand all aspects of my script, you definitely don't want to do that!


wget -q --show-progress --no-use-server-timestamps https://ffmpeg.org/releases/ffmpeg-4.0.2.tar.bz2

wget -q --show-progress --no-use-server-timestamps https://github.com/mpv-player/mpv/archive/v0.29.0.tar.gz

wget -q --show-progress --no-use-server-timestamps https://github.com/libass/libass/releases/download/0.14.0/libass-0.14.0.tar.gz

wget -q --show-progress --no-use-server-timestamps https://download.videolan.org/x264/snapshots/x264-snapshot-20180831-2245-stable.tar.bz2

wget -q --show-progress --no-use-server-timestamps https://downloads.sourceforge.net/opencore-amr/fdk-aac-0.1.6.tar.gz

wget -q --show-progress --no-use-server-timestamps https://downloads.sourceforge.net/lame/lame-3.100.tar.gz

wget -q --show-progress --no-use-server-timestamps https://github.com/raspberrypi/firmware/raw/master/hardfp/opt/vc/lib/libGLESv2.so

wget -q --show-progress --no-use-server-timestamps https://github.com/raspberrypi/firmware/raw/master/hardfp/opt/vc/lib/libEGL.so

##### AtTheHakShack : I modified this since the original glesv2.pc files is no longer in this repository and have been replaced by the below file
wget -q --show-progress --no-use-server-timestamps https://github.com/raspberrypi/firmware/raw/master/hardfp/opt/vc/lib/pkgconfig/brcmglesv2.pc

##### AtTheHakShack : I modified this since the original egl.pc file is no longer in this repository and have been replaced by the below file
wget -q --show-progress --no-use-server-timestamps https://github.com/raspberrypi/firmware/raw/master/hardfp/opt/vc/lib/pkgconfig/brcmegl.pc

wget -q --show-progress --no-use-server-timestamps https://waf.io/waf-2.0.9






##### For backup purposes – and for mental clarity – I deliberately decided not to "wget" the files directly into their ultimate destinations. Instead, I wanted all the downloads to first be consolidated into the Vidware_Downloads folder – and then copy them over, later on, into wherever they need to be. So that's what I'm doing here. Sudo is required, by the way, because the opt parent folder (and its children) are owned by user "root", not "pi". If we didn't add the "sudo", we would get a "permission denied" error:


sudo cp libGLESv2.so /opt/vc/lib

sudo cp libEGL.so /opt/vc/lib

##### AtTheHakShack : Updated to copy the correct (new) file instead of the old glesv2.pc file
sudo cp brcmglesv2.pc /opt/vc/lib/pkgconfig

##### AtTheHakShack : Updated to copy the correct (new) file instead of the old egl.pc file
sudo cp brcmegl.pc /opt/vc/lib/pkgconfig






##### The script downloaded version 2.0.9 of waf (the version that mpv 0.29.0 expects). But mpv also expects the file to simply be named "waf", not "waf-2.0.9". That's why I'm renaming it here with the mv command. Finally, since waf is a Python script that needs to be executed in order to build mpv, I'm using the chmod command to make it executable by the user that owns the file (which in this case is the user named pi):

mv waf-2.0.9 waf

chmod u+x waf






##### This makes an exact copy of our 6 source code tarballs (for FFmpeg, mpv, etc.) and places them inside the Vidware_Build folder. Some of the tarballs end in tar.gz, while others end in tar.bz2 – hence the 2 separate lines:


cp *.gz /home/pi/Vidware_Build

cp *.bz2 /home/pi/Vidware_Build







##### We're pretty much all done with the Vidware_Downloads folder at this point – so we now need to make sure the script is performing its actions inside the Vidware_Build folder. That's why we cd into it. We then need to "unzip" the 6 source code tarballs into folders – that's what the 2 "ls" lines with the xargs command does (for technical reasons, you can't use a simple asterisk wildcard to unzip multiple tarballs in the same folder). Finally, I delete all the tarballs in the build folder with the rm command. Why? Because we already have the original copy of them in our Vidware_Downloads folder – so there's no reason to clutter things up with duplicate tarballs!


cd /home/pi/Vidware_Build

ls *.gz | xargs -n1 tar xzf

ls *.bz2 | xargs -n1 tar jxf

rm *.gz

rm *.bz2






##### I don't want to keep seeing "fdk-aac-0.1.6" as the source code folder name, for example. That's just confusing. Instead, I just want to see "aac" – because that's what it really is. It's the AAC audio encoder! That's why I'm simplifying all the source code folder names by renaming them with the mv command:


mv ffmpeg* ffmpeg

mv mpv* mpv

mv x264* x264

mv fdk* aac

mv lame* mp3

mv libass* libass






##### We can now copy over the waf file into the mpv source code folder:


cp /home/pi/Vidware_Downloads/waf /home/pi/Vidware_Build/mpv






##### This is where we install the dependencies we need to build all 6 pieces of software – via "sudo apt-get install". Read my statement in the echo line for more detail:


echo; echo
echo "------------------------------"
echo "Now downloading and installing the dependencies – essential packages from the official Raspbian repository that are needed to build the programs. At a connection speed of 1 MB per second, it will take less than 50 seconds to download. It will then take about 5 minutes for your system to install all the packages." | fold -s
echo "------------------------------"
echo

sudo apt-get install -y automake checkinstall libsdl2-dev libva-dev libluajit-5.1-dev libgles2-mesa-dev libtool libvdpau-dev libxcb-shm0-dev texinfo libfontconfig1-dev libfribidi-dev python-docutils libbluray-dev libjpeg-dev libtheora-dev libvorbis-dev libgnutls28-dev linux-headers-rpi2 libomxil-bellagio-dev xdotool libcdio-cdda-dev libcdio-paranoia-dev libdvdread-dev libdvdnav-dev libbluray-dev






##### This begins the "software building" phase of my script. We're configuring and compiling the source code for our first program – the advanced x264 video encoder. That's what people mean by "building" a program. In the "./configure" line, we're enabling and disabling various options that will customize the build in the manner necessary for everything to work. We then compile the program with the "make -j4" command – which is quite impressive given that the "j4" means that all 4 cores inside the Raspberry's CPU will be computing simultaneously! For more information on how to use the encoders with FFmpeg, please see my extremely detailed appendices. After the x264 encoder is fully built, I use the checkinstall command to both install the program and "package it up" into the extremely useful .deb installer packages I mentioned earlier. The final line – sudo ldconfig – is essential in making sure the "shared libraries" are properly recognized.


echo; echo
echo "------------------------------"
echo "Now building the x264 video encoder. This will take about 2 to 3 minutes." | fold -s
echo "------------------------------"
echo

cd /home/pi/Vidware_Build/x264

./configure --prefix=/usr --enable-shared --disable-opencl --extra-cflags="-march=armv8-a+crc -mfpu=neon-fp-armv8 -mtune=cortex-a53"

make -j4

sudo checkinstall -y --pkgname x264 --pkgversion 0.155 make install

sudo ldconfig






##### We now move on to build and install the Fraunhofer AAC audio encoder. I don't need to say much here because I already described the basic outline of the "building from source code" process in my above comments about the x264 encoder.


echo; echo; echo
echo "------------------------------"
echo "Now building the Fraunhofer AAC audio encoder. This will take about 3 to 4 minutes." | fold -s
echo "------------------------------"
echo

cd /home/pi/Vidware_Build/aac

./autogen.sh

./configure --prefix=/usr --enable-shared

make -j4

sudo checkinstall -y --pkgname fdk-aac --pkgversion 0.1.6 make install

sudo ldconfig






##### Now we build and install the LAME MP3 audio encoder:


echo; echo; echo
echo "------------------------------"
echo "Now building the LAME MP3 audio encoder. This will take about 1 minute." | fold -s
echo "------------------------------"
echo

cd /home/pi/Vidware_Build/mp3

./configure --prefix=/usr --enable-shared

make -j4

sudo checkinstall -y --pkgname mp3lame --pkgversion 3.100 make install

sudo ldconfig






##### Now we build and install the libass subtitle renderer (mpv will not work without this software library):


echo; echo; echo
echo "------------------------------"
echo "Now building the libass subtitle renderer. This will take about 1 minute." | fold -s
echo "------------------------------"
echo

cd /home/pi/Vidware_Build/libass

./configure --prefix=/usr --enable-shared

make -j4

sudo checkinstall -y --pkgname libass --pkgversion 0.14.0 make install

sudo ldconfig






##### Now we build and install FFmpeg! This is the very powerful media "engine" at the center of everything we're doing. The last 3 "--enable" lines under "./configure" enable FFmpeg to access the 3 advanced encoders – x264, Fraunhofer AAC, and LAME MP3. Compiling a million+ lines of code is INTENSE and could easily overheat your CPU. Your Raspberry must therefore have its own small fan or an external fan blowing on it. Please see the explicit warnings on this subject in my instructions!


echo; echo; echo
echo "------------------------------"
echo "Now preparing to build FFmpeg. This will take about 2 minutes." | fold -s
echo "------------------------------"
echo

cd /home/pi/Vidware_Build/ffmpeg

./configure \
--prefix=/usr \
--enable-gpl \
--enable-nonfree \
--enable-static \
--enable-libtheora \
--enable-libvorbis \
--enable-omx \
--enable-omx-rpi \
--enable-mmal \
--enable-libxcb \
--enable-libfreetype \
--enable-libass \
--enable-gnutls \
--disable-opencl \
--enable-libcdio \
--enable-libbluray \
--extra-cflags="-march=armv8-a+crc -mfpu=neon-fp-armv8 -mtune=cortex-a53" \
--enable-libx264 \
--enable-libfdk-aac \
--enable-libmp3lame

echo; echo; echo
echo "------------------------------"
echo "Now building FFmpeg. This will take about 24 minutes on the Raspberry 3B+ (and 2 or 3 minutes longer on the 3B)." | fold -s
echo "------------------------------"
echo

make -j4

echo; echo; echo
echo "------------------------------"
echo "Now installing FFmpeg. This will take about 7 minutes." | fold -s
echo "------------------------------"
echo

sudo checkinstall -y --pkgname ffmpeg --pkgversion 4.0.2 make install

sudo ldconfig






##### Now we build and install mpv. Unlike the prior builds which were fairly straightforward, I'll add a few extra comments here – because I had to do quite a bit of arcane tweaking to successfully "port" mpv to the Raspberry platform with full GPU-based hardware acceleration.


echo; echo; echo
echo "------------------------------"
echo "Now preparing to build mpv. This will take about 1 minute." | fold -s
echo "------------------------------"
echo

cd /home/pi/Vidware_Build/mpv






##### In this section, I'm using the sed command to manipulate mpv's raw source code before we build it. The first edit specifically targets line 767 of mpv's wscript file. The wscript file contains the "building instructions" for mpv. There are more than 1,100 lines of code in the file, but only 18 of them are directly related to the Raspberry. The line I'm editing makes reference to a generic OpenGL ES "linkflag". With the sed command, I'm doing a "search & replace" so that it will now make reference to the Broadcom-specific version of the linkflag (Broadcom is the manufacturer of the Raspberry's VideoCore GPU). Beginning with the next line, I delete an entire stanza (13 lines) of audio-related source code and then replace it with 20 lines of modified and expanded code. Specifically, it affects how mpv interacts with the ALSA framework. Without this change, mpv would throw various audio-related "[ao/alsa]" errors. Hat tip: My ALSA source code patch combines the ideas of mpv contributor "orbea" and user "yumkam" on mpv's official GitHub site. And then we have the final sed line – it serves absolutely no purpose other than to give a bit of credit to yours truly!


sed -i_BACKUP '767s|GLESv2|brcmGLESv2|g' /home/pi/Vidware_Build/mpv/wscript

sed -i_BACKUP '939,951d' /home/pi/Vidware_Build/mpv/audio/out/ao_alsa.c

sed -i '939i\
\
\
static int get_space(struct ao *ao)\
{\
int err;\
struct priv *p = ao->priv;\
\
snd_pcm_state_t state = snd_pcm_state(p->alsa);\
snd_pcm_sframes_t space = state == SND_PCM_STATE_SETUP || state == SND_PCM_STATE_PAUSED\
? p->buffersize : snd_pcm_avail(p->alsa);\
if (space < 0) {\
if (space == -EPIPE) { // EOF\
err = snd_pcm_prepare(p->alsa);\
CHECK_ALSA_ERROR("pcm recover error");\
return p->buffersize;\
}\
\
MP_ERR(ao, "Error received from snd_pcm_avail (%ld, %s)!\\n",\
space, snd_strerror(space));\
\
// request a reload of the AO if device is not present,\
// then error out.\
\
' /home/pi/Vidware_Build/mpv/audio/out/ao_alsa.c

sed -i_BACKUP '143s|built on|built by the RPi_Mike script on|g' /home/pi/Vidware_Build/mpv/player/main.c

##### AtTheHakShack : We need to add some code to the /home/pi/Vidware_Build/mpv/video/out/opengl/hwdec_vaegl.c file or compiling mpv will fail.
sed -i_BACKUP '54c\
#define EGL_DMA_BUF_PLANE1_FD_EXT          0x3275\
#define EGL_DMA_BUF_PLANE1_OFFSET_EXT      0x3276\
#define EGL_DMA_BUF_PLANE1_PITCH_EXT       0x3277\
#define EGL_DMA_BUF_PLANE2_FD_EXT          0x3278\
#define EGL_DMA_BUF_PLANE2_OFFSET_EXT      0x3279\
#define EGL_DMA_BUF_PLANE2_PITCH_EXT       0x327A\
#define EGL_DMA_BUF_PLANE3_FD_EXT          0x3440\
#define EGL_DMA_BUF_PLANE3_OFFSET_EXT      0x3441\
#define EGL_DMA_BUF_PLANE3_PITCH_EXT       0x3442\
#endif\
\
#ifndef EGL_EXT_image_dma_buf_import_modifiers\
#define EGL_EXT_image_dma_buf_import_modifiers 1\
#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443\
#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444\
#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445\
#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446\
#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447\
#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448\
#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449\
#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A\
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);\
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLBoolean *external_only, EGLint *num_modifiers);\
#ifdef EGL_EGLEXT_PROTOTYPES\
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufFormatsEXT (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);\
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufModifiersEXT (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLBoolean *external_only, EGLint *num_modifiers);\
#endif\
#endif /* EGL_EXT_image_dma_buf_import_modifiers */\
\
#ifndef EGL_EXT_image_implicit_sync_control\
#define EGL_EXT_image_implicit_sync_control 1\
#define EGL_IMPORT_SYNC_TYPE_EXT          0x3470\
#define EGL_IMPORT_IMPLICIT_SYNC_EXT      0x3471\
#define EGL_IMPORT_EXPLICIT_SYNC_EXT      0x3472\
#endif /* EGL_EXT_image_implicit_sync_control */\
' /home/pi/Vidware_Build/mpv/video/out/opengl/hwdec_vaegl.c


##### The next 3 lines temporarily define the proper paths for 3 "environmental variables". Without these, mpv will not compile.


export LIBRARY_PATH=/opt/vc/lib

export PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig

export CPATH=/opt/vc/include






##### This next section is fairly straightforward. This is where we build and install mpv! The only noteworthy point is that instead of using the "make" system to do our building like all the other programs in this script, we're using the "waf" system. That simply reflects the preferences of the mpv developers.


./waf configure --prefix=/usr --enable-rpi --enable-cdda --enable-dvdread --enable-dvdnav --enable-libbluray

echo; echo; echo
echo "------------------------------"
echo "Now building mpv. This will take about 2 minutes." | fold -s
echo "------------------------------"
echo

./waf build -j4

echo; echo; echo
echo "------------------------------"
echo "Now installing mpv. This will take about 1 minute." | fold -s
echo "------------------------------"
echo

sudo checkinstall -y --pkgname mpv --pkgversion 0.29.0 ./waf install

sudo ldconfig






##### This is where we create mpv's configuration file that controls how mpv behaves with ALL video and audio. Please see the full version of Appendix 1 for details; also see the testing section for commentary on the "ytdl-format" line. NOTE: The "alsa-buffer-time" completes the fix to the ALSA issue I described earlier. It defines an audio buffer time of 800,000 microseconds (8/10 of a second). Through extensive testing, I found that this was the final step needed to get mpv and ALSA to play nice together.


mkdir -p /home/pi/.config/mpv

echo "--fullscreen
rpi-background=yes
screenshot-format=png
ytdl-format=bestvideo[height<=?1080][fps<=?30][vcodec!=?vp9]+bestaudio/best
--alsa-buffer-time=800000" > /home/pi/.config/mpv/mpv.conf






##### I didn't want users of my script to have to go through the 10-step "Open With" process in File Manager – over and over again – to associate every common type of video and audio file with mpv. So to save everyone a lot of time and eliminate this error-prone task, my script does it automatically! The first line demonstrates proper "etiquette" – before it creates the new associations, it first backs up your original mimeapps.list file (just in case you'd like to review or re-add your initial file associations). I then associate the following video and audio file types with mpv: MP4, WebM, MKV, TS, MOV, AVI, WMV, MPG, WAV, MP3, M4A, and FLAC.


cp /home/pi/.config/mimeapps.list /home/pi/.config/mimeapps.list_BACKUP &> /dev/null

echo "[Added Associations]
video/mp4=mpv.desktop;
video/webm=mpv.desktop;
video/x-matroska=mpv.desktop;
video/mp2t=mpv.desktop;
video/quicktime=mpv.desktop;
video/x-msvideo=mpv.desktop;
video/x-ms-wmv=mpv.desktop;
video/mpeg=mpv.desktop;
audio/x-wav=mpv.desktop;
audio/mpeg=mpv.desktop;
audio/mp4=mpv.desktop;
audio/flac=mpv.desktop;
text/plain=leafpad.desktop;

[Default Applications]
video/mp4=mpv.desktop
video/webm=mpv.desktop
video/x-matroska=mpv.desktop
video/mp2t=mpv.desktop
video/quicktime=mpv.desktop
video/x-msvideo=mpv.desktop
video/x-ms-wmv=mpv.desktop
video/mpeg=mpv.desktop
audio/x-wav=mpv.desktop
audio/mpeg=mpv.desktop
audio/mp4=mpv.desktop
audio/flac=mpv.desktop
text/plain=leafpad.desktop

[Removed Associations]" > /home/pi/.config/mimeapps.list






##### Raspbian places its overall file association "system" in 2 separate locations. The items above act as a kind of pointer to the item below. The two work hand-in-hand. The following stanza generates a special kind of file known as a "desktop" file that ends with the ".desktop" extension – but also has an "alias" (in this case, "MPV") and an executable line that tells it what to do. My complicated use of bash -c and xdotool is the result of hours of testing – to guarantee that you never lose keyboard control of mpv, due to other windows stealing "focus" from mpv's Terminal window. You see, mpv relies upon an active Terminal window "behind the screen" to detect the keyboard inputs which allow you to control the video or audio being played. Of course, if you actively do things to lose keyboard control – like hitting alt + tab or randomly clicking the screen with your mouse – there's nothing I can do about that!


echo "[Desktop Entry]
Type=Application
Name=MPV
Exec=lxterminal -t mpv_control -e bash -c \"sleep 0.25; xdotool search --name mpv_control windowactivate; mpv %f\"
NoDisplay=true
Icon=mpv" > /home/pi/.local/share/applications/mpv.desktop






##### This section "pins" the advanced versions of the programs my script just built. Without doing this, anytime you run a standard system update via "sudo apt-get upgrade" or "sudo apt-get dist-upgrade", the Raspbian package manager might wrongly think the newly-built programs are old and therefore need to be "upgraded". They might then be overwritten with the older, more primitive versions that exist in the Raspbian repository! Pinning them, in effect, says to your system's packager manager: "Don't touch these programs – leave them alone!" As per standard etiquette, I first back up your preferences file – on the remote chance you've been pinning other packages. Hat tip to "rpdom" for his pinning suggestion.


sudo cp /etc/apt/preferences /etc/apt/preferences_BACKUP &> /dev/null

echo "Package: ffmpeg
Pin: version 4.0.2-1
Pin-Priority: 1001

Package: mpv
Pin: version 0.29.0-1
Pin-Priority: 1001

Package: x264
Pin: version 0.155-1
Pin-Priority: 1001

Package: fdk-aac
Pin: version 0.1.6-1
Pin-Priority: 1001

Package: mp3lame
Pin: version 3.100-1
Pin-Priority: 1001

Package: libass
Pin: version 0.14.0-1
Pin-Priority: 1001" | sudo cp /dev/stdin /etc/apt/preferences

sudo chmod 644 /etc/apt/preferences






##### In some ways, this next section just might be the coolest part of the entire script. That's because it takes the TRILLIONS of computations the script just performed – distilled into 6 tiny packages – and neatly places them in the Vidware_Packages folder. They contain everything you need to reconstitute all the programs on any Raspberry 3B or 3B+ IN ONLY 1 MINUTE! So when the script is all done and the demonstration video has played, be sure to back up the 6 .deb files to a safe location.


echo; echo; echo
echo "------------------------------"
echo "Almost finished! The Debian package files are now in the Vidware_Packages folder. You can use them at any time in the future to install all the programs my script just built! Now downloading youtube-dl and a brief 1080p demonstration video from YouTube. All of this should take less than 2 minutes. After the looped video starts playing, feel free to press the q key to quit." | fold -s
echo "------------------------------"
echo

find /home/pi/Vidware_Build -name '*.deb' -exec mv -t /home/pi/Vidware_Packages {} +






##### This final section does 3 simple things: First, it downloads and installs the latest version of youtube-dl. If you already have it on your system, it will upgrade it (if necessary). If you don't have it, it will make sure you that you do. At that point, youtube-dl will download a very brief 1080p demonstration video from YouTube. And then comes the final act – mpv will play the video several times in a loop! Press q to quit at any time.

##### AtTheHakShack : Changed this from pip to pip3
sudo pip3 install --upgrade youtube_dl

echo; echo

cd /home/pi

youtube-dl -f 137+140 --no-mtime -o Neutron_Stars_Colliding_1080p.mp4 https://www.youtube.com/watch?v=x_Akn8fUBeQ

echo; echo

mpv -version

echo

mpv --loop=9 Neutron_Stars_Colliding_1080p.mp4

AtTheHakShack
Posts: 3
Joined: Wed Apr 29, 2020 6:56 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Thu Apr 30, 2020 12:35 am

redhotiron2004 wrote:
Tue Apr 14, 2020 12:13 am
I am on stretch 9.11 with my raspberry pi3b not the plus version. Can anyone confirm that this original script on the first page still works. I am having a fresh install and would like to try it out. Thanks.
Hey I just wanted to reply to your post and let you know I got the script working with some fixes and posted the fixed script to this same discussion thread if you want to use it.

AtTheHakShack
Posts: 3
Joined: Wed Apr 29, 2020 6:56 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Thu Apr 30, 2020 12:40 am

gingis wrote:
Sat Mar 28, 2020 6:08 pm
i tried also with
uDistributor ID: Raspbian
Description: Raspbian GNU/Linux 9.11 (stretch)
Release: 9.11
Codename: stretch
and there are also errors

Code: Select all

Checking for Raspberry Pi support                                 : no 
You manually enabled the feature 'rpi', but the autodetection check failed.



------------------------------
Now building mpv. This will take about 2 minutes.
------------------------------

The project was not configured: run "waf configure" first!



------------------------------
Now installing mpv. This will take about 1 minute.
------------------------------


checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.


The package documentation directory ./doc-pak does not exist. 
Should I create a default set of package docs?  [y]: y

Preparing package documentation...OK

*****************************************
**** Debian package creation selected ***
*****************************************

This package will be built according to these values: 

0 -  Maintainer: [ root@raspberrypi ]
1 -  Summary: [ Package created with checkinstall 1.6.2 ]
2 -  Name:    [ mpv ]
3 -  Version: [ 0.29.0 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ armhf ]
8 -  Source location: [ mpv ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ mpv ]
12 - Conflicts: [  ]
13 - Replaces: [  ]

Enter a number to change any of them or press ENTER to continue: 

Installing with ./waf install...

========================= Installation results ===========================
The project was not configured: run "waf configure" first!

****  Installation failed. Aborting package creation.

Cleaning up...OK

Please advise on how to proceed, thank you!
Delete all of the Vidware_ folders in your /home/pi folder and then try using my updated script that I posted to this same forum earlier today.

fitipe
Posts: 1
Joined: Tue Apr 07, 2020 2:45 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Mon May 04, 2020 6:04 pm

Hi Mike,

I just wanted to tell you that I really loved your script and it gave a real upgrade on my final art graduation project, here in Brasil. And that I'm looking forward to the Pi4s version, so I can buy the new hardware. That's right, my only current use of a RPI is with mpv and I only trusted its usage for my projects after using your script. ( No hurries! For now, I'm perfectly fine with the Pi3 I still have )

I've read some angry posts above and thought that, in these times of free insults and stupidities, it would be nice to read some good comment about your work.

Thank you a lot!

gravityaddiction
Posts: 11
Joined: Sat Nov 02, 2019 6:03 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Thu May 21, 2020 6:57 pm

airon11 wrote:
Fri Apr 03, 2020 5:18 pm
I was able to run the script and compile everything without errors in my raspberry pi 4 with raspbian latest...but when i start a video with mpv i get:

Playing: 2020.AMA.Supercross.Rd.09.Atlanta.720p.HDTV.x264-WRCR.mkv
(+) Video --vid=1 (*) (h264 1280x720 59.940fps)
(+) Audio --aid=1 --alang=eng (*) (aac 2ch 48000Hz)
Using hardware decoding (mmal).
AO: [alsa] 48000Hz stereo 2ch float
VO: [rpi] 1280x720 mmal
* failed to add service - already in use?

any help please?
thank you
You'll need to REM or remove the vc4-fkms-v3d overlay lines in /boot/config.txt

Code: Select all

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
#dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d

Return to “Graphics, sound and multimedia”