darknebular / Wrapper_VideoStation

Synology VideoStation and DLNA FFmpeg Wrapper with AAC, DTS, EAC3 and TrueHD support via pipes (now with GStreamer support). It enables full hardware transcoding from Synology´s FFmpeg for video and transcoding DTS, EAC3, TrueHD and AAC from the SynoCommunity's FFmpeg only when necessary.
627 stars 70 forks source link

[New feature] Add to ffmpeg command line to enable GPU to transcoding #58

Closed alekc70 closed 2 months ago

alekc70 commented 2 months ago

Hello!

I propose adding a wrapper function that includes the necessary commands to enable GPU usage for transcoding video with FFmpeg. You can find a description https://gist.github.com/danpawlik/d1ddd34e01e19d68fdc5890f1d343b95

The reason I'm suggesting this is that it would enable hardware acceleration on the SA6400 with CPU >= Gen11 or NVIDIA/AMD graphics.

darknebular commented 2 months ago

The dnf command does not exist on Synology NAS.

The "-hwaccel vaapi" argument is already thrown and used on devices currently using a GPU in my Wrapper.

The arguments are sent directly by the Video Station, the wrapper only waits to receive those arguments and modifies them if necessary. VideoStation makes use of GPU acceleration commands when it comes to 4K or high Bitrate videos.

These arguments that make use of hardware acceleration are already covered in my Wrapper. image

Thank you for your comments

alekc70 commented 2 months ago

thank you for quick reply)

In that case a bit strange.

My system is: CPU-i5 12400 DSM 7.2 latest Model SA6400 and i915 have been installed (i've checked it) Loader: Different latest version of RR, TCRP and ARC

I've installed advanced wrapper and nevertheless I've got high CPU load.

How can I get the same output as you in order to check what params are used?

Could be any chance to enforce use gpu for videostation somehow?

without wrapper: image

with wrapper (the same): image

log from wrapper script:

Please, What option wish to use?I You have ALL necessary packages Installed, GOOD. [2024-06-11 11:52:26] INFO: ==================== Installation of the Advanced Wr apper: START ====================

[2024-06-11 11:52:26] INFO: You are running DSM 7.2.1 [2024-06-11 11:52:26] INFO: DSM 7.2.1 is supported for this installer and the in staller will tuned for your DSM [2024-06-11 11:52:26] INFO: DSM 7.2.1 is using this path: /var/packages/CodecPac k/target/pack/bin [2024-06-11 11:52:26] INFO: DSM 7.2.1 is using this injector: X-Advanced [2024-06-11 11:52:26] INFO: Backup the original ffmpeg41 as ffmpeg41.orig. [2024-06-11 11:52:26] INFO: Creating the esqueleton of the ffmpeg41 [2024-06-11 11:52:26] INFO: Injection of the ffmpeg41 wrapper using this injecto r: X-Advanced. [2024-06-11 11:52:26] INFO: Waiting for consolidate the download of the wrapper. [2024-06-11 11:52:29] INFO: Fixing permissions of the ffmpeg41 wrapper. [2024-06-11 11:52:29] INFO: Ensuring the existence of the new log file wrapper_f fmpeg and its access. [2024-06-11 11:52:29] INFO: Installed correctly the wrapper41 in /var/packages/C odecPack/target/pack/bin [2024-06-11 11:52:29] INFO: Adding of the KEY of this Wrapper in /tmp. [2024-06-11 11:52:29] INFO: Installed correctly the KEY in /tmp [2024-06-11 11:52:29] INFO: Backup the original libsynovte.so in VideoStation as libsynovte.so.orig. [2024-06-11 11:52:29] INFO: Fixing permissions of /var/packages/VideoStation/tar get/lib/libsynovte.so.orig [2024-06-11 11:52:29] INFO: Patching /var/packages/VideoStation/target/lib/libsy novte.so for compatibility with AAC, DTS, EAC3 and TrueHD [2024-06-11 11:52:29] INFO: Modified correctly the file /var/packages/VideoStati on/target/lib/libsynovte.so [2024-06-11 11:52:29] INFO: Installed correctly the Advanced Wrapper in VideoSta tion. [2024-06-11 11:52:29] INFO: Adding of the KEY of this Wrapper in DLNA MediaServe r. [2024-06-11 11:52:29] INFO: Installed correctly the KEY in /var/packages/MediaSe rver/target/bin [2024-06-11 11:52:29] INFO: Backup the original libsynovte.so in MediaServer as libsynovte.so.orig. [2024-06-11 11:52:29] INFO: Fixing permissions of /var/packages/MediaServer/targ et/lib/libsynovte.so.orig [2024-06-11 11:52:29] INFO: Patching /var/packages/MediaServer/target/lib/libsyn ovte.so for compatibility with AAC, DTS, EAC3 and TrueHD [2024-06-11 11:52:29] INFO: Modified correctly the file /var/packages/MediaServe r/target/lib/libsynovte.so [2024-06-11 11:52:29] INFO: Installed correctly the Advanced Wrapper in Media Se rver. [2024-06-11 11:52:29] INFO: Restarting CodecPack... restart package [CodecPack] successfully [2024-06-11 11:52:31] INFO: Restarting VideoStation... restart package [VideoStation] successfully [2024-06-11 11:52:34] INFO: Restarting MediaServer... restart package [MediaServer] successfully [2024-06-11 11:52:36] INFO: ==================== Installation of the Advanced Wrapper: COMPLETE ====================

alekc70 commented 2 months ago

additionally I find out https://melvin-gundlach.de/blog/files/Synology-FFmpeg-Hardware-Transcoding.html where author identified what tool is used by videostation to make hardware transcoding video.

darknebular commented 2 months ago

The sa6400 does not have a GPU as standard. The Video Station checks what version or model it is and sends or not these arguments accordingly. When you use the Wrapper, logs are recorded in /tmp/wrapper_ffmpeg.log

alekc70 commented 2 months ago

Thanks I'll check it. I found one more interesting article https://timothybasanov.com/2018/12/08/hardware-accelerated-h264-encoding-synology-nas.html

Maybe problem in propriate synology ffmpeg library which have no necessary comands inside. Would be possible to change it to one from ds920+ or another one?

gitthangbaby commented 1 month ago

Maybe problem in propriate synology ffmpeg library which have no necessary comands inside. Would be possible to change it to one from ds920+ or another one?

Great source of information posted, thanks @alekc70 . I have the same PC, same setup and GPU is not used. Since SA6400 is the dream come true, covering the Gen 11+, i have to ask, did you accomplish more?