Feature #3831
Feature #4443: support vaapi for transcoding
VAAPI Encoding via FFmpeg.
0%
Description
Is there any plans to add the new h264_vaapi encoder via ffmpeg ?
Its much easier to setup compared to the quick sync intel media sdk stuff.
It works out of the box on a default ubuntu 15.10 install.
And the performance/quality is quite good if you have hasswell or better.
It also works without a X system.
test@box:~$ /home/test/FFmpeg/ffmpeg -y -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -y -i testfile.ts -vf 'format=nv12|vaapi,hwupload' -an -c:v h264_vaapi -b:v 2M -f mpegts out.ts
ffmpeg version N-80101-gd970f7b Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --enable-vaapi
libavutil 55. 24.100 / 55. 24.100
libavcodec 57. 43.100 / 57. 43.100
libavformat 57. 37.100 / 57. 37.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 46.100 / 6. 46.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
libva info: VA-API version 0.38.0
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_38
libva info: va_openDriver() returns 0
Input #0, mpegts, from 'testfile.ts':
Duration: 00:01:19.75, start: 47250.486389, bitrate: 3407 kb/s
Program 1
Stream #0:0[0x20]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 720x576 [SAR 16:11 DAR 20:11], 25 fps, 50 tbr, 90k tbn
Stream #0:1[0x279](swe): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s
Output #0, mpegts, to 'out.ts':
Metadata:
encoder : Lavf57.37.100
Stream #0:0: Video: h264 (High), vaapi_vld, 720x576 [SAR 16:11 DAR 20:11], q=2-31, 2000 kb/s, 25 fps, 90k tbn
Metadata:
encoder : Lavc57.43.100 h264_vaapi
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
Press [q] to stop, [?] for help
frame= 1957 fps=859 q=-0.0 Lsize= 20781kB time=00:01:19.00 bitrate=2154.9kbits/s speed=34.7x
video:19052kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 9.076974%
Files
History
Updated by zapp -it over 8 years ago
And also interesting https://github.com/FFmpeg/FFmpeg/blob/master/ffmpeg_vaapi.c
line 178 and line 181, support for VP
Updated by C vH over 8 years ago
referring to https://trac.ffmpeg.org/wiki/HWAccelIntro
the implementation is finished (current ffmpeg trunk has it working)
allowing vaapi encoding would finally end the mess with the qsv and offers a bigger hw compatibility
also less dependencies sounds great!
Updated by Jan g over 8 years ago
i tried this. i installed ubuntu 16.04 and compile ffmpeg with --enable-vaapi but the quality is very bad.
i started it with a pipe in tvheadend:
/usr/local/bin/ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -y -i $url -vf 'format=nv12|vaapi,hwupload' -c:v h264_vaapi -b:v 3M -minrate 2900k -maxrate 3100k -preset:v slow -c:a aac -ab 128k -ar 44100 -ac 2 -strict -2 -metadata service_provider=IPTV -metadata service_name=$name -f mpegts pipe:1
but the quality is full of pixels and not really good. with h264_qsv and mediasdk...i have really good quality.
something is wrong with my setup.. can u help me?
Updated by danny skjodt over 8 years ago
afaik you need hasswell atleast for any good quality with vaapi, i do also think there is some current limits in the ffmpeg vaapi code, for example it seems that the encoded h264 stream vaapi returns to ffmpeg is 30 fps or maybe 29.97 fps, so try add -r 29.97
Updated by Jan g over 8 years ago
Jan g wrote:
-r 29.97 does nothing change...
the cpu load is also quite low... with h264_qsv and mediasdk i have ca 15%-20% cpu load per channel
Updated by Jan g over 8 years ago
Jan g wrote:
Jan g wrote:
-r 29.97 does nothing change...
the cpu load is also quite low... with h264_qsv and mediasdk i have ca 15%-20% cpu load per channel
ffmpeg compile:
cd
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \
--enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis \
--enable-libvpx --enable-libx264 --enable-vaapi --enable-nonfree --enable-version3
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
hash x264 ffmpeg ffplay ffprobe
how did u compile it?
Updated by danny skjodt over 8 years ago
Jan g wrote:
Jan g wrote:
-r 29.97 does nothing change...
the cpu load is also quite low... with h264_qsv and mediasdk i have ca 15%-20% cpu load per channel
Then youre most likely using software based encoding via the media sdk, it will fall back to that if it cant use your gpu, if you dont have the right kernel setup etc.
Updated by danny skjodt over 8 years ago
Jan g wrote:
-r 29.97 does nothing change...
the cpu load is also quite low... with h264_qsv and mediasdk i have ca 15%-20% cpu load per channel
What bitrate is that picture made with, it looks fine, its what you should expect at 100kbit i think youre mixing up software vs hardware encoding here.
20% cpu load per channels is what x264 does, and the software based media sdk does.
You must remember that gpu assisted encoding is much worse quality at low bitrates than software based encoding is =)
Updated by danny skjodt over 8 years ago
1000 kbit*
The bitrates qsv it can produce good quality in is like 3000-4000 kbit for sd, and 8000-10000 kbit for hd, its not that good todo hard compression.
Updated by saen acro over 8 years ago
Jan asd g some example bitrates
SD 720x576 (4:3/16:9) ~2500-4000 kbit/s HDReady 720p(i) ~4000-6000 kbit/s HD 1080p(i) ~ 6000-12000 kbit/s
less motion less bitrate
more motion more bitrate
do not confuse with dual/multiple pass transcoding (with is not possible in real-time)
Updated by C vH over 8 years ago
Just want to add that transcoding at RPi2/3 would also work! 1080p->h264 1080p @ ~30fps !
Updated by Jan g over 8 years ago
With ffmpeg?
I know that it is working with gstreamer... U Compile ffmpeg on rasbian Jessy?
@my Problem
I use these ffmpeg Command with Quicksync 3mbit And the Quality is very good.. No pixel(Look My ts file). I search a Method that i Dont have to install Mediasdk (easier Installation And Same Quality). The Original 1080i steam is about 12mbit
Updated by C vH over 8 years ago
of course with ffmpeg - transcoding with RPi3 is quite an game changer for a lot ppl
Updated by The Troll over 8 years ago
Hey,
did someone try on a kernel 4.1.17 patched for QSV ?
I get drm hanging.
Updated by zapp -it over 8 years ago
The Troll wrote:
Hey,
did someone try on a kernel 4.1.17 patched for QSV ?
I get drm hanging.
Not on 4.1.17 but on 4.1.24 on Ubuntu 16.04 LTS. Media SDK 2016.
This is the code I used to get it working, based on https://software.intel.com/en-us/articles/how-to-setup-media-server-studio-on-secondary-os-of-linux
#!/bin/bash echo "remove other libdrm/libva" find /usr -name "libdrm*" | xargs rm -rf find /usr -name "libva*" | xargs rm -rf echo "Remove old MSS install files ..." rm -rf /opt/intel/mediasdk rm -rf /opt/intel/common rm -rf /opt/intel/opencl echo "install user mode components" #unpack the generic package tar -xvzf intel-linux*.tar.gz #put the generic components in standard locations /bin/cp -r etc/* /etc /bin/cp -r opt/* /opt /bin/cp -r usr/* /usr #ensure that new libraries can be found echo '/usr/lib64' > /etc/ld.so.conf.d/libdrm_intel.conf echo '/usr/local/lib' >> /etc/ld.so.conf.d/libdrm_intel.conf ldconfig echo "install kernel build dependencies" aptitude -y install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc g++ echo "install Intel tools" aptitude -y install libva-dev # intel_gpu_top aptitude -y install intel-gpu-tools echo "download 4.1.24 kernel" if [ ! -f ./linux-4.1.24.tar.xz ]; then wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.1.24.tar.xz fi tar -xJf linux-4.1.24.tar.xz echo "download 4.1.24 patches" if [ ! -f ./4.1.12-patches.tar ]; then wget http://tvheadend.org/attachments/download/3901/4.1.12-patches.tar fi tar -xvf 4.1.12-patches.tar echo "apply kernel patches" cd linux-4.1.24 for i in ../4.1.12-patches/*.patch; do patch -p1 <$i; done echo "build patched 4.1.24 kernel" make olddefconfig make -j 8 make modules_install make install echo "Install finished, please " echo "1. update LD_LIBRARY_PATH to include /usr/lib64;/usr/local/lib" echo "2. add user to video group: usermod -a -G video user" echo "3. reboot" echo "4. test with MediaSamples_Linux_6.0.16043175.175/samples/_bin/x64, execute: ./sample_multi_transcode_drm -hw -i::h264 ../content/test_stream.264 -o::h264 out.h264"
Maybe not necessary for you but don't forget to add the environments for the hts daemon.
export LIBVA_DRIVERS_PATH=/opt/intel/mediasdk/lib64 export LIBVA_DRIVER_NAME=iHD
Updated by The Troll over 8 years ago
Hi Zapp, this is meant for QSV right ? :)
So with this patched kernel, can you try h264_vaapi encoding ?
Updated by Jonathan Thomson over 8 years ago
zapp -it wrote:
Never mind, wrong reading
Do you know how easy/safe it is to downgrade the kernel in ubuntu. I'm running 16.04 with kernel 4.4.0-24 but I apparently need to downgrade to 4.1.24 to make use of the Intel QSV acceleration with TVH.
I've downloaded and compiled the kernel source incorporating the patches as described above and I also have the Intel Media Studio package ready to install but a couple of things are making me nervous;
1) The instructions above tell me to forcibly remove libdrm and libva - this feels wrong, shouldn't they be uninstalled using apt-get rather than just deleting the files?
2) If I install the kernel (I've never done it before) I guess the kernel is displayed in the grub menu meaning I can try booting from the new kernel and if it doesn't work I can just boot to my newer kernel and be back to where I was before?
3) Are there any additional steps to get QSV working above what is described above (install Intel Media Studio, patch/install the kernel)? What version of TVHeadend makes use of these modifications, can I just build and install git master?
Updated by Jonathan Thomson over 8 years ago
EDIT: Actually, I'm wondering if downgrading to the 4.1 kernel will cause me more problems than it solves - is the Skylake architecture even supported in 4.1, will I lose integrated graphics and sound as my TVH box is also a frontend running Kodi and the primary source of TV in our house! eek!
Updated by B C over 8 years ago
forget Skylake and QSV on Linux, it simply won't work. You will have to wait for native vaapi support in tvh
Updated by zapp -it over 8 years ago
Jonathan Thomson wrote:
zapp -it wrote:
Never mind, wrong reading
Do you know how easy/safe it is to downgrade the kernel in ubuntu. I'm running 16.04 with kernel 4.4.0-24 but I apparently need to downgrade to 4.1.24 to make use of the Intel QSV acceleration with TVH.
I've downloaded and compiled the kernel source incorporating the patches as described above and I also have the Intel Media Studio package ready to install but a couple of things are making me nervous;
1) The instructions above tell me to forcibly remove libdrm and libva - this feels wrong, shouldn't they be uninstalled using apt-get rather than just deleting the files?
2) If I install the kernel (I've never done it before) I guess the kernel is displayed in the grub menu meaning I can try booting from the new kernel and if it doesn't work I can just boot to my newer kernel and be back to where I was before?
3) Are there any additional steps to get QSV working above what is described above (install Intel Media Studio, patch/install the kernel)? What version of TVHeadend makes use of these modifications, can I just build and install git master?
I have no experience with TVH + Kodi on the same box and I have no Skylake proc(see note B C) but I think that is unwise to do that . I have an dedicated backend (NUC) with only TVH on it (and some other services) that differs from your environment.
But to give you some answer of your questions in your previous post:
1. Nope, see the link to the intel script, I had some trouble with apt-get, that’s why I use aptitude .
2. Yes, you can choose to boot with which kernel, I have changed the default kernel in grub to boot with the QSV kernel.
3. The environments for the TVH daemon.
@The Troll,
Testing with h264_vaapi but on this moment no luck sadly.
Updated by The Troll over 8 years ago
Hi Zapp, what error do you get ?
What kernel do you use ?
Thanks
Updated by danny skjodt over 8 years ago
B C wrote:
forget Skylake and QSV on Linux, it simply won't work. You will have to wait for native vaapi support in tvh
Skylake and vaapi works perfect on ubuntu 15.10 out of the box (ubuntu desktop)
Jan g wrote:
i tried this. i installed ubuntu 16.04 and compile ffmpeg with --enable-vaapi but the quality is very bad.
i started it with a pipe in tvheadend:
/usr/local/bin/ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -y -i $url -vf 'format=nv12|vaapi,hwupload' -c:v h264_vaapi -b:v 3M -minrate 2900k -maxrate 3100k -preset:v slow -c:a aac -ab 128k -ar 44100 -ac 2 -strict -2 -metadata service_provider=IPTV -metadata service_name=$name -f mpegts pipe:1
but the quality is full of pixels and not really good. with h264_qsv and mediasdk...i have really good quality.
something is wrong with my setup.. can u help me?
You need to remove -b:v 3M -minrate 2900k -maxrate 3100k or use higher rates, vaapi dont work that well with this kind of rate control it wants it peaks or else you get the results youre getting.
Updated by danny skjodt over 8 years ago
Jan g wrote:
-r 29.97 does nothing change...
the cpu load is also quite low... with h264_qsv and mediasdk i have ca 15%-20% cpu load per channel
If you have 15-20% cpu load using qsv, then qsv falls back to using its software encoder, meaning its not encoded using the igpu, most likely because you didnt patch kernel and all that stuff right.
Updated by B C over 8 years ago
QSV != vaapi
so yes, vaapi works on skylake but it is not qsv....
Updated by Jonathan Thomson over 8 years ago
zapp -it wrote:
Jonathan Thomson wrote:
zapp -it wrote:
Never mind, wrong reading
Do you know how easy/safe it is to downgrade the kernel in ubuntu. I'm running 16.04 with kernel 4.4.0-24 but I apparently need to downgrade to 4.1.24 to make use of the Intel QSV acceleration with TVH.
I've downloaded and compiled the kernel source incorporating the patches as described above and I also have the Intel Media Studio package ready to install but a couple of things are making me nervous;
1) The instructions above tell me to forcibly remove libdrm and libva - this feels wrong, shouldn't they be uninstalled using apt-get rather than just deleting the files?
2) If I install the kernel (I've never done it before) I guess the kernel is displayed in the grub menu meaning I can try booting from the new kernel and if it doesn't work I can just boot to my newer kernel and be back to where I was before?
3) Are there any additional steps to get QSV working above what is described above (install Intel Media Studio, patch/install the kernel)? What version of TVHeadend makes use of these modifications, can I just build and install git master?I have no experience with TVH + Kodi on the same box and I have no Skylake proc(see note B C) but I think that is unwise to do that . I have an dedicated backend (NUC) with only TVH on it (and some other services) that differs from your environment.
But to give you some answer of your questions in your previous post:
1. Nope, see the link to the intel script, I had some trouble with apt-get, that’s why I use aptitude .
2. Yes, you can choose to boot with which kernel, I have changed the default kernel in grub to boot with the QSV kernel.
3. The environments for the TVH daemon.@The Troll,
Testing with h264_vaapi but on this moment no luck sadly.
I got impatient and did it anyway - result: a non-bootable system.
At least I'm a pro at installing Ubuntu, Kodi and TVH in record time now - just thankful I backed up all my config files - I can get back to a working system within an hour
Updated by Jonathan Thomson over 8 years ago
B C wrote:
QSV != vaapi
so yes, vaapi works on skylake but it is not qsv....
So - ffmpeg supports vaapi, TVHeadend doesn't - once the two marry up then we'll have hardware accelerated transcoding? And vaapi works "out of the box" without all this kernel-patching stuff?
Updated by B C over 8 years ago
exactly, no kernel magic, just a recent gfx driver and some bytes in tvh
Updated by zapp -it over 8 years ago
The Troll wrote:
Hi Zapp, what error do you get ?
What kernel do you use ?Thanks
Hi TT,
The following error: symbol vaCreateSurfaces, version VA_API_0.33.0 not defined in file libva.so.1 with link time reference; looks an bit odd to me. It could be, not surprised, an local setup problem by me.
For the kernel see ^^
The strange is that QSV is working like an charm.
Updated by Jan g over 8 years ago
cindy lonely: 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
Updated by Jan g over 8 years ago
i patched my kernel to kernel 3.8 and install ffmpeg with qsv support. it is resource-efficient than software encoding h264
Updated by danny skjodt over 8 years ago
Jan g wrote:
cindy lonely: 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
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.
Jan g wrote:
i patched my kernel to kernel 3.8 and install ffmpeg with qsv support. it is resource-efficient than software encoding h264
Like ive told you already if its using 20% cpu its not qsv hw, then qsv fall back to its software encoder, yes qsv have a software encoder. And that may be less hard on the cpu than x264 but it will also be worse quality then, its most likely the same as x264 veryfast.
Updated by MinGyoon Woo over 8 years ago
Would please let me know how can I transcode with resize using VAAPI?
I can transcode with following command
ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -i input.mp4 -an -vf 'format=nv12|vaapi,hwupload' -c:v h264_vaapi -qp 25 output.mp4
But if I added resize option, it was failed.
ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -i input.mp4 -an -vf 'format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=720:format=yuv420p,hwdownload' -c:v h264_vaapi -qp 25 output.mp4
Please help...
Updated by Alfred Zastrow over 8 years ago
VAAPI was added today - fine, I will test it.
But I've one question: what is the normal way to get this option compiled?
I'm using "Autobuild.sh" normaly and I get installable DEB-Packages at the end, thats very fine. In this case I have added "vaapi:yes" to ./configure. This is not fine, because my version is now flagged as "dirty". I don't want to struggle with ./configure-options directly..
Updated by Gustavo Sánchez over 8 years ago
Alfred Zastrow wrote:
VAAPI was added today - fine, I will test it.
But I've one question: what is the normal way to get this option compiled?
I'm using "Autobuild.sh" normaly and I get installable DEB-Packages at the end, thats very fine. In this case I have added "vaapi:yes" to ./configure. This is not fine, because my version is now flagged as "dirty". I don't want to struggle with ./configure-options directly..
Why libva-x11 is required ? In a server libva-drm is enough to use ffmpeg and h264_vaapi
Updated by Gustavo Sánchez over 8 years ago
On this link https://wiki.libav.org/Hardware/vaapi you could see how to select DRM device without X11
Regards Gustavo.
Updated by Gustavo Sánchez over 8 years ago
Another question is why, to compile with vaapi support, is needed to enable QSV.
The advantage of vaapi over QSV is that no kernel patched are needed and no OpenCL, so if I need QSV to gain vaapi ...
Updated by B C over 8 years ago
vaapi support in tvh is not complete for now, it uses the wrong pix_fmt (easy to fix) and does not set the DRM device
Updated by Jose Vigil over 8 years ago
I'm trying to get hardware transcoding working in tvh. vaapi seems to be a better option than qsv (qsv is not working for me)
when trying vaapi, I get this error in the log:
Jul 9 11:58:45 gentoo tvheadend30050: libav: Undefined constant or missing '(' in 'high'
Jul 9 11:58:45 gentoo tvheadend30050: libav: Unable to parse option value "high"
Jul 9 11:58:45 gentoo tvheadend30050: libav: Error setting option profile to value high.
Jul 9 11:58:45 gentoo tvheadend30050: transcode: 0001: Unable to open h264_vaapi encoder
Do you know the reason of this error?
Thank you
Updated by Luis Palacios over 8 years ago
B C wrote:
it's not working yet, you have to wait
Thanks B C.
Very very "wanted" also here. I offer myself as beta tester, doc-provider, doc-translator (spanish), whatever help needed.
Thanks
Luis
Updated by Luis Palacios over 8 years ago
Hi Team, as I've spent lots of hours studying this topic (Tvheadend and QSV) and I though it might be usefull to document it, so I've put together a technical note (sorry, only Spanish) here [[http://www.luispa.com/archivos/4876]].
I'll update it as soon as this request is, hopefully, accepted and implemented.
Regards,
Luis
Updated by Anders Falk about 8 years ago
B C wrote:
it's not working yet, you have to wait
Anything new on this? Would be great to get this working.
//Anders
Updated by dreamer538 dreamer538 about 8 years ago
zapp -it wrote:
Not on 4.1.17 but on 4.1.24 on Ubuntu 16.04 LTS. Media SDK 2016.
This is the code I used to get it working, based on https://software.intel.com/en-us/articles/how-to-setup-media-server-studio-on-secondary-os-of-linux
Did it actually work for you? I'm trying to do the same, I load the new kernel, vainfo shows multiple entries
libva info: VA-API version 0.99.0 libva info: va_getDriverName() returns 0 libva info: User requested driver 'iHD' libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so libva info: Found init function __vaDriverInit_0_32 libva info: va_openDriver() returns 0 vainfo: VA-API version: 0.99 (libva 1.67.0.pre1) vainfo: Driver version: 16.4.4.47109-ubit vainfo: Supported profile and entrypoints VAProfileH264Baseline : VAEntrypointEncSlice VAProfileH264Baseline : <unknown entrypoint> VAProfileH264Baseline : <unknown entrypoint> VAProfileH264ConstrainedBaseline: VAEntrypointVLD VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice VAProfileH264ConstrainedBaseline: <unknown entrypoint> VAProfileH264ConstrainedBaseline: <unknown entrypoint> VAProfileH264Main : VAEntrypointVLD VAProfileH264Main : VAEntrypointEncSlice VAProfileH264Main : <unknown entrypoint> VAProfileH264Main : <unknown entrypoint> VAProfileH264High : VAEntrypointVLD VAProfileH264High : VAEntrypointEncSlice VAProfileH264High : <unknown entrypoint> VAProfileH264High : <unknown entrypoint> VAProfileMPEG2Simple : VAEntrypointEncSlice VAProfileMPEG2Simple : VAEntrypointVLD VAProfileMPEG2Main : VAEntrypointEncSlice VAProfileMPEG2Main : VAEntrypointVLD VAProfileVC1Advanced : VAEntrypointVLD VAProfileVC1Main : VAEntrypointVLD VAProfileVC1Simple : VAEntrypointVLD VAProfileJPEGBaseline : VAEntrypointVLD VAProfileJPEGBaseline : VAEntrypointEncPicture VAProfileVP8Version0_3 : VAEntrypointEncSlice VAProfileVP8Version0_3 : VAEntrypointVLD VAProfileVP8Version0_3 : <unknown entrypoint> VAProfileHEVCMain : VAEntrypointVLD VAProfileHEVCMain : VAEntrypointEncSlice VAProfileVP9Profile0 : VAEntrypointEncSlice VAProfileVP9Profile0 : VAEntrypointVLD VAProfileVP9Profile0 : <unknown entrypoint> <unknown profile> : VAEntrypointVideoProc VAProfileNone : VAEntrypointVideoProc VAProfileNone : <unknown entrypoint>
but when I'm trying to run a test (I do not have sample_multi_transcode_drm but sample_multi_transcode), I get a core dump
$ ./sample_multi_transcode -hw -i::h264 ../content/test_stream.264 -o::h264 out.h264 Multi Transcoding Sample Version 6.0.16043361.361 libva info: VA-API version 0.99.0 libva info: va_getDriverName() returns 0 libva info: User requested driver 'iHD' libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so libva info: Found init function __vaDriverInit_0_32 libva info: va_openDriver() returns 0 Illegal instruction (core dumped)
Any ideas how to fix it?
Updated by dreamer538 dreamer538 about 8 years ago
Update: When trying to use it in tvheadend, it crashes with
Aug 16 13:52:55 tvserver kernel: [ 5234.502464] traps: tvh:mi-main[12848] trap invalid opcode ip:7f0ccd97c5f7 sp:7f0cdf7fba00 error:0 in libmfxhw64-p.so.1.17[7f0ccd4db000+8ee000]
while in web logs I see
2016-08-16 13:52:54.947 transcode: 0001: 1:H264 1280x720 ==> H264 682x384 (h264_qsv) 2016-08-16 13:52:54.947 transcode: 0001: 2:MPEG2AUDIO ==> Passthrough 2016-08-16 13:52:54.947 transcode: 0001: 3:MPEG2AUDIO ==> Passthrough 2016-08-16 13:52:54.947 transcode: 0001: 4:AC3 ==> Passthrough 2016-08-16 13:52:54.947 transcode: 0001: 5:MPEG2AUDIO ==> Passthrough 2016-08-16 13:52:55.069 transcode: 0001: missing meta data for H264 2016-08-16 13:52:55.101 transcode: 0001: Using preset veryslow There seems to be a problem with the live update feed from Tvheadend. Trying to reconnect...
Updated by zapp -it about 8 years ago
You need to run ./sample_multi_transcode_drm from the MediaSamples_Linux_6.0.16043175.175/samples/_bin/x64 dir The one you used is also crashing here
Multi Transcoding Sample Version 6.0.16043175.175
libva info: VA-API version 0.99.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_0_32
libva info: va_openDriver() returns 0
Pipeline surfaces number: 21
MFX HARDWARE Session 0 API ver 1.17 parameters:
Input video: AVC
Output video: AVC
Session 0 was NOT joined with other sessions
Transcoding started
..
Transcoding finished
Common transcoding time is 0.27 sec
MFX session 0 transcoding PASSED:
Processing time: 0.27 sec
Number of processed frames: 101
The test PASSED
For TVH I added the following lines in the file /etc/init.d/tvheadend:
export LIBVA_DRIVERS_PATH=/opt/intel/mediasdk/lib64
export LIBVA_DRIVER_NAME=iHD
Possible there is an better solution for above but it works for me
If you need any help just drop an message here
Updated by dreamer538 dreamer538 about 8 years ago
zapp -it wrote:
You need to run ./sample_multi_transcode_drm from the MediaSamples_Linux_6.0.16043175.175/samples/_bin/x64 dir The one you used is also crashing here
I just tried this one and I still get a core dump.
Running any of the commands or starting tvheadend transcoding leads to a core dump with this in kern.log:
Aug 16 16:13:06 tvserver kernel: [13645.302240] traps: sample_multi_tr[15515] trap invalid opcode ip:7fbac62aa5f7 sp:7fff4011c5c0 error:0 in libmfxhw64-p.so.1.17[7fbac5e09000+8ee000]
I'm wondering if installing Centos 7.1.1503 will be really working?
Updated by dreamer538 dreamer538 about 8 years ago
I'm just wondering, when vaapi support will be fixed, will the final result be the same as using qsv?
If so, there's no need to try to patch the kernel and use outdated kernel.
Do you think if a fix is a matter of weeks/months/years?
Updated by zapp -it about 8 years ago
If your question suggests to me, I can not answer that, I'm just a happy end user.
I think Mr. lekma is busy with the VAAPI support, but that's just a wild guess.
If you still want to play with QSV, I had forgotten to told that the latest git version ffmpeg-3.1 does not work with me, I use ffmpeg version 3.0.2 for QSV.
Updated by Anders Falk about 8 years ago
Any news on progress on this? You are doing a great job with Tvheadend.
//Anders
Updated by Jose Vigil about 8 years ago
Hi B. C. and all,
I think it would be great if someone can share the current status of the development to support vaapi with FFmpeg.
This would give the community an idea about the estimated availability date for this fantastic feature, who is working on that, if we already have a beta version, etc.
Everybody here is a little bit anxious :-) because the performance of the software trascoding is very poor.
Please count on me for testings, o whatever is needed to speed up the process.
Thank you again for the impressive job you are doing with tvheadend.
Jose
Updated by dreamer538 dreamer538 about 8 years ago
Hi Jose, all,
As a temporary solution, I installed a fork by lekma and it seems to work fine for me now. He's done an impressive work on reimplementing the codecs system.
You need to play with the setting to find a good combination (and some of them lead to tvheadend crash), but at least you can find a way to do hardware transcoding. I'm running it now and it seems to be fine.
Updated by Luis Palacios about 8 years ago
dreamer538 dreamer538 wrote:
Hi Jose, all,
As a temporary solution, I installed a fork by lekma and it seems to work fine for me now. He's done an impressive work on reimplementing the codecs system.
You need to play with the setting to find a good combination (and some of them lead to tvheadend crash), but at least you can find a way to do hardware transcoding. I'm running it now and it seems to be fine.
Thanks dreamer538 dreamer538,
Unfortunately I'm unable to make it work. Are you using tvheadend + vaapi + qsv + Intel card?
Thanks.
Luis
PD: Tests that I've done with version: 4.1-2190~gc53ee12
TEST 1: FAIL
Container: Matroska (mov)/built-in (WEBM/av-lib also tested in all tests…) Resolution (height): 720 Channels: Stereo Language: Use original Video codec: h264_vaapi: H.264/AVC (VAAPI) Video codec preset: fast: h264 / h265 / qsv(h264 / h265) Video bitrate (kb/s) (0=auto): 1024 Audio codec: mp2: MP2 (MPEG audio layer 2) Audio bitrate (kb/s) (0=auto): 64 Subtitle codec: Do not use transcode: 0002: 1:H264 1920x1080 ==> H264 1280x720 (h264_vaapi) transcode: 0002: 2:MPEG2AUDIO ==> MPEG2AUDIO (mp2) transcode: 0002: Detected framedrop in audio transcode: 0002: missing meta data for H264 libav: mmco: unref short failure transcode: 0002: Using preset fast libav: Undefined constant or missing '(' in 'high' libav: Unable to parse option value "high" libav: Error setting option profile to value high. transcode: 0002: Unable to open h264_vaapi encoder :
TEST 2: FAIL
Video codec: hevc_vaapi: H.265/HEVC (VAAPI) Video codec preset: fast: h264 / h265 / qsv(h264 / h265) transcode: 0004: 1:H264 1920x1080 ==> HEVC 1280x720 (hevc_vaapi) transcode: 0004: 2:MPEG2AUDIO ==> MPEG2AUDIO (mp2) transcode: 0004: Detected framedrop in audio transcode: 0004: missing meta data for H264 libav: mmco: unref short failure transcode: 0004: Using preset fast libav: Specified pixel format yuv420p is invalid or not supported transcode: 0004: Unable to open hevc_vaapi encoder
Updated by Luis Palacios about 8 years ago
Forgot to mention, installed from fork https://github.com/lekma/tvheadend
Regards,
Luis
Updated by Jonathan Thomson about 8 years ago
IIRC VAAPI does not depend on QSV (and vice versa; indeed VAAPI is preferred for those that don't want to mess around with specific distros and custom kernels) so there's no need to have QSV available on your box for VAAPI to function.
Updated by Jonathan Thomson about 8 years ago
dreamer538 dreamer538 wrote:
Hi Jose, all,
As a temporary solution, I installed a fork by lekma and it seems to work fine for me now. He's done an impressive work on reimplementing the codecs system.
You need to play with the setting to find a good combination (and some of them lead to tvheadend crash), but at least you can find a way to do hardware transcoding. I'm running it now and it seems to be fine.
Can you share your video codec configuration? I've just tried to set up a h264 vaapi profile but I'm getting errors around connecting to X11 - this I seem to recall is something to do with the way the hardware rendering is implemented and if X is not running when the VAAPI hardware device is selected, it can lead to failures.
Updated by Luis Palacios about 8 years ago
Jonathan Young and all, forgive if my previoys message was confusing.
I'm calling "QSV HW or just QSV" to Intel QSV HW and to differentiate I call "SDK QSV" to the propietary Intel SDK.
IIRC VAAPI does not depend on QSV (and vice versa)
As far as I understood (correct me if wrong): QSV (HW) is supported by the VAAPI, both for encoding and decoding, and VAAPI should be the preferred mode to "consume" such hardware (QSV) over any propietary/complex solution (Intel Quick Sync SDK + Patched specific Kernel).
indeed VAAPI is preferred for those that don't want to mess around with specific distros and custom kernels)
Agree...
so there's no need to have QSV available on your box for VAAPI to function.
As I mentioned, when I say QSV I refer to the HW not to the QSV SDK, maybe that's the confusion?
Also, would like to share my findings:
1- Specific Linux distro with specific Kernel with specific patches + Tvheadend can be built together with "Intel Quick Sync SDK" and HW Acceleration will work. I've tested it and works. Unfortunately this is not what I want.
2- Linux (any) as of today supports HW Acceleration on QSV HW (without QSV SDK) with X11 supporting it too and with FFMPEG > 3.x. Access to the QSV HW is done through VAAPI. I've tested it and works. In this box there is NO need to install QSV SDK.
3- Tvheadend does NOT have native support of VAAPI to access the QSV (Intel HW), does NOT work yet. Tried with lekma fork.
Thanks all for your comments
Regards,
Luis
Updated by Jonathan Thomson about 8 years ago
Hi Luis - no need to apologise - I'm just learning here - my understanding was that VAAPI was an open standard for accessing hardware acceleration on Linux operating systems whilst QSV (short for Intel Quick Sync Video) is the closed-source equivalent (which as mentioned above needs the SDK, specific builds of Linux, specific kernels and specific TVH patches...all in all a bit of a nightmare to get set up for those who already have functioning systems). VAAPI is capable of using the hardware acceleration features of the Intel processors that support it, without any special software above the Intel drivers which whilst proprietary make the hardware acceleration device available for other packages to use with little modification (ffmpeg is one such example, using ffmpeg and addressing the Intel hardware acceleration device in the encoding command line options allows ffmpeg to make use of the hardware acceleration for video encoding).
I can see you have put a lot into the research of the technologies so the above should be taken as my understanding only, I'm not saying either one of us is right or wrong just how I understood hardware acceleration worked on Linux.
Updated by Anders Falk about 8 years ago
dreamer538 dreamer538 wrote:
Update: the work is in the codecs branch
Qustion then :-) : How did you compile? ./Autobuild????
//Anders
Updated by Luis Palacios about 8 years ago
Anders Falk wrote:
dreamer538 dreamer538 wrote:
Update: the work is in the codecs branch
Qustion then :-) : How did you compile? ./Autobuild????
//Anders
Ough!!... completely forgot to change branch during my tests. I can't believe, they were useless.
I'll retest now (w/ codecs) and come back.
Thanks Anders,
Luis
Updated by Anders Falk about 8 years ago
Luis Palacios wrote:
Anders Falk wrote:
dreamer538 dreamer538 wrote:
Update: the work is in the codecs branch
Qustion then :-) : How did you compile? ./Autobuild????
//Anders
Ough!!... completely forgot to change branch during my tests. I can't believe, they were useless.
How will you compile?
I tried this...but no luck:
git clone -b codecs https://github.com/lekma/tvheadend
sudo AUTOBUILD_CONFIGURE_EXTRA=--enable-vaapi_static ./Autobuild.sh -t
//Anders
I'll retest now (w/ codecs) and come back.
Thanks Anders,
Luis
Updated by Luis Palacios about 8 years ago
Hi team, finally got it working with VAAPI and my Intel card :-)
Although not perfect as mentioned before by dreamer538, you need to play with the setting to find a good combination (and some of them lead to tvheadend crash), but at least you can find a way to do hardware transcoding, however... from my findings it's not very stable if you start more than 2 clients against the server.
Of course you need to checkout the “codecs” branch, I'm compiling like this step by step.
marte ~ # mkdir /root/github_tvh_lekma
marte ~ # cd /root/github_tvh_lekma/
marte github_tvh_lekma # git clone https://github.com/lekma/tvheadend.git
marte github_tvh_lekma # cd tvheadend/
marte github_tvh_lekma # git checkout codecs
./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info \
--datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/lib64 --prefix=/usr --datadir=/usr/share --enable-vaapi
Then, I’ve configured 2 new Codec Profiles (video with h264_vaapi and audio with mpeg2), then 1 x new Stream Profile using these 2 codec profiles. Then I assign that stream profile to one specific user and connect using that user from a client.
The most stable configuration I have found in my “h264_vaapi Codec Profile” is the following:
Deinterlace: On
Height: 128, 192, 256, 512 (tested all of them)
HW accelerration: On
Bitrate: 0 (Be very careful here, seems it’s not yet supported/fully implemented, depending on the value may crash tvheadend)
Constant QP: 0
Profile: Main (I’m testing broadcast TV HD)
Pixel format: vaapi_vld
Comments:
- It works, I finally see the intel gpu working. Using intel_gpu_top to monitor it.
- GPU consumption keeps 5-15%.
- CPU consumption keeps max at 50% (tested in i5 and i7, never more)
It works very well with 1 or 2 clients but with more it starts to pixelate and as mentioned, bitrate seems not supported jet, so I can only play with the Height which turns very difficult to control the bandwidth.
Luis
Updated by Fabio Neves about 8 years ago
Hey.
I compiled mine just fine, but can't seem to get VAAPI transcoding working.
I'm trying this in a Asus Chromebox (Intel 2955U Celeron) and used the lekma codecs branch.
Output when starting and trying to transcoding tvheadend.
...
2016-09-02 02:02:01.978 [ INFO] codec: 'h264_vaapi' encoder registered
2016-09-02 02:02:01.979 [ INFO] codec: 'hevc_vaapi' encoder registered
....
2016-09-02 02:02:07.665 [ INFO] transcode: 0001: 00:UNKNOWN: > Filtered out
2016-09-02 02:02:07.666 [ INFO] transcode: 0001: 03:MPEG2AUDIO: > Passthrough
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
2016-09-02 02:02:08.199 [ INFO] vaapi: successful context creation for device: /dev/dri/renderD128
2016-09-02 02:02:08.200 [ ERROR] libav: mmco: unref short failure
2016-09-02 02:02:08.262 [ ERROR] vaapi: unsupported codec: h264_vaapi and/or profile: (null)
....
I've also tried with h265/hvec and the result is the same.
My 'vainfo' output:
root@streamer:/home/front/tvhcodecs# vainfo
error: XDG_RUNTIME_DIR not set in the environment.
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) Haswell Mobile - 1.7.1
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264Main : VAEntrypointVLD
VAProfileH264High : VAEntrypointVLD
VAProfileH264MultiviewHigh : VAEntrypointVLD
VAProfileH264StereoHigh : VAEntrypointVLD
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileNone : VAEntrypointVideoProc
VAProfileJPEGBaseline : VAEntrypointVLD
Any ideas?
Thanks
Updated by Anders Falk about 8 years ago
Hm. I´m getting:
checking for pkg libva >=0.38.0 ... fail (detected <none>)
ERROR: vaapi (Video Acceleration (VA) API for Linux) not found
vainfo tells me that 0.39 is installed..
Anyone have any ideas? Running Ubuntu 16.04.1
//Anders
Updated by MinGyoon Woo about 8 years ago
With the https://github.com/lekma/tvheadend fork, it works...
My system is
J1900 Celeron
Debian Jessie with backports kernel 4.6
libdrm 2.4.68, libva 1.7.1, i965-driver 1.7.1
When I tried transcoding to 512p, it used 34~36% of CPU.
Thanks for the hardwork.....
Updated by MinGyoon Woo about 8 years ago
Luis Palacios wrote:
Forgot to mention, installed from fork https://github.com/lekma/tvheadend
Regards,
Luis
Hi,
First, sorry for poor English.
I've test with codes you mentioned. And it works!
However I found something issues from those codes. I am not C programmer, so it just opinion about I think.
1. I got the freezing screen at every 5~10 seconds, maybe H/W performance issue or related with below issue?
2. I found scaling option from code 'transcoding/transcode/video.c' like "scale=w=-2:h=%d". When I tried transcode in shell, that filter does not work with vaapi, if I using the "scale_vaapi=w=..." is works.
BTW,
I'm really thanks for your hardwork.
Updated by MinGyoon Woo about 8 years ago
Here is recording result with 480p/H264_VAAPI transcoding option
==========================
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings, CABAC : Yes
Format settings, ReFrames : 2 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 32s 432ms
*Width : 1 920 pixels
Original width : 854 pixels
Height : 1 080 pixels
Original height : 480 pixels
*Display aspect ratio : 16:9
Original display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Language : English
Default : Yes
Forced : No
==========================
Updated by Antti Lehtinen about 8 years ago
Fabio Neves wrote:
Hey.
I compiled mine just fine, but can't seem to get VAAPI transcoding working.
I'm trying this in a Asus Chromebox (Intel 2955U Celeron) and used the lekma codecs branch.
2955U doesn't have quicksync hardware (see Intel ARK), so it will not have any hardware encoding/transcoding. vainfo output is also therefore missing all "VAEntrypointEncSlice"-encoding capabilities.
Updated by S K about 8 years ago
it works well with lekma's fork
G3258, debian stretch
Transcoding to 512p/AAC
- one stream 39% CPU
- two streams 75-78% CPU
Updated by dreamer538 dreamer538 about 8 years ago
MinGyoon Woo wrote:
I've test with codes you mentioned. And it works!
However I found something issues from those codes. I am not C programmer, so it just opinion about I think.1. I got the freezing screen at every 5~10 seconds, maybe H/W performance issue or related with below issue?
I had same issue, when trying to transcode audio as well, try to copy the audio codec
2. I found scaling option from code 'transcoding/transcode/video.c' like "scale=w=-2:h=%d". When I tried transcode in shell, that filter does not work with vaapi, if I using the "scale_vaapi=w=..." is works.
You can check if GPU is used by intel_gpu_top
Updated by Fabio Neves about 8 years ago
Antti Lehtinen wrote:
Fabio Neves wrote:
Hey.
I compiled mine just fine, but can't seem to get VAAPI transcoding working.
I'm trying this in a Asus Chromebox (Intel 2955U Celeron) and used the lekma codecs branch.2955U doesn't have quicksync hardware (see Intel ARK), so it will not have any hardware encoding/transcoding. vainfo output is also therefore missing all "VAEntrypointEncSlice"-encoding capabilities.
I know it doesn't have QuickSync, but I thought VAAPI didn't use QuickSync or didn't need it on the CPU.
Thanks for replying
Updated by L C about 8 years ago
Hi,
Managed to make vaapi transcoding working on my brand new J3710-itx motherboard. Only issue I got is that the format is kind of "doubled" horizontally, ie the output image is stretched by a factor of 2. I have tried many different resolution, output is always the same. I have fiddled around with the settings, but I find no way to change that behaviour.
If anybody has an idea...
Updated by L C about 8 years ago
L C wrote:
Hi,
Managed to make vaapi transcoding working on my brand new J3710-itx motherboard. Only issue I got is that the format is kind of "doubled" horizontally, ie the output image is stretched by a factor of 2. I have tried many different resolution, output is always the same. I have fiddled around with the settings, but I find no way to change that behaviour.
If anybody has an idea...
Commenting on my own point, I finally found the issue which seems to be related to the container "Matroska (mkv)/av-lib". When I select other containers, the image is perfect (ie A/R is correct), when I select that container image is stretched horizontally by a factor of two !!!
Seems very weird, but this is really what is happening.
Updated by Josu Lazkano about 8 years ago
Hello,
Is someone working on it?
It will be great to have hardware transcoding feature in Tvheadend.
Best regards.
Updated by Stephan Oelze about 8 years ago
Hello.
I can confirm ffmegs vaapi encode is working verry well an stable.
For now i am using it with vdr on a I5-3330S i bought on ebay für 80$ including mainboard and ram.
On that machine i stream 4 1080p/8M Streams(end of bandwith) simultaneous using ffmpeg+vaapi. Tvheadend definitely needs to implement that one,
its a world changer for streaming purposes. I had tested with file from dis, to disk. I can easily manage 8 Streams with 30fps without glitches.
I am familiar with debugging/tracing in tvheadend and i am willing to test and help debug here.
Or my be using stdout + external script like vdr is doing?
Regards
Stephan
Updated by Frank Schimmack about 8 years ago
- File codec_h264_vaapi.PNG codec_h264_vaapi.PNG added
- File codec_h264_vaapi_not_accessable.PNG codec_h264_vaapi_not_accessable.PNG added
- File codec_h264_vaapi_not_active.PNG codec_h264_vaapi_not_active.PNG added
Luis Palacios wrote:
Hi team, finally got it working with VAAPI and my Intel card :-)
Although not perfect as mentioned before by dreamer538, you need to play with the setting to find a good combination (and some of them lead to tvheadend crash), but at least you can find a way to do hardware transcoding, however... from my findings it's not very stable if you start more than 2 clients against the server.
Of course you need to checkout the “codecs” branch, I'm compiling like this step by step.
marte ~ # mkdir /root/github_tvh_lekma
marte ~ # cd /root/github_tvh_lekma/
marte github_tvh_lekma # git clone https://github.com/lekma/tvheadend.git
marte github_tvh_lekma # cd tvheadend/
marte github_tvh_lekma # git checkout codecs
./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info \
--datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/lib64 --prefix=/usr --datadir=/usr/share --enable-vaapiThen, I’ve configured 2 new Codec Profiles (video with h264_vaapi and audio with mpeg2), then 1 x new Stream Profile using these 2 codec profiles. Then I assign that stream profile to one specific user and connect using that user from a client.
The most stable configuration I have found in my “h264_vaapi Codec Profile” is the following:
Deinterlace: On
Height: 128, 192, 256, 512 (tested all of them)
HW accelerration: On
Bitrate: 0 (Be very careful here, seems it’s not yet supported/fully implemented, depending on the value may crash tvheadend)
Constant QP: 0
Profile: Main (I’m testing broadcast TV HD)
Pixel format: vaapi_vldComments:
- It works, I finally see the intel gpu working. Using intel_gpu_top to monitor it.
- GPU consumption keeps 5-15%.
- CPU consumption keeps max at 50% (tested in i5 and i7, never more)It works very well with 1 or 2 clients but with more it starts to pixelate and as mentioned, bitrate seems not supported jet, so I can only play with the Height which turns very difficult to control the bandwidth.
Luis
I followed the installation, but I am not able to activate the codec profile. I was able to choose h264_vaapi, but then I am not able to enable/acitvate it in the codec profile.
Some questions about that:
- does anyone know why?
- so I have to compile ffmpeg 3.1.3 addionally or is it integrated in tvheadend ?
I am able to transcode using ffmpeg in the terminal (160 FPS on N2930 Celeron, so vaapi hw accelerated is working!), but I am not able to create a streaming profile, because the codec profile for h264_vaapi, i created, is not accessable.
Please have a look at the snapshots.
Hope you have some ideas.
regards,
theo
Updated by Frank Schimmack about 8 years ago
Ok. I have done some further steps. I followed the instructions and I am able to compile and the vaapi transcoding (hw accelerated) is running now. But how can I get the compiled tvheadend packaged? Or even automated start of tvheadend would be nice after reboot. If I do the "Autobuild.sh", the vaapi is not included. How can I configure the package, so that vaapi is included?
Thanks for any response and your hard work!
Updated by Frank Schimmack about 8 years ago
Hi experts,
nobody had an idea, so I had to help myself....
Now tvheadend works using vaapi on my Zotac CI320 (N2930, Intel Celeron). Now my question... the idea was to watch TV for example in a hotel using wifi. The bandwidth of the wifi is normally not so good, so I only want one video stream and one stream for audio to save bandwitdh. But if I use the stream as described here, all audio stream are transcoded. Is it possible to select the audio stream to be transcoded?
regards,
Frank
Updated by dorin ilut about 8 years ago
Hi Frank,
Can you give more details about your box? I am also looking for a machine that can do transcoding and if you say your's is working I would look for something similar. can you also post what your config looks like?
Many thanks for your advice.
Dorin
Updated by Frank Schimmack about 8 years ago
Hi Dorin,
sorry for my late answer. So my machine is a Zotac mini computer (google for zotax zbox CI320 plus, price is lower than 270 Euro). It has an intel gpu which can be used very well. I installed Ubuntu 16.04 LTS 64-bit. The zbox was not very stable, so had to do some additional work (bios update, grub changes etc.), but now it is doing his job well except stability. It could be more stable (one freeze in 3 days). I am actually analyzing this, which is not easy for me. For the DVB-S2 Signal I am using a simple usb2 variant (Mystique SaTiX-S2). You just have to install the firmware and it will be recognized perfectly in tvh.
Hope it helps.
regards,
theo
p.s.: when will vaapi officially supported including hardware acceleration?
Updated by Brian Shensky about 8 years ago
Where in tarnation do you specify the "Video codec profiles" in the lekma branch?
I go to the Transcoding section of the Stream profiles, and I see a dropdown for "Video codec profile", "Audio codec profile" and "Subtitle codec profile", but each of these only contain "Copy" and "Disabled". I've looked for a tab up top labeled codec profiles or some such but do not see it.
Disclaimer: Upon successful make, I just copied the tvheadend executable from build.linux over to /usr/bin/, zeroed out my /home/hts/.hts/tvheadend folder, and restarted the service on Ubuntu 16.04.
Perhaps the codec profiles are in auxiliary files?
-Brian
Updated by Hafeez Ahmad almost 8 years ago
Anders Falk wrote:
Hm. I´m getting:
checking for pkg libva >=0.38.0 ... fail (detected <none>)
ERROR: vaapi (Video Acceleration (VA) API for Linux) not foundvainfo tells me that 0.39 is installed..
Anyone have any ideas? Running Ubuntu 16.04.1
//Anders
You need to install libva-dev with: apt-get install libva-dev
Compiling now myself
Updated by Sangwoo Kim almost 8 years ago
With lekma's fork, transcoding from 1080 to 720 or below works on Z3735F and N3510 cpus.
But the Deinterlace option should be Off.
With Deinterlace=On, even N35100 cpu suffers buffering every 3~5 seconds.
Updated by Brian Shensky almost 8 years ago
Brian Shensky wrote:
Where in tarnation do you specify the "Video codec profiles" in the lekma branch?
I go to the Transcoding section of the Stream profiles, and I see a dropdown for "Video codec profile", "Audio codec profile" and "Subtitle codec profile", but each of these only contain "Copy" and "Disabled". I've looked for a tab up top labeled codec profiles or some such but do not see it.
Disclaimer: Upon successful make, I just copied the tvheadend executable from build.linux over to /usr/bin/, zeroed out my /home/hts/.hts/tvheadend folder, and restarted the service on Ubuntu 16.04.
Perhaps the codec profiles are in auxiliary files?
To answer my own questions, and then some...
- I did not see the "Codec Profiles" tab at the time because I failed to "git checkout codecs" during the make, as specified in Luis' post #72 above. DO IT! It's important.
- Upon compiling with "git checkout codecs", I did thereafter get a new tab "Codec Profiles" next to "Stream Profiles" tab.
- Also as Luis posted, I created 2 codec profiles, one for VAAPI video, and the other using AAC at 64kbps, then created a Stream Profile using these 2 codec profiles. My stream profile uses MPEG-TS instead of MKV, however.
- Unlike Luis' post, and as Sangwoo #93 said above, DEINTERLACING IS EXPENSIVE, causing one of my G3258 CPU cores to go to 50% with deinterlacing, but only go to 11% with deinterlacing off (unchecked). My HDHomeRun's HD broadcasts really don't need deinterlacing anyway. Yay me.
- Attempts to constrain bitrate in the VAAPI codec profile do freeze up TVHeadend with this error: "[WARNING] mpegts: too much queued input data (over 50MB), discarding new".
- I have a Geforce GE710 alongside the Intel QSV-enabled (via VAAPI) CPU onboard. I had hoped I could --enable-nvenc on the ./configure command, but NVENC is nowhere to be found in the resulting executable.
- It almost worked when I included --enable-libfdkaac in the make. I see it in the app, and can even make a Codec Profile that uses it, but it's not enabled for me to create a Stream Profile with it. I'll just have to stick with the onboard AAC encoder for now.
VAAPI in Lekma's branch shows real promise - I will be using it, and hope we can get these mods - especially the Codec Profiles - merged back into the main repo.
-brian
Updated by Antonio S almost 8 years ago
Hi all
One question: is the branch codecs still valid? I mean, in the master branch there is official support for transcoding, and it is possible to specify ffmpeg profile. Doing so, with a proper compiled ffmpeg, it should be possible to transcode using vaapi or omx (which is the case I'm starting to work on), or?
Updated by Anders Falk almost 8 years ago
Hi
Also interested if Lekmas mods will be merged with main repo. VAAPI works good in Lekmas repo with some things still not quite there. Is it beeing looked into?
//Anders
Updated by Antonio S almost 8 years ago
Hi
Lekma fork use some internal encoding, I don't know if will ever be merged in main, since main is relaying on ffmpeg for transcoding.
You can try this: build tvheadend (git master) with either static ffmpeg wil Makefile.ffmpeg modified in the part of the ffmpeg build witjh the adding of --enable-vaapi, or without static ffmpeg if on your host ha libavcodec (and the other ffmpeg libraries) built with --enable-vaapi
Then in the Stream page, create a new transcoding stream. Even if you cannot see in the video codec, h264_vaapi, just type it, since the webui pass this string to the libavcodec codec pickup. If h264_vaapi doesn't need other specific trick (as pixel format) it may work
Updated by Luis Palacios almost 8 years ago
Antonio S wrote:
You can try this: build tvheadend (git master) with either static ffmpeg wil Makefile.ffmpeg modified in the part of the ffmpeg build witjh the adding of --enable-vaapi, or without static ffmpeg if on your host ha libavcodec (and the other ffmpeg libraries) built with --enable-vaapi
Then in the Stream page, create a new transcoding stream. Even if you cannot see in the video codec, h264_vaapi, just type it, since the webui pass this string to the libavcodec codec pickup. If h264_vaapi doesn't need other specific trick (as pixel format) it may work
Hi Antonio, I've tried this but does nothing, reports that h264_vaapi is not found. Can you please explain more in detail?
Thanks
Luis
Updated by Remi Os almost 8 years ago
Luis Palacios wrote:
Hi team, finally got it working with VAAPI and my Intel card :-)
marte github_tvh_lekma # git clone https://github.com/lekma/tvheadend.git
marte github_tvh_lekma # cd tvheadend/
marte github_tvh_lekma # git checkout codecs
./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info \
--datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/lib64 --prefix=/usr --datadir=/usr/share --enable-vaapiThen, I’ve configured 2 new Codec Profiles (video with h264_vaapi and audio with mpeg2), then 1 x new Stream Profile using these 2 codec profiles.
Then I assign that stream profile to one specific user and connect using that user from a client.
Pixel format: vaapi_vld
I've tried the Lekma fork, with configure and Autobuild script.
The build works fine, but when i try to start a stream i get the following error in /var/log/syslog
(user "hts" is added to the video group)
Jan 31 19:08:34 UbuntuServer tvheadend16958: vaapi: failed to find suitable VAAPI device
Jan 31 19:08:34 UbuntuServer tvheadend16958: libav: No VA display found for device: /dev/dri/renderD128.
Jan 31 19:08:34 UbuntuServer tvheadend16958: libav: No VA display found for device: /dev/dri/renderD129.
Jan 31 19:08:34 UbuntuServer tvheadend16958: libav: No VA display found for device: /dev/dri/renderD130.
Jan 31 19:08:34 UbuntuServer tvheadend16958: libav: No VA display found for device: /dev/dri/card0.
Jan 31 19:08:34 UbuntuServer tvheadend16958: libav: No VA display found for device: /dev/dri/card1.
Jan 31 19:08:34 UbuntuServer tvheadend16958: libav: No VA display found for device: /dev/dri/card2.
Jan 31 19:08:34 UbuntuServer tvheadend16958: vaapi: failed to find suitable VAAPI device
#ls /dev/dri al 1 root video 226, 0 Jan 31 19:15 card0
total 0
drwxr-xr-x 2 root root 100 Jan 31 19:15 .
drwxr-xr-x 20 root root 4660 Jan 31 19:15 ..
crw-rw---
crw-rw---- 1 root video 226, 64 Jan 31 19:15 controlD64
crw-rw---- 1 root video 226, 128 Jan 31 19:15 renderD128
#vainfo gives the below output, and
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/local/lib/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
When i try ffmpeg it runs fine and in intel_gpu_top i can see the GPU getting load.
ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i h264.mkv -vf 'format=nv12,hwupload' -map 0:0 -map 0:1 -threads 8 -aspect 16:9 -y -f matroska -acodec copy -c:v h264_vaapi test.mkv
Updated by Remi Os almost 8 years ago
Does someone know what's wrong here ?
P.s. running Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-040400-generic x86_64)
Updated by Remi Os over 7 years ago
I've got it working (almost)
First i installed a 4.8.11 Kernel
Then i manually compiled:
libcmrt1_1.0.6+dfsg1-1_amd64.deb (dependancy )
libcmrt-dev_1.0.6+dfsg1-1_amd64.deb (dependancy )
intel-hybrid-driver (from git)
intel-vaapi-driver (from git)
libva (from git)
libva-utils (from git)
xf86-video-intel (from git)
libdrm-2.4.75 (from Intel 2016Q4)
mesa-13.0.1 (from Intel 2016Q4)
xorg-server-1.19.0 (from Intel 2016Q4)
Then i build TVheadend
git clone -b codecs https://github.com/lekma/tvheadend.git
cd tvheadend
git checkout codecs
AUTOBUILD_CONFIGURE_EXTRA="--enable-ffmpeg --enable-libffmpeg_static --enable-libx264 --enable-libx265 --enable-vaapi --enable-libfdkaac" ./Autobuild.sh -t precise-amd64
cd ..
dpkg -i tvheadend_4.1-2211~gdbdd70f~precise_amd64.deb
Now i can a Codec_Profile for H264_vaapi and one for AAC witch i can choose in my Stream profile
When i look at intel_gpu_top i can see the GPU getting some load.
The only issue i have now is my 16:9 channels get transformed to 4:3 ...
I can't see anywhere an option to configure this
Updated by Remi Os over 7 years ago
sorry i ment ..
AUTOBUILD_CONFIGURE_EXTRA="--enable-ffmpeg_*static* --enable-libffmpeg_static --enable-libx264 --enable-libx265 --enable-vaapi --enable-libfdkaac" ./Autobuild.sh -t precise-amd64
Updated by Chris Koster over 7 years ago
This would be awesome, I have picons and comskip working. Vaapi support would be the final hurdle for me! Anybody got it working without lekma's fork? I'm not to fond of using Lekma's fork because it hasn't been updated in over a year. Any TVH dev's willing to comment if vaapi support is planned?
Maybe the solution can be that users can choose if they want to use either the built-in ffmpeg or the ffmpeg that's installed on the system. Then only options need to be added to transcode settings.
Updated by C vH over 7 years ago
Tvheadend has no usable vaapi support at the moment, the lekma branch is working but is heavily outdated and sadly not finished iirc.
Updated by Pyro maniac over 7 years ago
Sopli28 sopli28 wrote:
+1 need vaapi support
Me too! Would be an awesome feature.