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

ffmpeg 4.4.3 missing permission to /dev/dri/renderD128 and video files #66

Closed To-Azamat closed 1 year ago

To-Azamat commented 1 year ago

Did fresh install:

  1. VideoStation - working
  2. VideoStation + ffmpeg - working
  3. VideoStation + ffmpeg + patch - NOT working
  4. After Unpatch - working

System details

Describe the bug Any video just wont play at all after the patch

AlexPresso commented 1 year ago

Hello, please provide required log files, the procedure is explained in the issue template

To-Azamat commented 1 year ago

It says:

But the video never starts to play. Still follow logs steps?

I forgot to mention: I had previous version of ffmpeg installed, patched and working fine. VS stopped working after update to 4.4.3

AlexPresso commented 1 year ago

Yes, even if you have the red circle (loading), please follow the steps this is the only way I can try to help you

To-Azamat commented 1 year ago

ffmpeg.log

https://gist.github.com/To-Azamat/cfb64c3338d63c0435d88b9935dfe4eb

ffmpeg-FFMxxxx.stderr (containing chunks transcoding operations)

File is not there

AlexPresso commented 1 year ago

Okay, my bad, it's because the wrapper deletes the file when there is an error, I will fix it and tell you when you can uninstall and reinstall the wrapper

AlexPresso commented 1 year ago

You can now run the two following commands:

The first one will uninstall the old wrapper and the second one will install the latest wrapper

Then please retry your video and send me the logs of ffmpeg.log

To-Azamat commented 1 year ago

https://gist.github.com/To-Azamat/9ef3677d236ffdc494c28ffd2b20be3b

AlexPresso commented 1 year ago

Can you give me the output of the following commands please :

To-Azamat commented 1 year ago

_ffmpeg -hidebanner -hwaccels It is "-hwaccel" probably? admin@DiskStation916:$ ffmpeg -hide_banner -hwaccels Unrecognized option 'hwaccels'. Error splitting the argument list: Option not found admin@DiskStation916: ffmpeg -hide_banner -hwaccel Missing argument for option 'hwaccel'. Error splitting the argument list: Invalid argument

sudo su -s /bin/bash sc-ffmpeg -c '/var/packages/ffmpeg/target/bin/vainfo' admin@DiskStation916:~$ sudo su -s /bin/bash sc-ffmpeg -c '/var/packages/ffmpeg/target/bin/vainfo' Trying display: drm error: failed to initialize display

AlexPresso commented 1 year ago

Hello, Can you run and give me the output of the following command please: ls -al /dev/dri

Could you also try to run the following command (as root user) and then play a video on VideoStation : chmod 777 /dev/dri/renderD128

This will make everything able to access this renderer. It's a bit dirty so you can just restart your NAS after, to reset the default permission. This is just a test to see if it's a ffmpeg permission problem.

To-Azamat commented 1 year ago

Do I need to run those in patched environment? cause I unpatched after last batch of tests

AlexPresso commented 1 year ago

Yes, you need to try on a patched version of VideoStation, because this is the one not working :)

To-Azamat commented 1 year ago

ls -al /dev/dri root@DiskStation916:~# ls -al /dev/dri total 0 drwxr-xr-x 2 root root 100 Sep 17 2022 . drwxr-xr-x 14 root root 19020 Mar 13 15:15 .. crw------- 1 root root 226, 0 Sep 17 2022 card0 crw------- 1 root root 226, 64 Sep 17 2022 controlD64 crw------- 1 root root 226, 128 Sep 17 2022 renderD128

To-Azamat commented 1 year ago

Nope, after chmod same error in ffmpeg.log

root@DiskStation916:/tmp# tail -200 ffmpeg.log

[2023-04-21 19:37:39] [INFO] ========================================[start ffmpeg 12418] [2023-04-21 19:37:39] [INFO] DEFAULT_ARGS: -ss 0.000 -i /volume3/Anime/Angel Beats/Angel Beats! - 01.mkv -threads 0 -vcodec copy -vsync 2 -vbsf h264_mp4toannexb=repeatheader -acodec libmp3lame -ab 256k -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 8 -segment_time_delta 0.000 -segment_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 0 -max_muxing_queue_size 1024 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/12ca3f2e242f0707e7b53826eec98c2d_N2mI58X9/slice-%05d.ts [2023-04-21 19:37:40] [ERROR] An error occurred, here is the /tmp/ffmpeg-12418.stderr content:

ffmpeg version 4.4.3-48 Copyright (c) 2000-2022 the FFmpeg developers built with gcc 4.9.3 (crosstool-NG 1.20.0) 20150311 (prerelease) configuration: --target-os=linux --cross-prefix=/home/spksrc/master/spksrc/toolchain/syno-x64-6.1/work/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu- --prefix=/var/packages/ffmpeg/target --extra-cflags=-I/home/spksrc/master/spksrc/spk/ffmpeg4/work-x64-6.1/install/var/packages/ffmpeg/target/include --extra-ldflags=-L/home/spksrc/master/spksrc/spk/ffmpeg4/work-x64-6.1/install/var/packages/ffmpeg/target/lib --extra-libs='-lxml2 -ldl -lm' --pkg-config=/usr/bin/pkg-config --ranlib=/home/spksrc/master/spksrc/toolchain/syno-x64-6.1/work/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-ranlib --enable-cross-compile --enable-rpath --enable-pic --enable-shared --enable-gpl --enable-version3 --enable-avresample --disable-debug --disable-static --disable-doc --extra-version=48 --extra-cflags=-DSYNO_VIDEOSTATION --extra-cflags=-fno-if-conversion --extra-cflags=-O3 --extra-cflags=-Wno-deprecated-declarations --x86asmexe=nasm --enable-libcodec2 --enable-libxml2 --enable-demuxer=dash --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libopenjpeg --enable-libmp3lame --enable-libbluray --enable-libspeex --enable-libtheora --enable-libcaca --enable-libdc1394 --enable-libvorbis --enable-libwebp --enable-libzmq --enable-gnutls --enable-libopenh264 --enable-libopus --enable-libsoxr --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librabbitmq --enable-libtwolame --enable-libzvbi --enable-libx264 --enable-libx265 --enable-libvpx --enable-libshine --enable-chromaprint --enable-libdav1d --enable-librist --enable-libzimg --enable-libfdk-aac --enable-nonfree --enable-libaom --enable-libsvtav1 --enable-libsvthevc --arch=x86_64 --enable-vaapi --enable-libmfx --enable-libdrm --enable-libass libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 /volume3/Anime/Angel Beats/Angel Beats! - 01.mkv: Permission denied

[2023-04-21 19:37:40] [INFO] ========================================[end ffmpeg 12418]

AlexPresso commented 1 year ago

This is not the same error :)

At first it was :

[AVHWDeviceContext @ 0x1002cc0] No VA display found for device /dev/dri/renderD128.
Device creation failed: -22.
Failed to set value '/dev/dri/renderD128' for option 'vaapi_device': Invalid argument

Now it's: /volume3/Anime/Angel Beats/Angel Beats! - 01.mkv: Permission denied

Hi @th0ma7, for the first error I think the SynoCommunity's ffmpeg (4.4.3) package is missing some permissions to access the /dev/dri/renderD128. I'm not very familliar with apparmor, but is there anything we can do to give it acess ? [Edit:] Or maybe the ffmpeg group on this NAS is missing some permissions everywhere ?

@To-Azamat Please give me the output of the following command: ls -al /volume3/Anime/Angel Beats | grep 01.mkv

To-Azamat commented 1 year ago

Hmmm this command ls -al /volume3/Anime/Angel Beats | grep 01.mkv

does not make sense ) What do you wanna see?

File is /volume3/Anime/Angel Beats/Angel Beats! - 01.mkv

AlexPresso commented 1 year ago

Hmmm this command ls -al /volume3/Anime/Angel Beats | grep 01.mkv does not make sense ) What do you wanna see?

I want to see the owner and read permissions of the mkv file you're trying to play

File is /volume3/Anime/Angel Beats/Angel Beats! - 01.mkv

I know, the grep 01.mkv is limiting result only to this file

