User avatar
RPi_Mike
Posts: 118
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

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

Mon Dec 31, 2018 11:36 pm

migg wrote:
Mon Dec 31, 2018 2:48 am
I found a way to recode h264 faster..... with hw decoding + hw encode

As you discovered, my build of FFmpeg is fully equipped to utilize the Raspberry's GPU – on both the decoding AND encoding sides.

It should be pointed out, however, that re-encoding a video with a "lossy" encoder that's already been encoded with another "lossy" encoder – whether you do it with the GPU or the CPU – is not ideal for the simple reason that each "generation" of encoding will degrade the quality to some degree.

But I fully realize there are some "use cases" when re-encoding is necessary: Any time you wish to fundamentally alter a video's properties, you must re-encode it – such as resizing it, lowering its bit rate, or modifying its visual content. [Unless of course you're the author of the video and still have access to a losslessly-encoded "source file". Then you have the luxury of making any edits you wish before making a brand-new "first generation" encoding – without any penalty in quality whatsoever. Or, if you only need to change the audio track, you can alter it without touching the video track by "passing the video track through" as a direct copy – even if you don't have access to the source file.]

Beyond this, for those that wish to occasionally encode brief videos at the HIGHEST QUALITY POSSIBLE – and don't mind if things take a bit longer – I personally recommend doing everything "in software". In other words, let FFmpeg do everything on the CPU, not the GPU. Yes, the GPU's "hardware acceleration" can be up to 3 times faster at encoding – but you must also realize that the software engineers behind both FFmpeg and x264 have much greater flexibility (and desire) to optimize their code for the general-purpose CPU. And, when you choose the CPU over the GPU, you also have access to a wider range of settings and techniques – including two-pass encoding. Bit for bit, at least on the Raspberry, CPU-based encoding is capable of producing higher-quality results than the GPU.

So if I've spent several hours creating a special effect video, for instance, I'm certainly not going to cut corners at the very last step for the sake of "saving" a few minutes on the encoding.

But if you're pressed for time and have a lot to encode, the GPU could easily be the only logical choice. With sufficiently high bit rates, the GPU delivers surprisingly good results. Not only that, but at SD-level resolutions (640 x 480), the GPU has the raw horsepower to encode the video in REAL TIME!

That's why I'm completely agnostic about CPU vs. GPU-based encoding. Like many things in life, each has its pros and cons. It all depends on what you're trying to do!

wormyrocks
Posts: 2
Joined: Fri Jan 11, 2019 5:48 pm

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

Fri Jan 11, 2019 5:53 pm

Hi,

I've run this script on a clean install of the latest version of Raspbian, following the instructions exactly - when I try to run mpv, I get the following error:

Code: Select all

Playing: Neutron_Stars_Colliding_1080p.mp4
 (+) Video --vid=1 (*) (h264 1920x1080 29.970fps)
 (+) Audio --aid=1 (*) (aac 2ch 44100Hz)
[vo/rpi] Could not get DISPMANX objects.
Is anyone else seeing an issue like this? Thanks!

User avatar
RPi_Mike
Posts: 118
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

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

Sun Jan 13, 2019 4:40 am

wormyrocks wrote:
Fri Jan 11, 2019 5:53 pm
I've run this script on a clean install of the latest version of Raspbian, following the instructions exactly - when I try to run mpv, I get the following error..... Could not get DISPMANX objects.

One of the great things about computer science is that it's a "hard" science like physics or chemistry. Unlike a "softer" science like psychology or climatology, most claims can be verified in a truly definitive way. The biggest test of all is a simple one: Under the same conditions, can the results be fully replicated?

We obviously don't have two Earths on which to conduct comparative studies – nor can we take a 40-year-old back to the womb to see how different the outcome would be if we changed a key behavior in the mother or father.

To be clear, I'm not knocking the "softer" sciences even slightly – I'm simply stating a fact. Sure, we can create supercomputer simulations of multiple Earths and "experiment" on them. We can also look at "twin studies" of genetically identical siblings who were separated at birth to get a good understanding of nature vs. nurture.

These methods, however – though extremely insightful – are hardly as "concrete" and "verifiable" as dropping a steel ball in separate laboratories in London and Tokyo and demonstrating that both objects drop at exactly the same speed to an extreme degree of precision. [Under vacuum conditions while accounting for local variations in the gravitational field, of course.]

That's the beauty of the Raspberry – it brings computer science to life in a fully testable, verifiable, inexpensive, and widely available way. This is especially true if two or more people – or laboratories – both begin with completely identical, clean copies of the Raspbian operating system!

So, just a few minutes ago, I used that scientific principle to test your claim:

I completely nuked an SD card, reinstalled the latest version of Raspbian Desktop, and then followed my own instructions without any assumed knowledge. In other words, I did everything as though I were completely brand-new to the Raspberry.

