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

[BUG] thumbnails are empty #40

Closed Subtixx closed 1 year ago

Subtixx commented 2 years ago

System details

Describe the bug I'm really embarrassed to open a new bug report right away. But after switching to your ffmpeg and adding the files for ther workaround of #39 I do not receive any thumbnails anymore. It says: Error while opening decoder for input stream #0:0 : Operation not permitted

Provide Log files

ffmpeg.log (containing the ffmpeg-wrapper execution logs)

https://gist.github.com/Subtixx/bd1eebf65d303992d4ea1a066236fbe8

AlexPresso commented 2 years ago

Do you mean you executed the patcher from the pull request I linked in the other issue ? Actually don't do it for now, it's a Work In Progress and not working at all for now.

Subtixx commented 2 years ago

No no. I used the master of this repository.

Before I patched my ffmpeg using the script in the repository thumbnails were generated. Now after executing the patch using curl https://raw.githubusercontent.com/AlexPresso/VideoStation-FFMPEG-Patcher/main/patcher.sh | bash it does not generate thumbnails for videos anymore.

AlexPresso commented 2 years ago

You mean it doesn't recover the video infos from from TMDb and other providers ?

Subtixx commented 2 years ago

Usually video station will generate a thumbnail in the eaDir folder using ffmpeg (a one frame image from the video). But after applying the patch from this repository the thumbnails that are generated are all 0kb and have no data in it.

EDIT: Manually executing the following bash script inside the folder works however:

#!/bin/bash
for f in *.mp4
do
  echo "Processing $f file..."
  /var/packages/ffmpeg/target/bin/ffmpeg -i "$f" -s 400x222 -qscale:v 4 -frames:v 1 "@eaDir/$f/SYNOVIDEO_VIDEO_SCREENSHOT.jpg" >/dev/null
done
AlexPresso commented 2 years ago

Hi Subtixx, The new wrapper may fix this issue, if you want to give it a try you can use the following commands:

Subtixx commented 2 years ago

First I had to use the following:

curl https://raw.githubusercontent.com/AlexPresso/VideoStation-FFMPEG-Patcher/main/patcher.sh | sudo bash -s -- -a unpatch curl https://raw.githubusercontent.com/AlexPresso/VideoStation-FFMPEG-Patcher/main/patcher.sh | sudo bash -s -- -b new_wrapper

else I would get "permission denied" on alot of the commands.

And now I get just those errors:

[2022-06-04 21:51:29] [INFO] ========================================[start ffmpeg 24753]
[2022-06-04 21:51:29] [INFO] DEFAULT_ARGS: -timelimit 20 -an -ss 5 -i /volume1/Videos/blubb.mp4 -vframes 1 -vf scale=size=hd480:force_original_aspect_ratio=decrease -f mjpeg -y /volume1/Videos/@eaDir/blubb.mp4/SYNOVIDEO_TEMP.jpg
[2022-06-04 21:51:29] [ERROR] Error on line 48 /var/packages/VideoStation/target/bin/ffmpeg
[2022-06-04 21:51:29] [INFO] ========================================[end ffmpeg 24753]

[2022-06-04 21:51:29] [INFO] ========================================[start ffmpeg 24764]
[2022-06-04 21:51:29] [INFO] DEFAULT_ARGS: -timelimit 60 -an -i /volume1/Videos/blubb.mp4 -ss 5 -vframes 1 -vf scale=size=hd480:force_original_aspect_ratio=decrease -f mjpeg -y /volume1/Videos/@eaDir/blubb.mp4/SYNOVIDEO_TEMP.jpg
[2022-06-04 21:51:29] [ERROR] Error on line 48 /var/packages/VideoStation/target/bin/ffmpeg
[2022-06-04 21:51:29] [INFO] ========================================[end ffmpeg 24764]

[2022-06-04 21:51:29] [INFO] ========================================[start ffmpeg 24774]
[2022-06-04 21:51:29] [INFO] DEFAULT_ARGS: -timelimit 240 -an -i /volume1/Videos/blubb.mp4 -ss 3 -vframes 1 -vf scale=size=hd480:force_original_aspect_ratio=decrease -f mjpeg -y /volume1/Videos/@eaDir/blubb.mp4/SYNOVIDEO_TEMP.jpg
[2022-06-04 21:51:29] [ERROR] Error on line 48 /var/packages/VideoStation/target/bin/ffmpeg
[2022-06-04 21:51:29] [INFO] ========================================[end ffmpeg 24774]

and the file /var/packages/VideoStation/target/bin/ffmpeg is 1 kb

EDIT: Again executing sudo /var/packages/VideoStation/target/bin/ffmpeg -timelimit 240 -an -i /volume1/Videos/blubb.mp4 -ss 3 -vframes 1 -vf scale=size=hd480:force_original_aspect_ratio=decrease -f mjpeg -y /volume1/Videos/@eaDir/blubb.mp4/SYNOVIDEO_TEMP.jpg using putty works and creates an image..

AlexPresso commented 2 years ago

Have you runned the script using root user /sudo ? It would be really helpfull if you could give me the execution logs of the patcher :)

AlexPresso commented 2 years ago

The new wrapper directly pass the VideoStation args to the SynoCommunity ffmpeg. The patch isn't editing anything related to the eaDir, I also cannot reproduce the issue, my VideoStation (without patch) never generates an eaDir

Subtixx commented 2 years ago

The @ eaDir is only visible using WinSCP / SCP, it does not show up in SMB nor in filestation. The directory contains all thumbnails / covers that VideoStation uses and generates from the video by default (the little images you see in the list of the videos), the eaDir exists in every indexed path of Videostation and every subfolder.

Output of the patcher:

[2022-06-05 09:22:37] [INFO] ffmpeg-patcher v1.5
[2022-06-05 09:22:37] [Message of the day]

The patcher was redesigned to include an unpatch procedure.

I'm aware of an issue with HEVC and I'm working on it.

As always, please let me know of any issue you could have.

[2022-06-05 09:22:38] [INFO] You're running DSM 6.2
[2022-06-05 09:22:38] [INFO] ====== Patching procedure (branch: new_wrapper) ======
[2022-06-05 09:22:38] [INFO] Saving current ffmpeg as ffmpeg.orig
[2022-06-05 09:22:38] [INFO] Downloading ffmpeg's wrapper...
[2022-06-05 09:22:38] [INFO] Saving current libsynovte.so as libsynovte.so.orig
[2022-06-05 09:22:38] [INFO] Enabling eac3, dts and truehd
[2022-06-05 09:22:38] [INFO] Restarting VideoStation...
package VideoStation restart successfully

[2022-06-05 09:22:42] [INFO] Done patching, you can now enjoy your movies ;) (please add a star to the repo if it worked for you)

About the root user /sudo part. Yes I added sudo before the bash command.

EDIT:

I have modified the script to output $@ aswell (I have no idea about bash and if this is correct):

Like so:

info "========================================[start ffmpeg $pid]"
info "DEFAULT_ARGS: $*"
info "ARGS: $@"

/var/packages/ffmpeg/target/bin/ffmpeg "$@" 2> $stderrfile

And it outputs the following:

[2022-06-05 09:31:24] [INFO] ========================================[start ffmpeg 11760]
[2022-06-05 09:31:24] [INFO] DEFAULT_ARGS: -timelimit 240 -an -i /volume1/Videos/blubb-1.mp4 -ss 3 -vframes 1 -vf scale=size=hd480:force_original_aspect_ratio=decrease -f mjpeg -y /volume1/Videos/@eaDir/blubb-1.mp4/SYNOVIDEO_TEMP.jpg
[2022-06-05 09:31:24] [INFO] ARGS: -timelimit
[2022-06-05 09:31:24] [ERROR] Error on line 49 /var/packages/VideoStation/target/bin/ffmpeg
[2022-06-05 09:31:24] [INFO] ========================================[end ffmpeg 11760]

EDIT2:

Removing the line to remove the error pid file I found the following: /var/packages/VideoStation/target/bin/ffmpeg: line 50: /var/packages/ffmpeg/target/bin/ffmpeg: Permission denied

AlexPresso commented 2 years ago

All the args are already printed, it's the DEFAULT_ARGS (args are never modified) logs entry. Using $@ is a reference to the args array itself, when trying to print it, it will bug and only print the first array index. If you want to convert the whole array to a string, you need to use $*

AlexPresso commented 2 years ago

I just noticed you're running on an old VideoStation version, they may have changed the behavior of @eaDir because the video thumbnails are working fine (both Movies and Series episodes) on the latest version.

Still, it's a strange behavior, because the patch is not editing that part at all and I remember having them working fine before I upgraded to the latest version of DSM + VideoStation.

In your case the issue seems to be that VideoStation (when calling patched ffmpeg) doesn't have enough permissions to write/access @eaDir, what are your current @eaDir permissions ? By default, mine is having 777:

  File: @eaDir
  Size: 40960           Blocks: 88         IO Block: 4096   directory
Device: fa00h/64000d    Inode: 242089991   Links: 363
Access: (0777/drwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Subtixx commented 2 years ago

I cannot explain why the VideoStation should be an old version, I pretty much use the latest available in Package Manager: grafik

Either way permissions on my @eaDir is 0777: grafik

Permissions on /var/packages/ffmpeg/target/bin/ffmpeg: grafik

EDIT: But I can say when I switch back to the original unpatched version, thumbnails work fine

AlexPresso commented 2 years ago

It's the latest available for your DSM version, but updating to DSM 7.1 allows you to update VideoStation to 3.0.3

AlexPresso commented 2 years ago

Could you provide me these files please, so I can compare them before and after the patch:

If you want, you can copy them to the /volume1/homes/<your user> and download them using FileStation

Subtixx commented 2 years ago

Sure can: libsynovte.zip

It's the latest available for your DSM version, but updating to DSM 7.1 allows you to update VideoStation to 3.0.3

Yea do not want to update to a newer DSM. Do not update if it aint broken

AlexPresso commented 2 years ago

Hey there,

Sorry for the delay. It may be an issue with the old VideoStation because I cannot reproduce the issue and the only differences between the two files are for the patched codec names:

diff -u <(xxd libsynovte.so) <(xxd libsynovte.so.orig) | nano -

--- /dev/fd/63  2022-10-31 21:35:50.931184807 +0100
+++ /dev/fd/62  2022-10-31 21:35:50.927184805 +0100
@@ -19799,7 +19799,7 @@
 0004d560: 3d00 266d 6574 686f 643d 0026 5f73 6964  =.&method=.&_sid
 0004d570: 3d00 2653 796e 6f54 6f6b 656e 3d00 6175  =.&SynoToken=.au
 0004d580: 6469 6f5f 666f 726d 6174 0061 6333 5f63  dio_format.ac3_c
-0004d590: 6f70 7900 3363 6165 0079 7576 3432 3070  opy.3cae.yuv420p
+0004d590: 6f70 7900 6561 6333 0079 7576 3432 3070  opy.eac3.yuv420p
 0004d5a0: 002d 7069 785f 666d 7400 2d73 6567 6d65  .-pix_fmt.-segme
 0004d5b0: 6e74 5f66 6f72 6d61 7400 6d70 6567 7473  nt_format.mpegts
 0004d5c0: 002d 7365 676d 656e 745f 6c69 7374 5f74  .-segment_list_t
@@ -20364,7 +20364,7 @@
 0004f8b0: 4b53 7436 7665 6374 6f72 4953 7353 6149  KSt6vectorISsSaI
 0004f8c0: 5373 4545 524b 5373 4555 6c76 455f 006c  SsEERKSsEUlvE_.l
 0004f8d0: 6962 6661 6163 006c 6962 6d70 336c 616d  ibfaac.libmp3lam
-0004f8e0: 6500 7374 6400 6468 6575 7274 006d 7065  e.std.dheurt.mpe
+0004f8e0: 6500 6474 7300 7472 7565 6864 006d 7065  e.dts.truehd.mpe
 0004f8f0: 6734 0068 3236 3400 6d70 6567 3276 6964  g4.h264.mpeg2vid
 0004f900: 656f 0076 6331 0077 6d76 3300 7276 3430  eo.vc1.wmv3.rv40
 0004f910: 0068 6576 6300 4449 5658 0048 6967 6820  .hevc.DIVX.High

Would you be ok with updating to the latest DSM version ?

AlexPresso commented 1 year ago

I'll close this issue, feel free to reopen it if you need to.