AlexPresso / VideoStation-FFMPEG-Patcher

Patcher to enable DTS, EAC3 and TrueHD transcoding support to Synology VideoStation (from DSM 6.2 to DSM 7.0 and above ; ffmpeg4, 5, 6, 7 ready)
1.06k stars 102 forks source link

[Resource] A solution that enables Synology DTS, EAC3, TrueHD formats to support hardware acceleration #53

Closed nap-liu closed 1 year ago

nap-liu commented 1 year ago

After using the patch, Synology can support direct playback of DTS, EAC3, and TrueHD format videos, but hardware acceleration cannot be enabled. I analyzed the playback process, and patched the VideoStation of DS218Play, and successfully enabled hardware acceleration. If anyone has time, please You can refer to my patch to make other platforms work normally

my fork patch diff

AlexPresso commented 1 year ago

Hi nap-liu,

Thank you for your work, I'll keep this issue open in case anyone needs it for a DS218Play. There is an openned pull request on SynoCommunity to make a GStreamer package with all plugins, compatible with every architectures: https://github.com/SynoCommunity/spksrc/pull/5298

The new wrapper (https://github.com/AlexPresso/VideoStation-FFMPEG-Patcher/pull/33) is designed to use this version and will be merged when this package will be fully available.

nap-liu commented 1 year ago

Hi nap-liu,

Thank you for your work, I'll keep this issue open in case anyone needs it for a DS218Play. There is an openned pull request on SynoCommunity to make a GStreamer package with all plugins, compatible with every architectures: SynoCommunity/spksrc#5298

The new wrapper (#33) is designed to use this version and will be merged when this package will be fully available.

I saw this pull request from the community, and tried to compile and install locally, but the compiled gst-omx did not recognize the realtek plug-ins. I tried to modify and recompile gst-omx, but some plug-ins were still not recognized.

In addition, it is because the system of Synology has turned on apparmor.

Videostation can use the community's ffmpeg because the community's ffmpeg has been pre-configured with permissions in the official apparmor configuration, but the community's gstreamer has not been configured with permissions (I guess it may be because the community does not have the gstreamer package).

Videostation cannot directly use the external gstreamer. After I turned off apparmor, although the videostation successfully called the external gstreamer.

But the gstreamer I compiled locally has only sound but no video picture.

Later, I thought it would be better to directly migrate gstreamer from other platforms to complete the missing plug-ins, and then I found the corresponding package from launchpad.

The dts plugin is libgstdtsdec.so in gstreamer1.0-plugins-bad The plug-in for truehd and eac3 is libgstlibav.so

I added the above plug-in so that the hardware acceleration can be used normally, but there is still a problem. This hardware transcoding function can only run one at the same time. I don’t know if it is only the arm platform.

findstevehere commented 1 year ago

Hey firstly thanks for all your hard work and dedication to this project. It’s really amazing what you’ve accomplished!

I have a dumb question: im tech savvy and last year I got your wrapper or whatever to install and work properly…. but havent been able to since. I’m getting so confused by all the posts and forks and whatever on github and wish I could find a simple instruction on the steps to install this. especially now since one of the depencies is another app from community but cant find it in the community. Last time I tried installing wrapper I kept getting errors and just gave up about 6 months ago….trying to catch up and hoping I can get to work. Just updated DSM and trying to read all posts and comments and updates etc…. any easy instructions for a dolt when it comes to terminal and command instructions lol? I use a mac also so some commands are different for terminal. I always find most coders assume people like me have more basics than we actually do… wish I could watch a youtube video or something,as there’s always some little step that I miss or wrong protocols used when trying to paste in the code. I have no idea what all this is about overriding AME extensions or whatever and now they[ve be updated. I just recall the sheer joy that one tIme I read in terminal that the wrapper was successfully applied, couldnt believe it… but seems those days are gone lo

any help appreciated and thanks again, you’re a superstar!

cheers

steve

On Dec 19, 2022, at 1:25 AM, AlexPresso @.***> wrote:

Hi nap-liu,

Thank you for your work, I'll keep this issue open in case anyone needs it for a DS218Play. There is an openned pull request on SynoCommunity to make a GStreamer package with all plugins, compatible with every architectures: SynoCommunity/spksrc#5298 https://github.com/SynoCommunity/spksrc/pull/5298 The new wrapper (#33 https://github.com/AlexPresso/VideoStation-FFMPEG-Patcher/pull/33) is designed to use this version and will be merged when this package will be fully available.

— Reply to this email directly, view it on GitHub https://github.com/AlexPresso/VideoStation-FFMPEG-Patcher/issues/53#issuecomment-1357348084, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWU47YEVNIMJD37RJV2G5ELWOASY5ANCNFSM6AAAAAATC6H7PU. You are receiving this because you are subscribed to this thread.

nap-liu commented 1 year ago

Hey firstly thanks for all your hard work and dedication to this project. It’s really amazing what you’ve accomplished! I have a dumb question: im tech savvy and last year I got your wrapper or whatever to install and work properly…. but havent been able to since. I’m getting so confused by all the posts and forks and whatever on github and wish I could find a simple instruction on the steps to install this. especially now since one of the depencies is another app from community but cant find it in the community. Last time I tried installing wrapper I kept getting errors and just gave up about 6 months ago….trying to catch up and hoping I can get to work. Just updated DSM and trying to read all posts and comments and updates etc…. any easy instructions for a dolt when it comes to terminal and command instructions lol? I use a mac also so some commands are different for terminal. I always find most coders assume people like me have more basics than we actually do… wish I could watch a youtube video or something,as there’s always some little step that I miss or wrong protocols used when trying to paste in the code. I have no idea what all this is about overriding AME extensions or whatever and now they[ve be updated. I just recall the sheer joy that one tIme I read in terminal that the wrapper was successfully applied, couldnt believe it… but seems those days are gone lo any help appreciated and thanks again, you’re a superstar! cheers steve On Dec 19, 2022, at 1:25 AM, AlexPresso @.***> wrote: Hi nap-liu, Thank you for your work, I'll keep this issue open in case anyone needs it for a DS218Play. There is an openned pull request on SynoCommunity to make a GStreamer package with all plugins, compatible with every architectures: SynoCommunity/spksrc#5298 <SynoCommunity/spksrc#5298> The new wrapper (#33 <#33>) is designed to use this version and will be merged when this package will be fully available. — Reply to this email directly, view it on GitHub <#53 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWU47YEVNIMJD37RJV2G5ELWOASY5ANCNFSM6AAAAAATC6H7PU. You are receiving this because you are subscribed to this thread.

Because I don't have Synology for other platforms, I don't know whether to use gstreamer for decoding on other platforms. If you use gstreamer's decoder, you can refer to my solution, but you need to manually copy the file, theoretically The above is that you can directly use the packages of other platforms. The main problem is to distinguish which platform your Synology is on.

You can check it with uname -a This is mine

Linux 4.4.59+ #25556 SMP Sat Aug 28 02:14:55 CST 2021 aarch64 GNU/Linux synology_rtd1296_ds218play

There are only a few types of system architecture, you can refer to the following relationship to find the corresponding package armhf -> armhf aarch64 -> arm64 x86 -> i386 x64 -> amd64

Migration steps

Written at the top, if the following operations are performed incorrectly, VideoStation may be unusable. It is best to save the source files before overwriting any files, so that it can be restored to the original state. If there is no way to restore, just reinstall VideoStation

  1. Check the version of the local gstreamer

    root@nap:~# /var/packages/VideoStation/target/bin/gst-launch-1.0 --version
    gst-launch-1.0 version 1.6.3
    GStreamer 1.6.3
    Unknown package origin
  2. Find the package with the smallest version difference on launchpad. The version can be lower than the current installed version, but it cannot be higher than the current version https://launchpad.net/+search?field.text=gstreamer-plugins-bad+1.6+arm64&field.actions.search=Search

  3. Find the corresponding package and download it. Take gstreamer-plugins-bad as an example package found https://code.launchpad.net/ubuntu/xenial/arm64/gstreamer1.0-plugins-bad/1.6.0-1ubuntu1 Then manually download the compiled deb package http://launchpadlibrarian.net/220569823/gstreamer1.0-plugins-bad_1.6.0-1ubuntu1_arm64.deb

  4. Unzip the deb file and copy the libgstdtsdec.so file in the lib directory Normally, you need to copy all the files in the lib directory, but here only one libgstdtsdec.so is needed, because dts decoding only needs this plug-in Copy this plugin to the /var/packages/VideoStation/target/lib/gstreamer/gstreamer-1.0/ directory, which is the plugin directory of gstreamer

  5. Check if the plugin can load At this time, an error will be reported, indicating that libdca.so.0 is missing

    root@nap:~# /var/packages/VideoStation/target/bin/gst-inspect-1.0 /var/packages/VideoStation/target/lib/gstreamer/gstreamer-1.0/libgstdtsdec.so
    (gst-inspect-1.0:15787): GStreamer-WARNING **: Failed to load plugin '/var/packages/VideoStation/target/lib/gstreamer/gstreamer-1.0/libgstdtsdec.so': libdca.so.0: cannot open shared object file: No such file or directory
    Could not load plugin file: Opening module failed: libdca.so.0: cannot open shared object file: No such file or directory

    At this time, go to the package page to view the dependency packages of Package relationships and find the corresponding dependencies There are two dependencies of libgstdtsdec.so (these two packages are tested one at a time) liborc-0.4-0 (>= 1:0.4.23) and libdca0 are both in the list of dependent packages Click directly on the link to download the package https://code.launchpad.net/ubuntu/wily/arm64/liborc-0.4-0/1:0.4.24-1 https://code.launchpad.net/ubuntu/wily/arm64/libdca0/0.0.5-7build1 After decompressing the downloaded package, put the files in lib in the following directory /var/packages/VideoStation/target/lib/gstreamer/ Note that this directory is not the same directory as the plugin

  6. After completing the plug-in and lib package, check again whether the plug-in can be loaded

    
    root@nap:~# /var/packages/VideoStation/target/bin/gst-inspect-1.0 /var/packages/VideoStation/target/lib/gstreamer/gstreamer-1.0/libgstdtsdec.so

Plugin Details: Name dtsdec Description Decodes DTS audio streams Filename /var/packages/VideoStation/target/lib/gstreamer/gstreamer-1.0/libgstdtsdec.so Version 1.6.0 License GPL Source module gst-plugins-bad Source release date 2015-09-25 Binary package GStreamer Bad Plugins (Ubuntu) Origin URL https://launchpad.net/distros/ubuntu/+source/gst-plugins-bad1.0

dtsdec: DTS audio decoder

1 features: +-- 1 elements


Seeing this output means that your porting is successful, and now your gstreamer already supports dts

7. After the above steps, you have completed the transplantation of dts. Another bad news is that truehd and eac3 are ffmpeg plug-ins, that is, gst-libav. But if you are patient, you can manually transplant them one by one. When all the transplants are successful, your gstreamer will be able to play dts, truehd, eac3 videos normally.

8. Enable H.265 support 
Copy `/var/packages/CodecPack/target/etc/gstomx.conf` to `/var/packages/VideoStation/target/etc/gstomx.conf`
Because there is an additional h.265 support in gstomx.conf in CodecPack
If you don't do this step, there is no way to enable h.265
Check support
```shell
root@nap:~# /var/packages/VideoStation/target/bin/gst-inspect-1.0 | grep -E 'dts|eac3|truehd|h265'
omx: omxh265dec: OpenMAX H.265 Video Decoder
typefindfunctions: audio/x-ac3: ac3, eac3
typefindfunctions: audio/x-dts: dts
typefindfunctions: video/x-h265: h265, x265, 265
typefindfunctions: audio/aac: aac, adts, adif, loas
libav: avenc_eac3: libav ATSC A/52 E-AC-3 encoder
libav: avdec_eac3: libav ATSC A/52B (AC-3, E-AC-3) decoder
libav: avdec_truehd: libav TrueHD decoder
libav: avdec_h265: libav HEVC (High Efficiency Video Coding) decoder
libav: avmux_adts: libav ADTS AAC (Advanced Audio Coding) muxer (not recommended, use aacparse instead)
videoparsers bad: h265parse: H.265 parser
dtsdec: dtsdec: DTS audio decoder

dtsdec: dtsdec: DTS audio decoder is the dts plug-in just transplanted omx:omxh265dec:OpenMAX H.265 Video Decoder is h.265 enabled libav: avdec_eac3: libav ATSC A/52B (AC-3, E-AC-3) decoder requires manual porting of gst-libav libav: avdec_truehd: libav TrueHD decoder Same as above

  1. Make gstreamer support dts\truehd\eac3\h.265 through the above steps, but if you want to make VideoStation work normally, you need to point CodecPack’s gst-launch-1.0 and gst-inspect-1.0 to VideoStation
ln -s /var/packages/VideoStation/target/bin/gst-launch-1.0 /var/packages/CodecPack/target/bin/gst-launch-1.0
ln -s /var/packages/VideoStation/target/bin/gst-inspect-1.0 /var/packages/CodecPack/target/bin/gst-inspect-1.0

Written at the end, the above process was also figured out by me bit by bit. This method is not a good method, but it does solve my problem. Manual porting of lib packages is a very stupid behavior, because manual porting is very easy If an error occurs, a wrong lib will cause it to fail to run. In fact, you can write a script to automatically download all dependencies, but I didn't write it (a bit lazy). I hope someone can write a tool that automatically downloads dependencies

findstevehere commented 1 year ago

Oh hey Alex, where do I get onto the comment section to post my experience? Thanks again and I love being in this thread. It's weird I can play everything perfectly when I'm on the computer and using DS video to check out DTS and True HD and they pop up in another tab in the browser and play without a problem. But using the app sometimes now, even I think I've turned off hardware acceleration and third party playing is off and while initially it seemed like everything played natively. Now suddenly, it seems like more often than not. It's being played by the backup player such as VLC or MX player, so that's interesting.

On Sun, Dec 18, 2022, 9:02 p.m. nap.liu @.***> wrote:

After using the patch, Synology can support direct playback of DTS, EAC3, and TrueHD format videos, but hardware acceleration cannot be enabled. I analyzed the playback process, and patched the VideoStation of DS218Play, and successfully enabled hardware acceleration. If anyone has time, please You can refer to my patch to make other platforms work normally

my fork https://github.com/nap-liu/VideoStation-FFMPEG-Patcher/tree/rtd1296-ds6.2.4 patch diff https://github.com/AlexPresso/VideoStation-FFMPEG-Patcher/compare/main...nap-liu:VideoStation-FFMPEG-Patcher:rtd1296-ds6.2.4

— Reply to this email directly, view it on GitHub https://github.com/AlexPresso/VideoStation-FFMPEG-Patcher/issues/53, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWU47YCGH5GLCEYP2FLPBUTWN7T4VANCNFSM6AAAAAATC6H7PU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

AlexPresso commented 1 year ago

Hey @nap-liu Thank you very much for your work, I just added your work to the patcher and creditted you in the readme