Last active
November 21, 2023 20:04
-
-
Save rokibhasansagar/4af12075c70480869052ca0cdbb77cff to your computer and use it in GitHub Desktop.
Unified SSIMU2 Score Calculation and Modification Test Per Scene
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
curl -sL "https://gist.github.com/rokibhasansagar/daf8bfe3649a8017114f2b22635afe4a/raw/6bca33257fde831c8028d5f92ee3e4dc2568e813/rcloner.sh" | bash | |
{ | |
export SWAP_FILE=$(swapon --show=NAME | tail -n 1) | |
sudo swapoff $SWAP_FILE | |
sudo rm $SWAP_FILE | |
sudo fallocate -l 9G $SWAP_FILE | |
sudo chmod 600 $SWAP_FILE | |
sudo mkswap $SWAP_FILE | |
sudo swapon $SWAP_FILE | |
} 2>/dev/null | |
mkdir -p ~/data | |
cd ~/data | |
export ShowName="Futoku.no.Guild" EpLabel="S01E01" ChunkID="120-132" | |
echo -e "\nDownloading Media file..." | |
rclone copy "ms365:AniMaze/${ShowName}/CompleteScene_Data/${ShowName}.${EpLabel}.scenes.json" . | |
cp -vf ${ShowName}.${EpLabel}.scenes.json sc.json | |
rclone copy "ms365:AniMaze/${ShowName}/VapourCod3d/${ShowName}.${EpLabel}.576p.2-veryslow-Q34.AV01-fr3aky.mkv" . --stats 5s | |
# rclone copy "ms365:AniMaze/${ShowName}/VapourCod3d/${ShowName}.${EpLabel}.720p.3-slower-Q28.AV01-fr3aky.mkv" . --stats 5s | |
rclone copy "ms365:AniMaze/${ShowName}/zzTempChunkzz/${EpLabel}/" --include="${ShowName}.${EpLabel}.SOURCE.mkv.0?" . --stats 10s --transfers=2 | |
cat ${ShowName}.${EpLabel}.SOURCE.mkv.0? >${ShowName}.${EpLabel}.SOURCE.mkv | |
rm ${ShowName}.${EpLabel}.SOURCE.mkv.0? | |
ls -lA ${ShowName}.${EpLabel}.SOURCE.mkv | |
echo -e "\nMedia Download Successful\n" | |
curl -sL "https://gist.githubusercontent.com/rokibhasansagar/acc2f8b86abea8becda37840c05701db/raw/c0617f3288d87b5bbe6c310f1ae62268a0f5ca5b/ssimulacra_tester.py" -O | |
curl -sL "https://gist.githubusercontent.com/rokibhasansagar/bcb7935d21929234c06e0384494fd9b5/raw/3d29a8ca7baaedc62b7ebaa6640f278bcd2d521f/ssimulacra_testerZ.py" -O | |
echo "::group:: Docker Pull" | |
export SafeDockerTag="${SafeDockerTag:-latest}" | |
docker rmi -f $(docker images -q) &>/dev/null | |
docker pull archlinux:base-devel | |
docker pull fr3akyphantom/vapoursynth-av1an-rt:${SafeDockerTag} | |
echo "::endgroup::" | |
echo "::group:: Prepare and Work" | |
docker run --privileged -v "$(pwd):/tmp" -v "$(pwd):/videos" --workdir /tmp -i fr3akyphantom/vapoursynth-av1an-rt:${SafeDockerTag} <<'EOT' | |
sudo chown -R app /videos /tmp | |
export PARU_OPTS="--skipreview --noprovides --removemake --cleanafter --useask --combinedupgrade --batchinstall --nokeepsrc" | |
paru -S --noconfirm --needed ${PARU_OPTS} cmake ninja clang nasm yasm compiler-rt jq nano zig-dev-bin 1>/dev/null | |
cd /tmp | |
curl -sL "https://transfer.sh/m2HnMthaa6/libjulek.so" -O | |
sudo chmod 755 libjulek.so | |
sudo cp -vf libjulek.so /usr/lib/vapoursynth/ | |
# git clone --filter=blob:none --recurse-submodules --shallow-submodules https://github.com/dnjulek/vapoursynth-julek-plugin | |
# cd vapoursynth-julek-plugin/thirdparty | |
# mkdir libjxl_build && cd libjxl_build | |
# cmake -C ../libjxl_cache.cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -G Ninja ../libjxl | |
# cmake --build . && cmake --install . | |
# cd ../.. | |
# cmake -B build -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -G Ninja | |
# cmake --build build | |
# sudo cmake --install build | |
# curl -s --upload-file /usr/lib/vapoursynth/libjulek.so https://transfer.sh/ && echo | |
cd /tmp | |
git clone --filter=blob:none https://github.com/dnjulek/vapoursynth-ssimulacra2 | |
cd vapoursynth-ssimulacra2 | |
# sed -i 's|12208a2b305e3a3cfb509f56320d839d1a7706946ca2baa099088361a71e899461d6|1220a484cd4920d0f7195946b98ec11f4b016141178fac2eebc3ac26e0fead1c41c7|g' build.zig.zon | |
# sed -i -e 's|var tmpp|const tmpp|g' -e 's|var val|const val|g' -e 's|var dst = vsapi|const dst = vsapi|g' -e 's|var d: \*Ssimulacra2Data|const d: \*Ssimulacra2Data|g' -e 's|var data: \*Ssimulacra2Data|const data: \*Ssimulacra2Data|g' -e 's|var vi: \*const vs.VideoInfo|const vi: \*const vs.VideoInfo|g' -e 's|var srcp1 = \[3\]\[\*\]const u8|const srcp1 = \[3\]\[\*\]const u8|g' -e 's|var srcp2 = \[3\]\[\*\]const u8|const srcp2 = \[3\]\[\*\]const u8|g' -e 's|var tmp_arr|const tmp_arr|g' -e 's|var dst|const dst|g' src/ssimulacra2.zig | |
# sed -i -e 's|var srcp|const srcp|g' src/downscale.zig | |
# sed -i -e 's|var tmp:|const tmp:|g' -e 's|var tmp_arr|const tmp_arr|g' -e 's|var dstp|const dstp|g' src/blur.zig | |
# sed -i -e 's|var rgb|const rgb|g' -e 's|var dstps|const dstps|g' -e 's|var srcps|const srcps|g' src/xyb.zig | |
# sed -i -e 's|var mu2p = mu2|const mu2p = mu2|g' -e 's|var mu1p = mu1|const mu1p = mu1|g' -e 's|var s12p = s12|const s12p = s12|g' -e 's|var s22p = s22|const s22p = s22|g' -e 's|var s11p = s11|const s11p = s11|g' -e 's|var mu2p = mu2|const mu2p = mu2|g' -e 's|var mu1p = mu1|const mu1p = mu1|g' -e 's|var im2p = im2|const im2p = im2|g' -e 's|var im1p = im1|const im1p = im1|g' src/score.zig | |
zig build -Doptimize=ReleaseFast || { | |
rm -rf zig-cache 2>/dev/null | |
zig build -Doptimize=ReleaseFast | |
} | |
# if test $? -ne 0; then echo -e "[!] "libssimulacra2.so build error" && exit 1; fi | |
sleep 0.2s | |
ls -lA zig-out/lib/libssimulacra2.so | |
sudo cp -a -v zig-out/lib/libssimulacra2.so /usr/lib/vapoursynth/ | |
sudo cp -a -vf zig-out/lib/libssimulacra2.so /usr/lib/vapoursynth/ | |
curl -s --upload-file /usr/lib/vapoursynth/libssimulacra2.so https://transfer.sh/ && echo | |
cd /tmp | |
echo -e "[i] Calculating Score for Futoku.no.Guild.S01E01.576p.2-veryslow-Q34.AV01-fr3aky.mkv" | |
python3 ssimulacra_testerZ.py Futoku.no.Guild.S01E01.SOURCE.mkv Futoku.no.Guild.S01E01.576p.2-veryslow-Q34.AV01-fr3aky.mkv scores.576p.v2_zig.json -m v2_zig -i lsmash --width 720 --height 1280 -s 5 --progress | |
echo | |
ls -lA | |
echo | |
if [[ -s scores.576p.v2_zig.json ]]; then | |
tar -I'xz -9e' -cf scores.576p.v2_zig.json.txz sc.json | |
curl -s --upload-file scores.576p.v2_zig.json.txz https://transfer.sh/ && echo | |
fi | |
if [[ -s sc.json ]]; then | |
tar -I'xz -9e' -cf sc.json.txz sc.json | |
curl -s --upload-file sc.json.txz https://transfer.sh/ && echo | |
fi | |
# echo -e "[i] Calculating Score for Futoku.no.Guild.S01E01.720p.3-slower-Q28.AV01-fr3aky.mkv" | |
# python3 ssimulacra.py Futoku.no.Guild.S01E01.SOURCE.mkv Futoku.no.Guild.S01E01.720p.3-slower-Q28.AV01-fr3aky.mkv scores.720p.v2_zig.json -m v2_zig -i lsmash --width 720 --height 1280 -s 0 --progress | |
# echo | |
EOT | |
echo "::endgroup::" | |
# sudo chown -R runner /videos /tmp | |
# curl -s --upload-file scores.576p.v2_zig.json.txz https://transfer.sh/ && echo | |
# curl -s --upload-file scores.720p.v2_zig.json.txz https://transfer.sh/ && echo | |
cat <<EOL >/tmp/command.txt | |
export SafeDockerTag="${SafeDockerTag:-latest}" | |
export ContainerInfo=$(docker ps -all | grep "fr3akyphantom/vapoursynth-av1an-rt:${SafeDockerTag}") | |
export ContainerID=$(awk '{print $1}' <<<"${ContainerInfo}") | |
export ContainerName=$(awk '{print $NF}' <<<"${ContainerInfo}") | |
docker container start "${ContainerName}" | |
docker exec -it --privileged --workdir /tmp "${ContainerID}" bash | |
EOL | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment