Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ffmpeg intel quick sync #3842

Merged
merged 23 commits into from
Jan 18, 2020
Merged

Conversation

th0ma7
Copy link
Contributor

@th0ma7 th0ma7 commented Jan 2, 2020

Motivation: Migrate over to newer VAAPI driver implementation using iHD driver 19.4.0
Linked issues: #3830

Checklist

  • Build rule all-supported completed successfully
  • Package upgrade completed successfully
  • New installation of package completed successfully

New iHD driver and dependancies significantly increases compile time for x64 arch.

@th0ma7 th0ma7 requested a review from ymartin59 January 2, 2020 03:14
@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 2, 2020

New driver output on apollolake:

$ sudo /var/packages/ffmpeg/target/bin/vainfo 
Password: 
libva info: VA-API version 1.6.0
libva info: Trying to open /var/packages/ffmpeg/target/lib/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_6
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.6 (libva 2.6.0)
vainfo: Driver version: Intel iHD driver - 19.4.0
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointStats
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointFEI
      VAProfileH264Main               :	VAEntrypointEncSliceLP
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointFEI
      VAProfileH264High               :	VAEntrypointEncSliceLP
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointFEI
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointFEI
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointVLD

@th0ma7 th0ma7 added enhancement request to enhance existing package status/needs-review labels Jan 2, 2020
@th0ma7 th0ma7 self-assigned this Jan 2, 2020
@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 2, 2020

@kc6108 here you go:

ffmpeg -codecs 2>/dev/null | grep -Ei -e ' e?ac3' -e 'truehd' -e 'dts' -e 'h26[45]' -e 'hevc' -e 'qsv'

$ ./ffmpeg -codecs 2>/dev/null | grep -Ei -e ' e?ac3' -e 'truehd' -e 'dts' -e 'h26[45]' -e 'hevc' -e 'qsv'
 DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m h264_qsv ) (encoders: libx264 libx264rgb h264_qsv h264_v4l2m2m h264_vaapi )
 DEV.L. hevc                 H.265 / HEVC (High Efficiency Video Coding) (decoders: hevc hevc_qsv ) (encoders: libx265 hevc_qsv hevc_vaapi )
 DEVIL. mjpeg                Motion JPEG (encoders: mjpeg mjpeg_qsv mjpeg_vaapi )
 DEV.L. mpeg2video           MPEG-2 video (decoders: mpeg2video mpegvideo mpeg2_v4l2m2m mpeg2_qsv ) (encoders: mpeg2video mpeg2_qsv mpeg2_vaapi )
 D.V.L. vc1                  SMPTE VC-1 (decoders: vc1 vc1_qsv vc1_v4l2m2m )
 DEV.L. vp8                  On2 VP8 (decoders: vp8 vp8_v4l2m2m libvpx vp8_qsv ) (encoders: libvpx vp8_v4l2m2m vp8_vaapi )
 DEA.L. ac3                  ATSC A/52A (AC-3) (decoders: ac3 ac3_fixed ) (encoders: ac3 ac3_fixed )
 DEA.LS dts                  DCA (DTS Coherent Acoustics) (decoders: dca ) (encoders: dca )
 DEA.L. eac3                 ATSC A/52B (AC-3, E-AC-3)
 DEA..S truehd               TrueHD

@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 2, 2020

My readings leans towards the following:
Option 1) _smd

  1. I can port Synology ffmpeg evansport patches from 2.7.1 to 4.2.1. I think it's relatively easy.
  2. I would need to compile against Intel® Media Processor SDK pre-built libraries that are provided through here:
    https://sourceforge.net/projects/dsgpl/files/toolkit/DSM6.0/ds.evansport-6.0.dev.txz
    By far the best would be to find the source code of the original Intel® Media Processor SDK (perhaps by asking Intel directly?)

Option 2) _qsv
I believe that the Intel® Media Processor SDK was superseeded by Intel® Media SDK. If this is true then it may be possible to get _qsv encoders/decoders working for evansport arch. I'll check if this is even feasible.

Option 3) _smd & _qsv
Get both options working so it is backward compatible.

@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 2, 2020

I have read some really good fixes for pixelation type issues are included with i965 v2.4 as well. Might pull in latest libva-utils as well. Just a thought.

https://github.com/intel/libva-utils/archive/2.6.0.tar.gz
https://github.com/intel/intel-vaapi-driver/archive/2.4.0.tar.gz

If I'm not mistaken, we can revert to the i965 driver by simply deleting/renaming the iHD driver? Is that correct?

I had pulled libva 2.6 but forgot to pull libva-utils as well. Will do that for next round of packages.

Also yes, it does fallback to "legacy" i965 driver when renaming iHD_drv_video.so:

$ sudo ./vainfo 
libva info: VA-API version 1.6.0
libva info: Trying to open /var/packages/ffmpeg/target/lib/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /var/packages/ffmpeg/target/lib/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_6
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.6 (libva 2.6.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Broxton - 2.1.0
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSliceLP
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointEncSliceLP
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointEncSliceLP
      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
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointVLD

Lastly, x64 package version -20 now available.

@BenjaminPoncet
Copy link

My readings leans towards the following:
Option 1) _smd

  1. I can port Synology ffmpeg evansport patches from 2.7.1 to 4.2.1. I think it's relatively easy.
  2. I would need to compile against Intel® Media Processor SDK pre-built libraries that are provided through here:
    https://sourceforge.net/projects/dsgpl/files/toolkit/DSM6.0/ds.evansport-6.0.dev.txz
    By far the best would be to find the source code of the original Intel® Media Processor SDK (perhaps by asking Intel directly?)

Option 2) _qsv
I believe that the Intel® Media Processor SDK was superseeded by Intel® Media SDK. If this is true then it may be possible to get _qsv encoders/decoders working for evansport arch. I'll check if this is even feasible.

Option 3) _smd & _qsv
Get both options working so it is backward compatible.

Such good news!
I'll test the -20 quickly (on Synology DS718+)
Just to understand, is it necessary to use the h264_qsv codec to use Quick Sync or does the iHD driver do it by itself through VAAPI?
Concretely EvanSport it would be great that it works with quick sync and option 3 would just be perfect.
Anyway, we have someone who I think will be happy to test both solutions on my gist.
Thanks again for your great work.

@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 2, 2020

I'll test the -20 quickly (on Synology DS718+)

Let me know how thing goes with it.

Just to understand, is it necessary to use the h264_qsv codec to use Quick Sync or does the iHD driver do it by itself through VAAPI?

I believe so.
Now question is, will videostation automatically call-up *_qsv instead of *_vaapi ?

Concretely EvanSport it would be great that it works with quick sync and option 3 would just be perfect.

I will need quite a few more cycles to get any of the options working for evansport ...
And I don't have a compatible NAS to test things up which further complicates things.

@BenjaminPoncet
Copy link

First test with the h265 10bit video I've been using since the beginning and without changing anything to the wrapper: It's much better, indeed there is no more pixelization in the first minutes but above all, the transcoding in medium quality (720p) and in low quality (480p) is much better.
So Quick Sync or not the iHD driver brings a real plus.
I will now test and compare using _qvs via the wrapper and a rewrite of the parameters.
I'm not sure I'll see a gain in quality but maybe a gain in CPU load.

Concerning EvanSport if it's easier to compile with Quick Sync at first, I can create a specific wrapper for EvanSport. Because if indeed Quick Sync works with EvanSport, SMD is only of interest for direct compatibility with VideoStation, not for ffmpeg use outside VideoStation...

@ymartin59
Copy link
Contributor

@th0ma7 I have evansport device (DS214play) so I may compile with specific options and try on my own with video samples. Let me know

@BenjaminPoncet
Copy link

@th0ma7,

I have finished my first QVS tests and the hevc_qsv driver seems not to work. Every time I use it in encoding, decoding or hevc/hevc transcoding I get the following error:

[hevc_qsv @ 0xd1d800] Could not load the requested plugin '33a61c0b4c27454ca8d85dde757c6f8e': specified object was not found (-9)

On the other hand, h264 transcoding works correctly.

Here are my logs for h264 transcoding (which works):

2020-01-02 23:59:22 - hYdCTjxZ - *** PROCESS START ***
2020-01-02 23:59:22 - hYdCTjxZ - MOVIE    = /volumeUSB2/usbshare/Films/VID_H264_AC3.mkv
2020-01-02 23:59:22 - hYdCTjxZ - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-02 23:59:22 - hYdCTjxZ - PARAMVS  =
2020-01-02 23:59:22 - hYdCTjxZ -          = -ss 0.000 -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i /volumeUSB2/usb
2020-01-02 23:59:22 - hYdCTjxZ -          = share/Films/VID_H264_AC3.mkv -vcodec h264_vaapi -vf format=nv12|vaapi,hwupload,setsar=sar=1,scale_vaapi=w=1920:h=1040 -v
2020-01-02 23:59:22 - hYdCTjxZ -          = sync 2 -bf 0 -vb 4500000 -acodec libmp3lame -ab 128K -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3u8 -h
2020-01-02 23:59:22 - hYdCTjxZ -          = ls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segment_start_number 00000 -avoid_negative_ts 0 -break_non_key
2020-01-02 23:59:22 - hYdCTjxZ -          = frames 1 -max_muxing_queue_size 1024 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/e99c64d12acf192e0e7005d6c89bf96e_hYdCTjxZ/s
2020-01-02 23:59:22 - hYdCTjxZ -          = lice-%05d.ts
2020-01-02 23:59:22 - hYdCTjxZ - PARAMQVS =
2020-01-02 23:59:22 - hYdCTjxZ -          = -ss 0.000 -hwaccel qsv -vcodec h264_qsv -noautorotate -i /volumeUSB2/usbshare/Films/VID_H264_AC3.mkv -vcodec h264_qsv -v
2020-01-02 23:59:22 - hYdCTjxZ -          = f scale_qsv=w=1920:h=1040 -vsync 2 -bf 0 -vb 4500000 -acodec libmp3lame -ab 128K -ac 2 -f ssegment -segment_format mpegt
2020-01-02 23:59:22 - hYdCTjxZ -          = s -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segment_start_number 00000 -avoid_
2020-01-02 23:59:22 - hYdCTjxZ -          = negative_ts 0 -break_non_keyframes 1 -max_muxing_queue_size 1024 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/e99c64d12acf192
2020-01-02 23:59:22 - hYdCTjxZ -          = e0e7005d6c89bf96e_hYdCTjxZ/slice-%05d.ts
2020-01-02 23:59:22 - hYdCTjxZ - CHILDPID = 7102
2020-01-03 00:00:00 - hYdCTjxZ - *** KILLCHILD ***
2020-01-03 00:00:00 - hYdCTjxZ - *** CHILD END ***
2020-01-03 00:00:00 - hYdCTjxZ - *** PROCESS END ***

Here are my logs for h265 8bits -> h264 transcoding (which doesn't work):

2020-01-03 00:18:59 - vvT4Wijp - *** PROCESS START ***
2020-01-03 00:18:59 - vvT4Wijp - MOVIE    = /volumeUSB2/usbshare/Films/VID_H265_EAC3.mkv
2020-01-03 00:18:59 - vvT4Wijp - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-03 00:18:59 - vvT4Wijp - PARAMVS  =
2020-01-03 00:18:59 - vvT4Wijp -          = -ss 0.000 -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i /volumeUSB2/usb
2020-01-03 00:18:59 - vvT4Wijp -          = share/Films/VID_H265_EAC3.mkv -vcodec h264_vaapi -vf format=nv12|vaapi,hwupload,setsar=sar=1,scale_vaapi=w=1920:h=960 -v
2020-01-03 00:18:59 - vvT4Wijp -          = sync 2 -bf 0 -vb 3183492 -acodec libmp3lame -ab 128K -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3u8 -h
2020-01-03 00:18:59 - vvT4Wijp -          = ls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segment_start_number 00000 -avoid_negative_ts 0 -break_non_key
2020-01-03 00:18:59 - vvT4Wijp -          = frames 1 -max_muxing_queue_size 1024 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/43fa6ce62f7fb6aef78e85ab5ae400ae_vvT4Wijp/s
2020-01-03 00:18:59 - vvT4Wijp -          = lice-%05d.ts
2020-01-03 00:18:59 - vvT4Wijp - PARAMQVS =
2020-01-03 00:18:59 - vvT4Wijp -          = -ss 0.000 -hwaccel qsv -vcodec hevc_qsv -noautorotate -i /volumeUSB2/usbshare/Films/VID_H265_EAC3.mkv -vcodec h264_qsv -
2020-01-03 00:18:59 - vvT4Wijp -          = vf scale_qsv=w=1920:h=960 -vsync 2 -bf 0 -vb 3183492 -acodec libmp3lame -ab 128K -ac 2 -f ssegment -segment_format mpegt
2020-01-03 00:18:59 - vvT4Wijp -          = s -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segment_start_number 00000 -avoid_
2020-01-03 00:18:59 - vvT4Wijp -          = negative_ts 0 -break_non_keyframes 1 -max_muxing_queue_size 1024 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/43fa6ce62f7fb6a
2020-01-03 00:18:59 - vvT4Wijp -          = ef78e85ab5ae400ae_vvT4Wijp/slice-%05d.ts
2020-01-03 00:18:59 - vvT4Wijp - CHILDPID = 20020
2020-01-03 00:19:04 - vvT4Wijp - STDERR   =
2020-01-03 00:19:04 - vvT4Wijp -          = [hevc_qsv @ 0xd1d800] Could not load the requested plugin '33a61c0b4c27454ca8d85dde757c6f8e': specified object was not f
2020-01-03 00:19:04 - vvT4Wijp -          = ound (-9)
2020-01-03 00:19:04 - vvT4Wijp -          = [hevc_qsv @ 0xd1d800] Error loading plugins
2020-01-03 00:19:04 - vvT4Wijp -          = [hevc_qsv @ 0xd1d800] Error initializing an MFX session
2020-01-03 00:19:04 - vvT4Wijp -          = Error while decoding stream #0:0: Function not implemented
2020-01-03 00:19:04 - vvT4Wijp -          = [hevc_qsv @ 0xd1d800] Could not load the requested plugin '33a61c0b4c27454ca8d85dde757c6f8e': specified object was not f
2020-01-03 00:19:04 - vvT4Wijp -          = ound (-9)
2020-01-03 00:19:04 - vvT4Wijp -          = [hevc_qsv @ 0xd1d800] Error loading plugins
2020-01-03 00:19:04 - vvT4Wijp -          = [hevc_qsv @ 0xd1d800] Error initializing an MFX session
2020-01-03 00:19:04 - vvT4Wijp -          = Error while decoding stream #0:0: Function not implemented
[hevc_qsv @ 0xd1d800] Could not load the requested plugin '33a61c0b4c27454ca8d85dde757c6f8e': specified object was not f/A    
2020-01-03 00:19:04 - vvT4Wijp -          = ound (-9)
2020-01-03 00:19:04 - vvT4Wijp -          = [hevc_qsv @ 0xd1d800] Error loading plugins
2020-01-03 00:19:04 - vvT4Wijp -          = [hevc_qsv @ 0xd1d800] Error initializing an MFX session
2020-01-03 00:19:04 - vvT4Wijp -          = Error while decoding stream #0:0: Function not implemented
2020-01-03 00:19:04 - vvT4Wijp -          = Too many packets buffered for output stream 0:1.
2020-01-03 00:19:04 - vvT4Wijp -          = [libmp3lame @ 0xd43ac0] 4 frames left in the queue on closing
2020-01-03 00:19:04 - vvT4Wijp -          = Conversion failed!
2020-01-03 00:19:04 - vvT4Wijp - *** CHILD END ***
2020-01-03 00:19:04 - vvT4Wijp - *** PROCESS END ***

Here is the wrapper used (Warning, you have to choose explicitly the encoder and decoder. By default it is in h265 decode mode and h264 encoding mode):
https://gist.github.com/BenjaminPoncet/4f7b635e993a8de1105a3f3bc361dea7

@kc6108
Copy link

kc6108 commented Jan 3, 2020

@BenjaminPoncet

You might try adding -load_plugin hevc_hw (or some derivative) as seen in this example:

ffmpeg -y -c:v hevc_qsv -load_plugin hevc_hw -i video-h265.mkv -an -c:v h264_qsv out.mp4

See here for more info:

https://emby.media/community/index.php?/topic/55876-quicksync-apollo-lake-windows-10-not-working-cpu-fallback/

15dd936825ad475ea34e35f3f54217a6 is the HEVC Software decoder

33a61c0b4c27454ca8d85dde757c6f8e is the HEVC hardware decoder

@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 3, 2020

And libva-utils version 2.6.0 currently fails to build without x11 support.
(interesting that I had forgotten that one specifically)

@kc6108
Copy link

kc6108 commented Jan 8, 2020

There isn’t a version 2.6. The latest is 2.4. We are at 2.1 right now. Your repo is the same:

https://github.com/th0ma7/spksrc/blob/ffmpeg-IntelQuickSync/cross/intel-vaapi-driver/digests

Your vainfo output above shows the same:

#3842 (comment)

vainfo: Driver version: Intel i965 driver for Intel(R) Broxton - 2.1.0

@kc6108
Copy link

kc6108 commented Jan 8, 2020

I thought about creating an issue to announce this to anyone wanting to get a jump on DSM 7.0:

https://event.synology.com/en-global/dsm_preview

I’ll let someone else do that if appropriate.

@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 8, 2020

I thought about creating an issue to announce this to anyone wanting to get a jump on DSM 7.0:

https://event.synology.com/en-global/dsm_preview

I’ll let someone else do that if appropriate.

Yup, I saw that last week. Thnx for sharing.

@BenjaminPoncet
Copy link

BenjaminPoncet commented Jan 8, 2020

@kc6108,

Remind me again why you want to use the i965 driver?
Of all the tests I've done the iHD driver is much better : better quality, faster.

For info, to switch from one to the other just do the following commands:

export LIBVA_DRIVER_NAME=i965
OR
export LIBVA_DRIVER_NAME=iHD

You can see the change via the verbose mode:

/var/packages/ffmpeg/target/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -i "/volumeUSB2/usbshare/Test/VID_H265_EAC3.mkv" -c:v h264_vaapi -v verbose output.mp4

@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 8, 2020

There isn’t a version 2.6. The latest is 2.4. We are at 2.1 right now. Your repo is the same:

https://github.com/th0ma7/spksrc/blob/ffmpeg-IntelQuickSync/cross/intel-vaapi-driver/digests

You are totally right! Again good catch...
I mixed-it up with libva which was updated to 2.6...
Adding the update in the new packages...

@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 8, 2020

New x64 and apollolake packages ready.
Hopefully this will fix the apparmor issue.
Also note taht VAAPI driver got updated to 2.4.
As always, feedbacks greatly appreciated
PS: I think we are now getting closer for a fully functional iHD driver...

@BenjaminPoncet
Copy link

@th0ma7, You got it!

No more apparmor problems.

Regarding CPU usage and quality tests, I did not notice any significant difference between VAAPI and QSV on a h265 10bit to h264 8bit transcoding.
The only thing is that QSV is about 15% faster on a complete stream like in VideoStation.
I took the opportunity to test the new i965 driver and there are still the same pixelization problems in the first minute and a clearly worse quality in 480p but it's maybe a bit faster than iHD.

If you want to test in VideoStation, I created a special wrapper that replaces VAAPI by QSV. I tested it only with h264 and h265 but logically it should work with everything:

wget -O - https://gist.githubusercontent.com/BenjaminPoncet/4f7b635e993a8de1105a3f3bc361dea7/raw/ffmpeg-wrapper-qsv > /var/packages/VideoStation/target/bin/ffmpeg

And to test with i965, just add the following line at the beginning of the script:

export LIBVA_DRIVER_NAME=i965

In short, for me there's nothing to stop merge anymore.

Good job !!!

@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 9, 2020

Great job on the testing you too! woot!
@kc6108 pointed me exactly where needed so it was relatively easy to fix.

BTW, @BenjaminPoncet feel free to look & follow #3828
I'm thinking that your script could be something worth using in order to automatize the replacement of videostation ffmpeg with synocommunity ffmpeg + your wrapper.

@ymartin59 it's now ready for review and merge!

@BenjaminPoncet
Copy link

@th0ma7,

Maybe one more thing!

@kc6108, again, has found the explanation for a problem with VideoStation extracting .srt subtitles via the ffmpeg SynoCommunity.
It's still an Apparmor problem but I don't know if spk can do anything about it.
For this problem, I coded a workaround in the wapper.

See: https://gist.github.com/BenjaminPoncet/bbef9edc1d0800528813e75c1669e57e#gistcomment-3131604 and my answer below.

Sorry ;)

