Jump to content

Hardware encoding on Ubuntu Server


szimat
 Share

Recommended Posts

@@Andy777 Fixed in PR #2188

Greatt!!! I see Luke already pulled it in. I'm on a beta branch so it takes me a while (which is no problem). I PM:d about some unofficial Intel developments on low powered hardware.

 

Anyway, I think the VA-API + i965 driver is eventually the way to go. The community activity will eventually supersede the "Intel Media Group" approach with the closed source driver stack.

 

Once again: Thank you!

BR

Andy777

Link to comment
Share on other sites

 

Anyway, I think the VA-API + i965 driver is eventually the way to go.

 

this is really going to be a ground breaker.

 

I built a completely fanless silent test system with super low specs (and bleeding edge software versions) and I'm able to transcode 100 Mbps Jellyfish h.264 and 4k Big Bucks Buynny in realtime to 1 Mbps 720p h.264!

 

This is with:

  • 2.5 years old Celeron N2807 Bay Trail (fanless Gigabyte Brix).
  • 2 cores, no hyperthreading, 1 MB of cache
  • Average CPU  Mark 868.
  • CPU TDP 4.3W
  • 2GB ram
  • small SSD
  • IvyBridge generation GPU with only 4 EU:s and 310 MHz base frequency

Picture quality is (of course) really bad, but transcoding those heavy test clips happens without dropped frames (Jellyfish going 78fps and 4K BBB with 61fps.

 

Kernel + graphics drivers + vaapi + ffmpeg are all pre-release versions (hardware old and slow, software on the bleeding edge). Emby dev branch.

 

Amazing!

BR,

Andy777 

Link to comment
Share on other sites

Just wanted to add that I updated ffmpeg to 3.1.3 following the same post mentioned earlier http://ubuntuhandbook.org/index.php/2016/09/install-ffmpeg-3-1-ubuntu-16-04-ppa/ on vanilla 16.04 LTS w/ a Haswell CPU (Xeon e3-1225v3)  and my CPU usage went from 2 cores pegged during Live TV (still not sure why 2 cores were pegged) to under 4% across all cores.  Fing awesome.

 

 

Edit:  Just want to say that I have Live TV on one TV via Kodi, same show on my Chrome browser, and a movie on the Emby app, CPU avg still under 4%.

Edited by mastrmind11
Link to comment
Share on other sites

Just wanted to add that I updated ffmpeg to 3.1.3 following the same post mentioned earlier http://ubuntuhandbook.org/index.php/2016/09/install-ffmpeg-3-1-ubuntu-16-04-ppa/ on vanilla 16.04 LTS w/ a Haswell CPU (Xeon e3-1225v3)  and my CPU usage went from 2 cores pegged during Live TV (still not sure why 2 cores were pegged) to under 4% across all cores.  Fing awesome.

 

 

Edit:  Just want to say that I have Live TV on one TV via Kodi, same show on my Chrome browser, and a movie on the Emby app, CPU avg still under 4%.

 

Sorry but this doesnt tell anything about performance of emby, it just gives the stream to the clients without transcoding, so why should the server gets load through it?

vaapi is working gr8 for playback at all, but in transocding it is not able to work with less then 4% cpu ;)

Link to comment
Share on other sites

Sorry but this doesnt tell anything about performance of emby, it just gives the stream to the clients without transcoding, so why should the server gets load through it?

vaapi is working gr8 for playback at all, but in transocding it is not able to work with less then 4% cpu ;)

htop showed 2 cores pegged while watching Live TV before switching to VAAPI, and 4% after the switch.  

Link to comment
Share on other sites

  • 2 weeks later...

Just wanted to add that I updated ffmpeg to 3.1.3 following the same post mentioned earlier http://ubuntuhandbook.org/index.php/2016/09/install-ffmpeg-3-1-ubuntu-16-04-ppa/ on vanilla 16.04 LTS w/ a Haswell CPU (Xeon e3-1225v3)  and my CPU usage went from 2 cores pegged during Live TV (still not sure why 2 cores were pegged) to under 4% across all cores.  Fing awesome.

 

 

Edit:  Just want to say that I have Live TV on one TV via Kodi, same show on my Chrome browser, and a movie on the Emby app, CPU avg still under 4%.

 

I also have a Haswell GPU (Xeon E3-1245v2) but cannot get it to work for the life of me!

 

Can I ask if you're running Desktop Ubuntu 16.04? I'm starting with Ubuntu 16.04 minimal on a headless server. I must be missing something, when I hit vainfo it's says this.

# vainfo
error: can't connect to X server!
error: failed to initialize display
Aborted   

Link to comment
Share on other sites

I've used these installation instructions (kind of came up on my own) using files repo maintained by 01.org. It's a little cleaner that the other instructions. Can someone with Ubuntu 16.04 run these install instructions and see if it works for them. Let me know if you're running Desktop Ubuntu 16.04 or minimal.

cd ~
mkdir gfxtmp
cd gfxtmp
sudo wget https://download.01.org/gfx/RPM-GPG-KEY-ilg-4
sudo apt-key add - < RPM-GPG-KEY-ilg-4
sudo sh -c 'echo "deb https://download.01.org/gfx/ubuntu/16.04/main/ xenial main" >> /etc/apt/sources.list.d/intel-linux-graphics.list'
sudo apt-get update
sudo apt-get -y install vainfo i965-va-driver

sudo add-apt-repository ppa:jonathonf/ffmpeg-3
sudo apt-get update
sudo apt-get install ffmpeg
sudo reboot

Reboot. Then run

sudo usermod -a -G video emby
su - emby
vainfo
Edited by asnguy01
Link to comment
Share on other sites

@@Luke I just saw your vaapi fix in 3.0.8300. The thing is, MPEG4 decoding/encoding is not supported by Intel drivers at all so transcoding is still partially broken. Also h265 encoding/decoding is not supported on my system. So how to tackle this in your preferred way?

 

I believe there are four options: (1) the user selects codecs (and profiles?) supported by hardware decoding in the server configuration (2) emby analyzes the system (3) only codecs (and profiles?) supported by all vaapi implementations are enabled (mpeg2, h264 and vc1?) and finally (4) the user can disable hardware transcoding per file / library / show / ...
 
Is this also relevant for the other hardware acceleration options?
Link to comment
Share on other sites

Well as automatic as possible would be better. I think it is fine to start with mpeg2, h264 and vc1 as that covers the majority.

Link to comment
Share on other sites

Well as automatic as possible would be better. I think it is fine to start with mpeg2, h264 and vc1 as that covers the majority.

I think so too. Even though my use case (intention) is to use Emby server to transcode h265 (in hardware, KBL(w.10bit), when it is available) to my devices that can only decode older formats.

 

Please do not drop the Vaapi option. At least keep it in the dev-branch. Maybe label it as "exprimental, support only from the community, not the Emby core team".

 

The biggest problem is, that the only people needing this are the people with for real-time-transcoders, such as Plex and Emby users. There are some game streamers but that is bit different. Plex has taken the road, where they wait until everything works flawlessly, while Emby embraces new technology. So, were are beta testers for Emby and kind of alpha testers for Plex. Which one is the best business model? I cannot tell. However, there are not that many projects out there doing it

 

Open source hardware encoding (transcoding) will not get better implementations if WE do not pursue it. People who do offline transcoding will always find software methods to do better quality in non-realtime. Intel is only interested in paying customers _or_  a large open source user community.

 

I'm not the one to tell which is the better business model, Emby or Plex., but I am here just because of that difference.So my opinion is to keep the Vaapi option. If it is too much load for the core team, offload the option out of the UI to some configuration file, and offload the support from the main forums to a spcecial forum.

 

This option actually was the first _ever_ that enabled me to build a completely silent media server (stock, no special casing/cooling case and less than 10W of power consumption) capable of transcoding multiple streams simultaneously.

 

On the topic: ffmpeg can be queried for hardware capabilities. I'm currently super busy, but will chime in when have time.

 

BR,

Andy 777

Link to comment
Share on other sites

witteschnitte

@@schamane

 

I tested both.

 

quicksync on ubuntu Server works realy nice with emby. fast transcoding with 60 fps und 10 percent cpu (i7 4790t)

Vaapi transconding on the same machine is much faster by the same cpu usage but it results in a huge amount of artefacts.

But only in Scenes with fast moving or camera scene changes

 

With quicksync there are near no artefacts and the Picture is much better.

 

Maybe the vaapi will got better in the future when ffmpeg will get a better implementation.

I like VAAPI a little more, because you don´t have to build a custom kernel.

Edited by witteschnitte
  • Like 1
Link to comment
Share on other sites

@@schamane

 

I tested both.

 

quicksync on ubuntu Server works realy nice with emby. fast transcoding with 60 fps und 10 percent cpu (i7 4790t)

Vaapi transconding on the same machine is much faster by the same cpu usage but it results in a huge amount of artefacts.

But only in Scenes with fast moving or camera scene changes

 

With quicksync there are near no artefacts and the Picture is much better.

 

Maybe the vaapi will got better in the future when ffmpeg will get a better implementation.

I like VAAPI a little more, because you don´t have to build a custom kernel.

 

 

WOW,

 

how did u get quicksync running on Ubuntu 16.04 ???

Man, I am really interested as fuck in this information, I guess my Knowledge in Linux is quite well, but I didn` t manage to get this shit working.

 

And in the IRC of Intelgpu they told me there should be no  difference, I `ll send you the log the irc conversation and hopefully we can figure something out

Link to comment
Share on other sites

Seriously, you were able to get QS working in 16.04?  I'd also love more info on how you went about this.  I tried for an entire weekend before throwing in the towel.  Please share!

Link to comment
Share on other sites

Guest plexman

Seriously, you were able to get QS working in 16.04?  I'd also love more info on how you went about this.  I tried for an entire weekend before throwing in the towel.  Please share!

 

I recomend you to avoid custom kernels, VAAPI works perfectly. In addition, older kernels doesn't have the best suppor for newer hardware such as Skylake.

 

EDIT: Now the have full support for Skylake and 4.4 kernel. -> https://software.intel.com/sites/default/files/media_server_studio_getting_started_guide.pdf

Edited by plexman
Link to comment
Share on other sites

ffmpeg can be queried for hardware capabilities

Well that would be even best of all.

 

Some add hoc tests. The last ones are most important, as they check the success of actual encode process. The first two are actually covered by "vainfo", which anybody trying to get vaapi working, should install anyway. Also there are additional encoding capabilities coming all the time with new chips, new vaapi, new ffmpeg... I'n not an expert on this, so there could be smarter ways to do this.

 

Test that the render node exists:
ls -la /dev/dri/renderD128
If the exit code != 0, the HW is disabled


Test for HW access rights
touch /dev/dri/renderD128
If exit != 0 then the user does not belong to the video group


Test if vaapi hwaccel supported by ffmpeg:
./ffmpeg -hwaccels 2> /dev/null  | grep vaapi
If exit != 0 then ffmpeg doesn't have vaapi hwaccel support


Test vaapi encoders supported by ffmpeg:


./ffmpeg -encoders 2> /dev/null  | grep h264_vaapi
./ffmpeg -encoders 2> /dev/null  | grep hevc_vaapi
./ffmpeg -encoders 2> /dev/null  | grep mjpeg_vaapi
If exit != 0 on any of those, then ffmpeg doesn't have vaapi encoder for the respective codec


Test if the encoding actually works (h264, succeeds on my BYT and SKL)

./ffmpeg -vaapi_device /dev/dri/renderD128 -f lavfi -i nullsrc=s=1280x720 -t 1 -vf 'format=nv12,hwupload' -vcodec h264_vaapi -f null -
If exit != 0 vaapi h264 encode is not working


Test if the encoding actually works (hevc, succeeds only on my SKL)

./ffmpeg -vaapi_device /dev/dri/renderD128 -f lavfi -i nullsrc=s=1280x720 -t 1 -vf 'format=nv12,hwupload' -vcodec hevc_vaapi -f null -
If exit != 0 vaapi hevc encode is not working


Test if the encoding actually works (mjpeg, succeeds only on my SKL)

./ffmpeg -vaapi_device /dev/dri/renderD128 -f lavfi -i nullsrc=s=1280x720 -t 1 -vf 'format=nv12,hwupload' -vcodec hevc_vaapi -f null -
If exit != 0 vaapi mjpeg encode is not working
 

BR,

Andy777

Link to comment
Share on other sites

Seriously, you were able to get QS working in 16.04?  I'd also love more info on how you went about this.  I tried for an entire weekend before throwing in the towel.  Please share!

 

It works like charm if you follow intel media studio instructions to the letter. Mostly people just miss the part where the (short) list of supported (= the only ones that will work)  CPUs is.

With Intel media studio 2017 you need to have (excluding the respective Xeon models):

5th Generation (Broadwell) Core i3, i5 or i7
or
6th Generation (Skylake) Core i3, i5 or i7
 
Older CPU (like Haswell) -> no quicksync on linux 
New or old Pentium/Celeron/Atom/etc. -> no quicksync on linux
 
BR,
Andy777
Link to comment
Share on other sites

Andy777,

 

sorry, but cant agree here, even the guys on Intel irc dev channel told me to avoid quicksync, cause its just a mess.

 

I would really appreciate a working howto to get it working on a  Intel® Pentium® CPU  N3700  

 

which is supported 

http://ark.intel.com/products/87261/Intel-Pentium-Processor-N3700-2M-Cache-up-to-2_40-GHzhttp://ark.intel.com/products/87261/Intel-Pentium-Processor-N3700-2M-Cache-up-to-2_40-GHz

Intel® Quick Sync Video

search-glass.png

Yes

and if u mean this "howto"

https://software.intel.com/sites/default/files/media_server_studio_getting_started_guide.pdf

 

it didnt work for me, not on 16.04 as well as on CentOs 7.2

 

So please, If u are able to help us , do it ;)

 

I ruined my installation 3 times already trying to get it work

 

cheers

Edited by schamane
Link to comment
Share on other sites

Andy777,

 

sorry, but cant agree here, even the guys on Intel irc dev channel told me to avoid quicksync, cause its just a mess.

 

I would really appreciate a working howto to get it working on a  Intel® Pentium® CPU  N3700  

 

which is supported 

http://ark.intel.com/products/87261/Intel-Pentium-Processor-N3700-2M-Cache-up-to-2_40-GHzhttp://ark.intel.com/products/87261/Intel-Pentium-Processor-N3700-2M-Cache-up-to-2_40-GHz

Intel® Quick Sync Video

search-glass.png

Yes

and if u mean this "howto"

https://software.intel.com/sites/default/files/media_server_studio_getting_started_guide.pdf

 

it didnt work for me, not on 16.04 as well as on CentOs 7.2

 

So please, If u are able to help us , do it ;)

 

I ruined my installation 3 times already trying to get it work

 

cheers

 

I could quote the Intel Media guys directly, but I don't want to dig up the link again, as I have posted it in the Emby forums before. Here is the beef anyway: ON LINUX the intel ARK mentioned capabilities do not mean anything. They show that you have the needed hardware, and it works in Windows.

 

On Linux, you can do quicksync (talking about qsv enc/dec) only if the CPU&GPU is supported by the Intel Media Server Studio. Period. HW identifiers are hard coded in their closed source driver. So no quicksync in Linux for you sir!

 

Please visit Intel media forums where you quickly find out the same information. Large number of people getting the same answer that "even though your chip is listed as quicksync capable in the ARK, Intel doesn't currently offer quicksync for any other chips than listed in the Media Server Studio requirements.

 

 Vaapi in linux works for all quicksync(hardware capable) devices, so that is currently the only way for you to transcode in hardware (Linux. In Windows you can use quicksync).

 

The guide you yourself linked (that is the correct guide) does not list your Pentium. -> It does not work.

 

Is there a place I could write a sticky about it?

 

BR,

Andy777

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...