marmayr 4 Posted August 29, 2016 Share Posted August 29, 2016 Ok, when you run the command above, you'll see the bitrate ffmpeg uses to encode your media. This should give you a feeling for the bitrate needed to achieve the quality that you desire. But you can also experiment in Emby, of course. As far as I am aware, Emby does not take quality into consideration, but only bandwidth. You can change it by pressing the settings icon (the gears) when playing back videos. Link to comment Share on other sites More sharing options...
Wired Life 0 Posted August 29, 2016 Share Posted August 29, 2016 The linux support for some hardware is still bad...The Emby-Server of my dad has a Intel G4400 processor with Windows 10 and the quality of quick sync transcoding (which is supported out-of-the-box!) from a full hd bluray movie to 4 Mbit/s is !excellent! with 140 fps.My Emby-Server has a Intel G4500 procesoor, runs Ubuntu 16.04 and quick sync transcoding is still not supported on Skylake processors and vaapi transcoding giving so much artefacts.Hopefully waiting for a solution which makes vaapi stop making artefacts... Link to comment Share on other sites More sharing options...
Luke 37007 Posted August 29, 2016 Share Posted August 29, 2016 For those who are more familiar with vaapi, any suggestions to improve our command lines would be welcome. thanks. Link to comment Share on other sites More sharing options...
schamane 18 Posted August 30, 2016 Share Posted August 30, 2016 (edited) Ok, when you run the command above, you'll see the bitrate ffmpeg uses to encode your media. This should give you a feeling for the bitrate needed to achieve the quality that you desire. But you can also experiment in Emby, of course. As far as I am aware, Emby does not take quality into consideration, but only bandwidth. You can change it by pressing the settings icon (the gears) when playing back videos. yeah, I understand how i can improve the quality with this, but wont help much in emby, cause it still take bandwidth as limit, what is working not as good as it should. On the other hand, the above wont solve anything in an easy way, cause every movie is different in its bitrate and its much more comfortable clicking a gears icon, when u recognice, the bandwidth in hotel or somewhere else is not big enough. @marmayr do you have quicksync running as well on linux and can confirm what wired Life has written "The Emby-Server of my dad has a Intel G4400 processor with Windows 10 and the quality of quick sync transcoding (which is supported out-of-the-box!) from a full hd bluray movie to 4 Mbit/s is !excellent! with 140 fps." Edited August 30, 2016 by schamane Link to comment Share on other sites More sharing options...
szimat 6 Posted August 30, 2016 Author Share Posted August 30, 2016 @@szimat Support for VAAPI was added in ffmpeg 3.1, as far as I am aware of. This version is *very* new. It is neither available in Ubuntu 16.04 nor in Ubuntu 16.10 beta. I think packages will become available soon in https://launchpad.net/~mc3man/+ppa-packages Another option would be compiling it yourself. Personally, I use Debian and packages from deb-multimedia at the moment. I also tried to generate more reproducable results, so I downloaded Big Buck Bunny converted it into an mkv without any audio tracks by using ffmpeg -i /tmp/bbb_sunflower_1080p_30fps_normal.mp4 -vcodec copy -an out.mkv and then I converted the result by using the following commands: The results I obained are: # Fast transcode, quality 20, bandwidth does not matter: ~102 fps, 14MBit/s /usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 \ -i /tmp/out.mkv -map 0:0 -vf 'format=nv12|vaapi,hwupload' -codec:v:0 h264_vaapi \ -quality 2 -qp 20 -level 42 -map_metadata -1 -threads 0 -y "/tmp/transcoded.h264" # Slow transcode, quality 20, bandwidth does matter: ~76 fps, ~8.4MBit/s /usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 \ -i /tmp/out.mkv -map 0:0 -vf 'format=nv12|vaapi,hwupload' -codec:v:0 h264_vaapi \ -quality 0 -qp 20 -level 42 -map_metadata -1 -threads 0 -y "/tmp/transcoded.h264" # Bitrate limited transcode: 58 fps, ~4MBit/s /usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 \ -i /tmp/out.mkv -map 0:0 -vf 'format=nv12|vaapi,hwupload' -codec:v:0 h264_vaapi -b 4000k \ -level 42 -map_metadata -1 -threads 0 -y "/tmp/transcoded.h264" # Bitrate limited 720p-downsampling transcode: 104 fps, ~3MBit/s /usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 \ -i /tmp/out.mkv -map 0:0 -vf 'format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=720' \ -codec:v:0 h264_vaapi -b 3000k -level 42 -map_metadata -1 -threads 0 -y "/tmp/transcoded.h264" I think that the last two cases resemble how emby uses ffmpeg for transcoding. So my hardware should be capable of transcoding two streams at the same time, especially if one of them is down-sampled to 720p. The problem for me is that the N3150 SoC based board is my small home media server, and I don't want to mess up my production system. I have Vbox on the server, but not sure if vaapi would work in vbox environment? Do you mind to give a short how-to about installing ffmpeg and configuring vaapi on Debian (headless) or perhaps Ubuntu Server 16.04 for Emby Server beta? 1 Link to comment Share on other sites More sharing options...
schamane 18 Posted August 30, 2016 Share Posted August 30, 2016 (edited) I was lazy too, and dont wanna compile around on my "home-server" as well I did with 15.10 and trying to get quicksync working, afterwards, the system was a mess I dont know, why this (in my opinion) KILLERFEATURE of a intel cpu as a media server is so painful in linux and especially ubuntu. The ubuntu ffmpeg is 2.8.6???? Hello? This is disgusting old here you can get a ffmpeg with build in vaapi, just add the repo and dist-upgrade your ffmpeg https://launchpad.net/~djcj/+archive/ubuntu/hybrid and as a hint (taken from kodi.tv board) sudo apt-add-repository ppa:wsnipex/vaapisudo apt-get updatesudo apt-get dist-upgrade upgrade your vaapi to 1.7.1 cause 1.7.0 has colour issues https://bugs.freedesktop.org/show_bug.cgi?id=94845 vaapi in vbox will only work through passthrough and for that u would need a second GPU for the main system, if you passthrough ur first Edited August 30, 2016 by schamane 1 Link to comment Share on other sites More sharing options...
szimat 6 Posted August 30, 2016 Author Share Posted August 30, 2016 (edited) Thanks @@schamane I will try out. I also follow the Kodi vaapi forum, and already added wsnipex ppa for driver without color issue. However, we need to make a full how-to in order to make everything work on Ubuntu Server. I know X is not required, but we need the proper ffmpeg line how to do it on headless server. Exactly which packages are required? Edit: I already messwd up my home server, so before a new install, I can make some testing, since vbox is not an option and I don't have other hw I can play with atm with vaapi support Sent from my Xperia Z3 Compact using Tapatalk Edited August 30, 2016 by szimat Link to comment Share on other sites More sharing options...
schamane 18 Posted August 31, 2016 Share Posted August 31, 2016 the most interesting thing u may test would be quicksync. it would be really nice to know, if the result is really that much better as VAAPI. A howto in general would be useful in emby, to be honest, emby is always talking about HW acceleration, but the difficult part is not clicking "enable WH Transcoding" and about the whole building of ffmpeg is no documentation in here. Everyone is building his own environment instead of a ppa emby with all the tools I think only quicksync has license issues, but vaapi should be possible to include Link to comment Share on other sites More sharing options...
szimat 6 Posted August 31, 2016 Author Share Posted August 31, 2016 Agree. I will try to make a how-to for vaapi, but first I need to make it work. I don't vare about quicksync as it needs patched kernel, and 4.1 is only available, while I'm already on 4.4. Vaapi is the way to go, it should be quite easy to set up everything, once figured out how. Need the vaapi support dependencies, which are already available, compile ffmpeg with vaapi support until a static build woth vaapi enabled is available, and then to figure out the proper syntax for ffmpeg on headless install. It works for sure, just as I said, need to find the correct way. Sent from my Xperia Z3 Compact using Tapatalk Link to comment Share on other sites More sharing options...
schamane 18 Posted August 31, 2016 Share Posted August 31, 2016 this is written fast just install ffmpeg as written above install vaapi like they tell u in the kodi thread install emby add user emby to group video change in emby transcoding /dev/dri/card0 to /dev/dri/renderD128 (only needed if u also run kodi with vaapi) thats it, I guess set up in 10 minutes quicksync is the real pain but there are ppl, running it on 16.04 https://ubuntuforums.org/showthread.php?t=2329355 and also in the forum here, I saw some ppl havin it set up successfully. but nobody shares his knowledge of that Link to comment Share on other sites More sharing options...
szimat 6 Posted August 31, 2016 Author Share Posted August 31, 2016 this is written fast just install ffmpeg as written above install vaapi like they tell u in the kodi thread install emby add user emby to group video change in emby transcoding /dev/dri/card0 to /dev/dri/renderD128 (only needed if u also run kodi with vaapi) thats it, I guess set up in 10 minutes quicksync is the real pain but there are ppl, running it on 16.04 https://ubuntuforums.org/showthread.php?t=2329355 and also in the forum here, I saw some ppl havin it set up successfully. but nobody shares his knowledge of that Thanks again schamane It must be something wrong, as vainfo give me the following output: error: can't connect to X server! libva info: VA-API version 0.39.2 libva info: va_getDriverName() returns 0 libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so libva info: Found init function __vaDriverInit_0_39 libva info: va_openDriver() returns 0 vainfo: VA-API version: 0.39 (libva 1.7.1) vainfo: Driver version: Intel i965 driver for Intel(R) CherryView - 1.7.1 vainfo: Supported profile and entrypoints VAProfileMPEG2Simple : VAEntrypointVLD VAProfileMPEG2Simple : VAEntrypointEncSlice VAProfileMPEG2Main : VAEntrypointVLD VAProfileMPEG2Main : VAEntrypointEncSlice VAProfileH264ConstrainedBaseline: VAEntrypointVLD VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice VAProfileH264Main : VAEntrypointVLD VAProfileH264Main : VAEntrypointEncSlice VAProfileH264High : VAEntrypointVLD VAProfileH264High : VAEntrypointEncSlice VAProfileH264MultiviewHigh : VAEntrypointVLD VAProfileH264MultiviewHigh : VAEntrypointEncSlice VAProfileH264StereoHigh : VAEntrypointVLD VAProfileH264StereoHigh : VAEntrypointEncSlice VAProfileVC1Simple : VAEntrypointVLD VAProfileVC1Main : VAEntrypointVLD VAProfileVC1Advanced : VAEntrypointVLD VAProfileNone : VAEntrypointVideoProc VAProfileJPEGBaseline : VAEntrypointVLD VAProfileJPEGBaseline : VAEntrypointEncPicture VAProfileVP8Version0_3 : VAEntrypointVLD VAProfileVP8Version0_3 : VAEntrypointEncSlice VAProfileHEVCMain : VAEntrypointVLD What do you get with vainfo? Link to comment Share on other sites More sharing options...
schamane 18 Posted August 31, 2016 Share Posted August 31, 2016 why do you think something is wrong here? all good error: can't connect to X server! this is ok if you have no x or working via ssh, my output is exactly the same your vaapi is working, no worries now add user emby to user video enable transcoding with vaapi in emby and use /dev/dri/renderD128 restart emby and give it a go, should work but with artefacts Link to comment Share on other sites More sharing options...
szimat 6 Posted August 31, 2016 Author Share Posted August 31, 2016 why do you think something is wrong here? all good error: can't connect to X server! this is ok if you have no x or working via ssh, my output is exactly the same your vaapi is working, no worries now add user emby to user video enable transcoding with vaapi in emby and use /dev/dri/renderD128 restart emby and give it a go, should work but with artefacts You are correct! It does work:) Excellent. Now need to check cpu load an encoding fps (how do you do this the easiest way, I mean the fps?). Artifacts are there indeed. Based on my readings, it is there because hardware encoding needs other bitrate settings (I will look up the thread I read about this). Interestingly, the ffmpeg version from the ppa doesnt list vaapi as enabled. The output of ffmpeg -buildconf is: ffmpeg version 3.1.3-1~xenial Copyright (c) 2000-2016 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609 configuration: --prefix=/usr --extra-version='1~xenial' --libdir=/usr/lib/ffmpeg --shlibdir=/usr/lib/ffmpeg --disable-static --disable-debug --toolchain=hardened --enable-pthreads --enable-runtime-cpudetect --enable-gpl --enable-shared --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-libkvazaar --enable-libopenh264 --enable-nonfree --enable-libfdk-aac --enable-libfaac libavutil 55. 28.100 / 55. 28.100 libavcodec 57. 48.101 / 57. 48.101 libavformat 57. 41.100 / 57. 41.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 47.100 / 6. 47.100 libavresample 3. 0. 0 / 3. 0. 0 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 1.100 / 2. 1.100 libpostproc 54. 0.100 / 54. 0.100 configuration: --prefix=/usr --extra-version='1 xenial' --libdir=/usr/lib/ffmpeg --shlibdir=/usr/lib/ffmpeg --disable-static --disable-debug --toolchain=hardened --enable-pthreads --enable-runtime-cpudetect --enable-gpl --enable-shared --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-libkvazaar --enable-libopenh264 --enable-nonfree --enable-libfdk-aac --enable-libfaac Shouldn't it list: --enable-vaapi Link to comment Share on other sites More sharing options...
schamane 18 Posted August 31, 2016 Share Posted August 31, 2016 right, it should, thats weird, but its build in 100% avconv -encoders | grep vaapi gives me V..... h264_vaapi H.264/AVC (VAAPI) (codec h264) V..... hevc_vaapi H.265/HEVC (VAAPI) (codec hevc) V..... mjpeg_vaapi MJPEG (VAAPI) (codec mjpeg) so its maybe standard in the new ffmpeg? dunno Link to comment Share on other sites More sharing options...
szimat 6 Posted August 31, 2016 Author Share Posted August 31, 2016 OK, some testing: quality settings work until 720p 3 Mbps. If you select anything lower, for example 720p 2 Mbps, then it Video Error. Can anybody else confirm this? Link to comment Share on other sites More sharing options...
schamane 18 Posted August 31, 2016 Share Posted August 31, 2016 cant confirm this, can go to 144p as well (we dont have to talk about "quality" anymore ) Link to comment Share on other sites More sharing options...
szimat 6 Posted August 31, 2016 Author Share Posted August 31, 2016 (edited) cant confirm this, can go to 144p as well (we dont have to talk about "quality" anymore ) Wait, I just remembered something: since I use it as a headless server, I added only 64 MB memory to GPU in UEFI, since actually the GPU is not used at all. I will need to set this to at least 512 MB and check again (but for that I need to get home first, so I will test and report back at the evening). it is more then likely that I get the errors because of very small RAM dedicated to GPU. Edited August 31, 2016 by szimat Link to comment Share on other sites More sharing options...
szimat 6 Posted August 31, 2016 Author Share Posted August 31, 2016 (edited) An interesting discussion about vaapi and bitrates over Tvheadend forums (where they are also working on adding vaapi enabled hw encoding for Tvh, WOW): Question: @danny: making VAAPI then for meaningful if I specify no bitrate ? I would like to reduce the hd stream of 11Mbit on 3mbit be able to look at him over internet Answer: Then you need software encoding, no hardware encoder nvenc, qsv or vaapi will produce a good quality hd in 3 mbit, only if you scale it to sd.The current ffmpeg implentation of vaapi dont like when youre using -b:v to restrict its bw, addjusting -qp to like 25 will yeld much better results tho.Even x264 will have a hard time producing a good quality in 3 mbit hd unless you use medium or slower preset. Located at: https://tvheadend.org/issues/3831#note-39 Based on this, this is why we get artifacts when encoding with vaapi (the original question was exactly referring to this, it works, but image is pixelated). 1) Are there artifacts when choosing SD and higher bitrate? 2) Can we somehow add different quality controls to Emby, like -qp 25 or to have higher bitrate at SD resolutions? Edited August 31, 2016 by szimat Link to comment Share on other sites More sharing options...
schamane 18 Posted August 31, 2016 Share Posted August 31, 2016 We got this topic already in here, that BW limit isnt as good as qp But afaik and from my own experience, its hard to figure out how much BW u will need with a movie with qp 25 or 20 ... because its downscaling the movie, but if its 10 Mbit before its maybe 5 afterwards, if it was 20 before it still needs 10 or so, what i wanna say, its hard if you know you have just 3 mbit in the hotel or elsewhere to figure out in which qp u will be able to stream. But I really guess I have to figure out quicksync, because in that tvheadend thread they also commit, that quicksync delivers a much better quality Link to comment Share on other sites More sharing options...
szimat 6 Posted August 31, 2016 Author Share Posted August 31, 2016 We got this topic already in here, that BW limit isnt as good as qp But afaik and from my own experience, its hard to figure out how much BW u will need with a movie with qp 25 or 20 ... because its downscaling the movie, but if its 10 Mbit before its maybe 5 afterwards, if it was 20 before it still needs 10 or so, what i wanna say, its hard if you know you have just 3 mbit in the hotel or elsewhere to figure out in which qp u will be able to stream. But I really guess I have to figure out quicksync, because in that tvheadend thread they also commit, that quicksync delivers a much better quality Yes, I'm fully aware of the BW vs qp problems to get the desired bitrate for a given connection limit. It is nearly impossible with qp, afaik. Again, if I'm not mistaken, vaapi is basically the same as qucksync, just access over a different implementation (open source?). It will be certainly improved over time by ffmpeg, and I'm sure we can come up with a better configuration when using vaapi. I really think quicksync is not the solution: 1) certainly must use a patched kernel, even if available for any kernel (which is not), it is still not convenient. Imagine most Emby server users patching the kernel? After a kernel update you need to patch again (or dkms?) 2) vaapi will certainly improve by time, and Emby needs to find the best way how to utilize vaapi Link to comment Share on other sites More sharing options...
schamane 18 Posted August 31, 2016 Share Posted August 31, 2016 (edited) the difference is in the used library and encoder and nobody else can produce a better one as the manufacturer, I guess this is the reason why quicksync is that much better. I also think, that vaapi will improve in the future, but if it really ever will reach quickync in terms of qualitiy? I have doubts. With the kernel, that the reason, why the Kernel in LTS based distributions are never upgraded in their version, so they are compatible Edited August 31, 2016 by schamane Link to comment Share on other sites More sharing options...
szimat 6 Posted August 31, 2016 Author Share Posted August 31, 2016 (edited) Just a quick how-to for those who would like to test VAAPI on Ubuntu (Server) and Emby beta. 1) Install Emby Server beta (must be beta, since VAAPI is only included in beta) Add emby user to group video (needed to have access to GPU), If you run Emby as a different user, you should add that user sudo usermod -a -G video emby 2) Install vaapi goodies: sudo apt-get update sudo apt-get install libva1 vainfo i965-va-driver 3) Install the 1.7.1 libva-driver-intel version, since the one included with 16.04 (v 1.7.0) has color issues (https://bugs.freedesktop.org/show_bug.cgi?id=94845) sudo apt-add-repository ppa:wsnipex/vaapi sudo apt-get update sudo apt-get dist-upgrade 4) Install ffmpeg with VAAPI support. You have two options: a) compile ffmpeg with --enable-vaapi or b ) use the ppa (thanks to schamane for pointing out this ppa) sudo add-apt-repository ppa:djcj/hybrid sudo apt-get update sudo app-get install ffmpeg OPTIONAL: You can check the ffmpeg version before you install with sudo apt-get update sudo apt-cache policy ffmpeg Finally, do a system restart, then in Emby Server, under Transcoding enable VAAPI and save the settings. Do some testing, and report your findings here. We experience some artifacts with VAAPI, I think especially at lower bitrates. At higher bitrates I believe there will be less artifacts (I need to do more testing to confirm this). Remember, VAAPI support in ffmpeg is still new, and Emby just added the support (very quickly, so much thanks), so it is still, well, beta. I'm sure it will get better by time. My small home media server running an N3150 SoC performs excellent with VAAPI if transcoding is needed. Edited August 31, 2016 by szimat Link to comment Share on other sites More sharing options...
Wired Life 0 Posted August 31, 2016 Share Posted August 31, 2016 Just a quick how-to for those who would like to test VAAPI on Ubuntu (Server) and Emby beta. 1) Install Emby Server beta (must be beta, since VAAPI is only included in beta) This is not right, VAAPI is included in stable since 3.0.6200! Link to comment Share on other sites More sharing options...
szimat 6 Posted August 31, 2016 Author Share Posted August 31, 2016 This is not right, VAAPI is included in stable since 3.0.6200! Well, according to Luke's post here it was just added now, and available on beta channel. Didn't check before. Link to comment Share on other sites More sharing options...
szimat 6 Posted August 31, 2016 Author Share Posted August 31, 2016 Just as I thought, setting gpu memory to 512 MB makes vaapi perfectly working. I mean I still get the artifacts, sadly. I understand vaapi was not designed for low & limited bitrates, but lets hope ffmpeg development will fix this somehow, or we find a way to implement in Emby to have at least some bitrate control. Sent from my Xperia Z3 Compact using Tapatalk Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now