To-Azamat commented 1 year ago

root@DiskStation916:/tmp# ls -al "/volume3/Anime/Angel Beats" | grep 01.mkv -rwxr-x---+ 1 admin users 1790628823 Nov 14 2011 Angel Beats! - 01.mkv

To-Azamat commented 1 year ago

I do not know if it matters or not, but before I updated to ffmpeg 4.4.3 I had an older version of ffmpeg installed, patched and working fine for a long time. So if I were to guess, there is smth with ffmpeg updated package

AlexPresso commented 1 year ago

This seems to be a permission issue, but I cannot tell you if it's related to the ffmpeg update or because you're running on an old DSM version. Let's wait for @th0ma7 to check it out :)

th0ma7 commented 1 year ago

Is is possible for you to provide output from the following commands (the last one using sudo will prompt for your password):

$ uname -a
$ cat /proc/cpuinfo | grep "model name"
$ cat /etc/VERSION
$ id
$ grep videodriver /etc/group
$ ll /var/packages/ffmpeg/target/bin/vainfo
$ /var/packages/ffmpeg/target/bin/vainfo
$ sudo su -s /bin/bash sc-ffmpeg -c '/var/packages/ffmpeg/target/bin/vainfo'
To-Azamat commented 1 year ago

admin@DiskStation916:~$ uname -a Linux DiskStation916 3.10.105 #25556 SMP Sat Aug 28 02:13:34 CST 2021 x86_64 GNU/Linux synology_braswell_916+

admin@DiskStation916:~$ cat /proc/cpuinfo | grep "model name" model name : Intel(R) Pentium(R) CPU N3710 @ 1.60GHz model name : Intel(R) Pentium(R) CPU N3710 @ 1.60GHz model name : Intel(R) Pentium(R) CPU N3710 @ 1.60GHz model name : Intel(R) Pentium(R) CPU N3710 @ 1.60GHz

admin@DiskStation916:~$ cat /etc/VERSION majorversion="6" minorversion="2" major="6" minor="2" micro="4" productversion="6.2.4" buildphase="GM" buildnumber="25556" smallfixnumber="6" nano="0" base="25556" builddate="2022/05/13" buildtime="14:40:29"

admin@DiskStation916:~$ id uid=1024(admin) gid=100(users) groups=100(users),101(administrators)

admin@DiskStation916:~$ grep videodriver /etc/group [nothing]

admin@DiskStation916:~$ ll /var/packages/ffmpeg/target/bin/vainfo -rwsr-xr-x 1 sc-ffmpeg ffmpeg 19920 Mar 29 06:14 /var/packages/ffmpeg/target/bin/vainfo

admin@DiskStation916:~$ /var/packages/ffmpeg/target/bin/vainfo Trying display: drm libva info: VA-API version 1.17.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_17 libva info: va_openDriver() returns 0 vainfo: VA-API version: 1.17 (libva 2.17.1) vainfo: Driver version: Intel i965 driver for Intel(R) CherryView - 2.4.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

admin@DiskStation916:~$ sudo su -s /bin/bash sc-ffmpeg -c '/var/packages/ffmpeg/target/bin/vainfo' Password: Sorry, try again. Password: Trying display: drm libva info: VA-API version 1.17.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_17 libva info: va_openDriver() returns 0 vainfo: VA-API version: 1.17 (libva 2.17.1) vainfo: Driver version: Intel i965 driver for Intel(R) CherryView - 2.4.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

th0ma7 commented 1 year ago

@To-Azamat would you mind testing out packages generated by github-action at https://github.com/SynoCommunity/spksrc/actions/runs/4870614890?pr=5711

If confirmed OK I'll then be ready to publish online to SynoCommunity repository. Thnx in advance.

To-Azamat commented 1 year ago

@th0ma7 I installed ffmpeg 4 package only and it seems VS is working now.

th0ma7 commented 1 year ago

Excellent 👍. I'll be publishing shortly then.

AlexPresso commented 1 year ago

Ffmpeg patch has been deployed and fixes the issue, feel free to re-open the issue if the problem is not fixed :)