@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 9, 2020

Yeah I read the thread, nice finding from @kc6108 , again ;)
As it is totally independant from adding qsv I have opened up a new issue #3847.

@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 16, 2020

I just finished testing several audio and video codecs and found no regressions.

This awesome news, thnx for the feedback @kc6108
New packages soon to be released to the communuity up to this pull request.

@ymartin59 ymartin59 merged commit 2f3aa0e into SynoCommunity:master Jan 18, 2020
@ymartin59
Copy link
Contributor

Well done to every contributor for this complex team effort, really impressive!

@ymartin59
Copy link
Contributor

@th0ma7 May you detail me the "x64" package split I have to apply to deliver architecture specific optimizations? What are architectures which are not specificly optimized with hardware acceleration? (I guess it is not a runtime decision but a compile-time switch, right?)
To avoid to build many packages for "non optimized", I will probably create a dedicated toolchain to produce a "x64" for ffmpeg binaries without hardware acceleration "x64-softffmpeg" for instance.
Am I correct with that idea?

@th0ma7
Copy link
Contributor Author

th0ma7 commented Jan 18, 2020

@ymartin59 this shouldn't matter... I may be wrong but my understanding is that at the end of day a call to vainfo validates all the available optimizations specific to your CPU (and there are a lot of subtilities for sub-optimization for every codecs).

Thus only what's available will work (e.g. nothing = no optimization) meaning that a non-optimized package is unecessary. Acceleration simply wont show up when calling ffmpeg -accels.

@th0ma7 th0ma7 deleted the ffmpeg-IntelQuickSync branch January 18, 2020 13:47
@ymartin59
Copy link
Contributor

@th0ma7 OK I see you have enabled all optimizations for any x64 architecture, so according to this compile directive, I may publish a single package x64. I will test in xpenology where hardware acceleration should not work.

AlexPresso pushed a commit to AlexPresso/spksrc that referenced this pull request Jan 30, 2025
* ffmpeg 4.2.1-22: add Intel Quick Sync support, VAAPI driver update, apparmor mfx driver fix
* gmmlib 19.4.1: Intel Graphics Memory Management Library
* libdrm 2.4.100: disable radeon, amdgpu and nouveau drivers
* libva 2.6: update for Intel Media driver dependency
* intel-media-driver 19.4.0r: build, install fixes, plugins.cfg
* intel-mediasdk 19.4.0: initial package, path for plugins.cfg, move lib/mfx to lib
* ffmpeg 4.2.1: fix #7030 from git.videolan.org for _qsv
* intel-vaapi-driver: update from v2.1.0 to v2.4.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement request to enhance existing package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants