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

Improvements and Fix wrapping procedure on non ARMv8 #10

Merged
merged 6 commits into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.idea
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ I'm working hard to fix it but in the mean time, please do not update to DSM 7.0

## Supported architectures
([check your NAS architecture here](https://github.com/SynoCommunity/spksrc/wiki/Architecture-per-Synology-model))
- ARMv8 ⚠️ (fails on DSM 7.0)
- Old ARM ⚠️ (sometimes fails on DSM 7.0)
- x64 ⚠️ (sometimes fails on DSM 7.0)
- x86 ⚠️ (sometimes fails on DSM 7.0)
- ARMv8 ⚠️ (partial support)
- Old ARM ⚠️ (partial support)
- x64
- x86

## Dependencies
- DSM 6.2.2-24922 Update 4 (and above)
Expand All @@ -27,7 +27,15 @@ I'm working hard to fix it but in the mean time, please do not update to DSM 7.0
- Install SynoCommunity ffmpeg ([help](https://synocommunity.com/#easy-install))
- Connect to your NAS using SSH (admin user required) ([help](https://www.synology.com/en-global/knowledgebase/DSM/tutorial/General_Setup/How_to_login_to_DSM_with_root_permission_via_SSH_Telnet))
- Use the command `sudo -i` to switch to root user
- Use the folowing command to execute the patch:

`curl https://raw.githubusercontent.com/AlexPresso/VideoStation-FFMPEG-Patcher/main/patcher.sh | bash`
- Use the [folowing](https://github.com/AlexPresso/VideoStation-FFMPEG-Patcher#usage) command to execute the patch
- VideoStation will have to be repatched everytime you update it (and when you update DSM)

## Usage
Basic command usage:
`curl https://raw.githubusercontent.com/AlexPresso/VideoStation-FFMPEG-Patcher/main/patcher.sh | bash`
With options:
`curl https://raw.githubusercontent.com/AlexPresso/VideoStation-FFMPEG-Patcher/main/patcher.sh | bash -s -- <option>`

| Option | Description |
| ------ | ----------- |
| -f | Force patcher to install ffmpeg-wrapper (only usefull on ARMv8 architectures if the default procedure doesn't work)
6 changes: 6 additions & 0 deletions motd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
There are currently some issues with DSM 7.0 (see repository readme).
Please let me now of any issue you could get, the more architectures the script is tested on, the more stable it will be.

ARMv8 architectures are having troubles with the dedicated patch procedures, if the first attempt fails:
- uninstall + reinstall bot VideoStation (keep library) and Advanced Media Extension
- re-run the script using the -f option (curl https://raw.githubusercontent.com/AlexPresso/VideoStation-FFMPEG-Patcher/main/patcher.sh | bash -s -- -f)
80 changes: 59 additions & 21 deletions patcher.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
#!/bin/bash

###############################
# LIFECYCLE
###############################
function welcome_motd() {
echo "[INFO] ffmpeg-patcher v1.2"

motd=$(curl -s -L "https://github.com/AlexPresso/VideoStation-FFMPEG-Patcher/blob/main/motd.txt?raw=true")
if [ "${#motd}" -ge 1 ]; then
echo "[INFO] Message of the day:"
echo ""
echo "$motd"
echo ""
fi
}

function save_and_patch() {
cp -n /var/packages/VideoStation/target/lib/libsynovte.so /var/packages/VideoStation/target/lib/libsynovte.so.orig
chown VideoStation:VideoStation /var/packages/VideoStation/target/lib/libsynovte.so.orig

sed -i -e 's/eac3/3cae/' -e 's/dts/std/' -e 's/truehd/dheurt/' /var/packages/VideoStation/target/lib/libsynovte.so
}

function restart_videostation() {
if [[ -d /var/packages/CodecPack/target/bin ]]; then
echo "[INFO] Restarting CodecPack..."
Expand All @@ -10,14 +32,17 @@ function restart_videostation() {
synopkg restart VideoStation
}

function save_and_patch() {
cp -n /var/packages/VideoStation/target/lib/libsynovte.so /var/packages/VideoStation/target/lib/libsynovte.so.orig
chown VideoStation:VideoStation /var/packages/VideoStation/target/lib/libsynovte.so.orig

sed -i -e 's/eac3/3cae/' -e 's/dts/std/' -e 's/truehd/dheurt/' /var/packages/VideoStation/target/lib/libsynovte.so
function end_patch() {
echo ""
echo "[SUCCESS] Done patching, you can now enjoy your movies ;) (please add a star to the repo if it worked for you)"
}


################################
# PATCH PROCEDURES
################################
function armv8_procedure() {
echo "[INFO] Running ARMv8 procedure"
echo "[INFO] Saving current ffmpeg as ffmpeg.orig"
mv -n /var/packages/VideoStation/target/lib/ffmpeg /var/packages/VideoStation/target/lib/ffmpeg.orig

Expand Down Expand Up @@ -54,12 +79,11 @@ function armv8_procedure() {

save_and_patch
restart_videostation

echo ""
echo "[SUCCESS] Done patching, you can now enjoy your movies ;) (please add a star to the repo if it worked for you)"
end_patch
}

function others_procedure() {
function wrapper_procedure() {
echo "[INFO] Running wrapping procedure"
echo "[INFO] Saving current ffmpeg as ffmpeg.orig"
mv -n /var/packages/VideoStation/target/bin/ffmpeg /var/packages/VideoStation/target/bin/ffmpeg.orig

Expand All @@ -71,27 +95,41 @@ function others_procedure() {
chmod u+s /var/packages/VideoStation/target/bin/ffmpeg

if [[ -d /var/packages/CodecPack/target/bin ]]; then
echo "[INFO] Detected Advanced Media Extensions"
cpackfiles=($(ls /var/packages/CodecPack/target/bin | grep ffmpeg))

echo "[INFO] Saving current Advanced Media Extensions ffmpeg33 as ffmpeg33.orig"
mv /var/packages/CodecPack/target/bin/ffmpeg33 /var/packages/CodecPack/target/bin/ffmpeg33.orig
for file in "${cpackfiles[@]}"
do
echo "[INFO] Patching CodecPack's $file..."

echo "[INFO] Copying VideoStation's ffmpeg to CodecPack ffmpeg33"
cp /var/packages/VideoStation/target/bin/ffmpeg /var/packages/CodecPack/target/bin/ffmpeg33
mv "/var/packages/CodecPack/target/bin/$file" "/var/packages/CodecPack/target/bin/$file.orig"
cp /var/packages/VideoStation/target/bin/ffmpeg "/var/packages/CodecPack/target/bin/$file"

chmod 755 /var/packages/CodecPack/target/bin/ffmpeg33
chmod 755 "/var/packages/CodecPack/target/bin/$file"
done
fi

save_and_patch
restart_videostation

echo ""
echo "[SUCCESS] Done patching, you can now enjoy your movies ;) (please add a star to the repo if it worked for you)"
end_patch
}

if [[ $(cat /proc/cpuinfo | grep 'model name' | uniq) =~ "ARMv8" ]]; then

################################
# ENTRYPOINT
################################
forcewrapper=false

while getopts "f" option
do
case $option in
f)
forcewrapper=true
;;
esac
done

if [[ $(cat /proc/cpuinfo | grep 'model name' | uniq) =~ "ARMv8" && $forcewrapper == false ]]; then
armv8_procedure
else
others_procedure
wrapper_procedure
fi