Now why would I bother doing that if I'm so confident about the perfection of my script? In fact, not a single person – until you came along – has claimed my script didn't work on a truly clean installation of Raspbian.

I did it because there's always the THEORETICAL possibility that the Raspberry Pi Foundation – at any moment – during one of their frequently-issued system updates – could suddenly change a fundamental system component that inadvertently "breaks" my script. So far, this has never happened – but I obviously have no control over what goes on in Cambridge, England.

Well guess what? I'm pleased to report that my script still works perfectly!

To put it mildly, this raises severe doubts about your claim that you've "run this script on a clean install of the latest version of Raspbian, following the instructions exactly".

I'm even more dubious about your claim because the exact error message you report can indeed be replicated – but only if you don't follow my instructions!

For example, if you change the Raspberry's default video driver to the EXPERIMENTAL OpenGL driver – namely Full KMS – mpv will generate the exact same error message you report! Perhaps you recently installed Raspbian – and only made this one "minor" change – thus in your mind, it remained an entirely "clean" copy that fully complied with my instructions. There's just one problem with that perspective: I explicitly stated in my "requirements" section that those experimental drivers will NOT work! It certainly wouldn't be the first time that someone didn't carefully read my comprehensive instructions.

Am I saying that's what you did? Not at all! I'm not the NSA, so I'm not about to make any specific assumptions about what you may or may not have done. Perhaps you tinkered with your system and made some other fundamental change that triggered the same error message by coincidence. Either way, it's not my concern – because none of these scenarios would involve a truly clean, completely standard copy of Raspbian, now would they?

Oh, and just in case you're thinking about switching your Raspberry back to the standard default "legacy" video driver via sudo raspi-config | Advanced Options | GL Driver, there's a bit of a bug in Raspbian that you should know about. When the experimental drivers are switched on, raspi-config will "secretly" change the /boot/config.txt file back to the 64 MB default setting for the GPU memory allocation without telling you! So if you switch back to the default video driver to try and get things working, be sure to re-do my instructions and move your GPU memory back to 128 MB – because if you don't do that, you'll be treated to a whole new batch of error messages that also have nothing to do with my script!

Better yet, if you're not completely sure what you may or may not have done, just nuke your entire system and start all over again from scratch! Otherwise, you could end up wasting several hours because of some obscurity deep inside your system that you don't understand.

Finally, I can't help but mention a supreme irony about your claim: Thanks to your unique but recycled screen name, it only took me a minute to discover that 8 days ago – on January 5, 2019 UTC – you tweeted a sarcastic message about me that says "this guy really likes the shell script he wrote". The irony is that if only you had followed my instructions to the letter, you would have realized just how good my script really is!

But I get it. Some don't like my confident tone – a tone that's clearly evident in my writing style. It's a tone I'm fully aware of, by the way.

I worked hard to achieve what I've done – the proof is in the pudding. I feel zero shame in defending my high-quality contribution – a contribution I've donated for FREE. In fact, I'm the guy that brought a fully GPU-enabled software suite of the world's leading media engine, top-notch encoders, and a truly modern media player to the Raspberry Pi – and presented the whole thing in a clearly-written manner that almost anyone can follow. No one had done all that until I came along.

Knowing that the Raspberry is now a truly historic machine – the best-selling general-purpose computer in the history of the world – eclipsed only by the Mac and PC – makes my contribution even more significant.

Do I sound a bit boastful in the way I phrase things? I certainly hope so – because it's entirely deliberate. When I put a ton of effort into something I know is significant, I'm not about to sacrifice it at the alter of false "modesty" and let it disappear into the noise.

If anyone looks through this giant thread, they'll see that for more than a year, I've had to fight off multiple bogus claims to defend my work. It's amazing how any random person on the Internet can just come along and say WHATEVER! So if people perceive me as having an aggressive posture, they're not mistaken. What some fail to understand, however, is that it's a special kind of aggression – a justified aggression to stand up for what I know to be true!

wormyrocks
Posts: 2
Joined: Fri Jan 11, 2019 5:48 pm

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

Mon Jan 14, 2019 9:38 pm

Christ dude, get a girlfriend or something

User avatar
RPi_Mike
Posts: 118
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

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

Mon Jan 14, 2019 10:52 pm

wormyrocks wrote:
Mon Jan 14, 2019 9:38 pm
Christ dude, get a girlfriend or something

LOL

There's one good thing about your incivility:

It demonstrates the emptiness of your claim.

dennissss
Posts: 2
Joined: Thu Jan 17, 2019 10:19 am

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

Thu Jan 17, 2019 10:32 am

Great job Mike.
I just tried to install it on a raspbian light, and it failed on installing libass, but I found only a Pi 2 laying around, so maybe that was the problem.
Will find a 3+ and try again, any pointers would be greatly appreciated.

//Dennis
Copying files to the temporary directory...OK
Stripping ELF binaries and libraries...OK
Compressing man pages...OK
Building file list...OK
Building Debian package...OK
Installing Debian package... FAILED!
*** Failed to install the package

dennissss
Posts: 2
Joined: Thu Jan 17, 2019 10:19 am

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

Thu Jan 17, 2019 11:07 pm

OK, I'm back.
Didn't find a Pi 3, so I tried again with a Pi 2 B
Was a bit more organized this time and I got it running

The Pi is connected with HDMI to a monitor, I run commands via ssh from another computer

After installing raspbian and updating I checked what I got running

[email protected]:~ $ lsb_release -a

No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.6 (stretch)
Release: 9.6
Codename: stretch


we need 256 meg for GPU so I added this to /boot/config.txt


##################
## GPU MEMORY
##################
##
## gpu_mem_512
## GPU memory allocation in MB for 512MB board revision.
## This option overrides gpu_mem.
##
gpu_mem_512=256

## gpu_mem_1024
## GPU memory allocation in MB for 1024MB board revision.
## This option overrides gpu_mem.
##
gpu_mem_1024=256


then I created a file for the script and made sure (well sure...) there will be not issues with permissions
(in /home/pi/)

sudo touch vidware
sudo chown pi:pi vidware
sudo chmod 777 vidware


checked the file (in /home/pi)

ls -la
-rwxrwxrwx 1 pi pi 0 Jan 17 11:37 vidware


checked it again after pasting the script in the file (now 24k)

ls -la
-rwxrwxrwx 1 pi pi 24129 Jan 17 11:43 vidware




then I run (inside /home/pi)

sudo bash vidware


waited for +1.5 hours for the script to run. (Pi 2 B, constantly complaining about under-voltage, at least it didn't overheat)

The script did not get the file with the colliding stars downloaded, so I downloaded that manually


[email protected]:~ $ mpv --loop=9 Neutron_Stars_Colliding_1080p.f137.mp4
Playing: Neutron_Stars_Colliding_1080p.f137.mp4
(+) Video --vid=1 (*) (h264 1920x1080 29.970fps)
Using hardware decoding (mmal).
VO: [rpi] 1920x1080 mmal
V: 00:00:42 / 00:00:42 (99%)


That one is working fine, although most other files I tried doesn't want to play for different reasons.
Guessing that there was more than the star movie that didn't really make it to the Pi.
Anyways, it's running smooth and looking good.

Thanks for your superb instructions

//Dennis

dennissss wrote: Great job Mike.
I just tried to install it on a raspbian light, and it failed on installing libass, but I found only a Pi 2 laying around, so maybe that was the problem.
Will find a 3+ and try again, any pointers would be greatly appreciated.

//Dennis
Copying files to the temporary directory...OK
Stripping ELF binaries and libraries...OK
Compressing man pages...OK
Building file list...OK
Building Debian package...OK
Installing Debian package... FAILED!
*** Failed to install the package

User avatar
RPi_Mike
Posts: 118
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

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

Fri Jan 18, 2019 2:04 am

dennissss wrote:
Thu Jan 17, 2019 10:32 am
I just tried to install it on a raspbian light, and it failed on installing libass

Seriously? You're using the lite version of Raspbian and wondering why it doesn't work?

And then you make a second post with a long list of scary-looking problems and "troubleshooting" steps that have absolutely nothing to do with my tutorial or script?

Please review these highly visible, 100% verbatim quotes from my tutorial:


REQUIREMENTS: My script will work on any standard Raspberry Pi 3! It will fully execute and finish in only 54 minutes on the model 3B+, and only 58 minutes on the model 3B. All you need is the completely free Raspbian Stretch operating system (initially released on August 17, 2017). Advanced users should know that the stripped-down "lite" version of Raspbian will not work with my script, nor will it work for those who use the experimental desktop GL drivers (via raspi-config). The bottom line is actually very modest and simple – all you need is the current version of the Raspberry Pi's standard operating system. That's it! I don’t have a Raspberry Pi 2, but since the architecture is very similar, there’s a decent but non-guaranteed chance that my script will also work reasonably well on that device.

WHAT IF I HAVE A PROBLEM? Carefully re-read my requirements section. I've been surprised at the number of people in the past who skimmed over my tutorial and completely ignored my requirements section or warnings. For example, some went ahead and tried to do it with the "lite" version of Raspbian – even though I explicitly said it will NOT work with the lite version! My script only takes a few minutes to set up, but these instructions definitely require your full attention. It's not the kind of thing you can do while watching your favorite TV show!

Return to “Graphics, sound and multimedia”