From 9ba0c87bc79ab4598366ee3fd12b07cedda86cda Mon Sep 17 00:00:00 2001 From: "(Holloway) Chew, Kean Ho" Date: Sun, 11 Feb 2024 14:55:36 +0800 Subject: [PATCH] init: added single video editing codes layout Since we already supported video upscaling, we can proceed to develop its codes layout. Hence, let's setup its layout with placeholding functions. This patch adds single video editing codes layout in init/ directory. Co-authored-by: Shuralyov, Jean Co-authored-by: Galyna, Cory Co-authored-by: (Holloway) Chew, Kean Ho Signed-off-by: (Holloway) Chew, Kean Ho --- .github/workflows/git-push.yml | 4 + init/services/compilers/ffmpeg.ps1 | 72 ++++++ init/services/compilers/ffmpeg.sh | 80 +++++++ init/services/compilers/upscaler.ps1 | 123 ++++++++++- init/services/compilers/upscaler.sh | 117 ++++++++++ init/services/i18n/error-ffmpeg-dissect.ps1 | 50 +++++ init/services/i18n/error-ffmpeg-dissect.sh | 51 +++++ .../i18n/error-ffmpeg-unavailable.ps1 | 49 +++++ .../services/i18n/error-ffmpeg-unavailable.sh | 51 +++++ init/services/i18n/error-video-setup.ps1 | 50 +++++ init/services/i18n/error-video-setup.sh | 52 +++++ init/services/i18n/error-video-upscale.ps1 | 50 +++++ init/services/i18n/error-video-upscale.sh | 52 +++++ init/start.ps1 | 57 +++++ init/start.sh | 59 +++++ tests/02_test_upscale_video_single.sh.ps1 | 206 ++++++++++++++++++ 16 files changed, 1122 insertions(+), 1 deletion(-) create mode 100644 init/services/compilers/ffmpeg.ps1 create mode 100644 init/services/compilers/ffmpeg.sh create mode 100644 init/services/i18n/error-ffmpeg-dissect.ps1 create mode 100644 init/services/i18n/error-ffmpeg-dissect.sh create mode 100644 init/services/i18n/error-ffmpeg-unavailable.ps1 create mode 100644 init/services/i18n/error-ffmpeg-unavailable.sh create mode 100644 init/services/i18n/error-video-setup.ps1 create mode 100644 init/services/i18n/error-video-setup.sh create mode 100644 init/services/i18n/error-video-upscale.ps1 create mode 100644 init/services/i18n/error-video-upscale.sh create mode 100755 tests/02_test_upscale_video_single.sh.ps1 diff --git a/.github/workflows/git-push.yml b/.github/workflows/git-push.yml index 71bd738..cbf2cc4 100644 --- a/.github/workflows/git-push.yml +++ b/.github/workflows/git-push.yml @@ -37,3 +37,7 @@ jobs: id: upscaler_image_unscale_single run: | ./tests/01_test_upscale_image_single.sh.ps1 + - name: Execute Upscaler's Single Video Upscale + id: upscaler_video_unscale_single + run: | + ./tests/02_test_upscale_video_single.sh.ps1 diff --git a/init/services/compilers/ffmpeg.ps1 b/init/services/compilers/ffmpeg.ps1 new file mode 100644 index 0000000..387b810 --- /dev/null +++ b/init/services/compilers/ffmpeg.ps1 @@ -0,0 +1,72 @@ +# BSD 3-Clause License +# +# Copyright (c) 2024, (Holloway) Chew, Kean Ho +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +. "${env:LIBS_UPSCALER}\services\i18n\report-simulation.ps1" +. "${env:LIBS_UPSCALER}\services\io\os.ps1" +. "${env:LIBS_UPSCALER}\services\io\fs.ps1" +. "${env:LIBS_UPSCALER}\services\io\strings.ps1" + + + + +function FFMPEG-Is-Available { + if ((STRINGS-Is-Empty "${env:UPSCALER_TEST_MODE}") -ne 0) { + $null = I18N-Report-Simulation "ffmpeg & ffprobe" + return 0 + } + + # execute + $___process = OS-Is-Command-Available "ffmpeg" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "ffprobe" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function FFMPEG-Video-Dissect { + return 0 +} + + + + +function FFMPEG-Video-Reassemble { + return 0 +} diff --git a/init/services/compilers/ffmpeg.sh b/init/services/compilers/ffmpeg.sh new file mode 100644 index 0000000..7d8b5e1 --- /dev/null +++ b/init/services/compilers/ffmpeg.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# +# BSD 3-Clause License +# +# Copyright (c) 2023, (Holloway) Chew, Kean Ho +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +. "${LIBS_UPSCALER}/services/i18n/report-simulation.sh" +. "${LIBS_UPSCALER}/services/io/os.sh" +. "${LIBS_UPSCALER}/services/io/fs.sh" +. "${LIBS_UPSCALER}/services/io/strings.sh" + + + + +FFMPEG_Is_Available() { + # execute + if [ ! "$(STRINGS_Is_Empty "$UPSCALER_TEST_MODE")" = "0" ]; then + I18N_Report_Simulation "ffmpeg & ffprobe" + return 0 + fi + + OS_Is_Command_Available "ffmpeg" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "ffprobe" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +FFMPEG_Video_Dissect() { + #___input="$1" + #___output="$2" + + return 0 +} + + + + +FFMPEG_Video_Reassemble() { + #___input="$1" + #___output="$2" + + return 0 +} diff --git a/init/services/compilers/upscaler.ps1 b/init/services/compilers/upscaler.ps1 index a5dc9a8..9b21344 100644 --- a/init/services/compilers/upscaler.ps1 +++ b/init/services/compilers/upscaler.ps1 @@ -27,10 +27,131 @@ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +. "${env:LIBS_UPSCALER}\services\i18n\report-simulation.ps1" . "${env:LIBS_UPSCALER}\services\io\os.ps1" . "${env:LIBS_UPSCALER}\services\io\fs.ps1" . "${env:LIBS_UPSCALER}\services\io\strings.ps1" -. "${env:LIBS_UPSCALER}\services\i18n\report-simulation.ps1" + + + + +function UPSCALER-Batch-Load { + param( + [string]$___video, + [string]$___model, + [string]$___scale, + [string]$___format, + [string]$___parallel, + [string]$___gpu, + [string]$___input, + [string]$___output + ) + + + # validate input + if ( ((STRINGS-Is-Empty "${___video}") -eq 0) -or + ((STRINGS-Is-Empty "${___model}") -eq 0) -or + ((STRINGS-Is-Empty "${___scale}") -eq 0) -or + ((STRINGS-Is-Empty "${___format}") -eq 0) -or + ((STRINGS-Is-Empty "${___parallel}") -eq 0) -or + ((STRINGS-Is-Empty "${___gpu}") -eq 0) -or + ((STRINGS-Is-Empty "${___input}") -eq 0) -or + ((STRINGS-Is-Empty "${___output}") -eq 0)) { + return 1 + } + + + if ((STRINGS-Is-Empty "$(UPSCALER-Program-Get)") -eq 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function UPSCALER-Batch-Run { + param( + [string]$___video, + [string]$___model, + [string]$___scale, + [string]$___format, + [string]$___parallel, + [string]$___gpu, + [string]$___input, + [string]$___output + ) + + + # validate input + if ( ((STRINGS-Is-Empty "${___video}") -eq 0) -or + ((STRINGS-Is-Empty "${___model}") -eq 0) -or + ((STRINGS-Is-Empty "${___scale}") -eq 0) -or + ((STRINGS-Is-Empty "${___format}") -eq 0) -or + ((STRINGS-Is-Empty "${___parallel}") -eq 0) -or + ((STRINGS-Is-Empty "${___gpu}") -eq 0) -or + ((STRINGS-Is-Empty "${___input}") -eq 0) -or + ((STRINGS-Is-Empty "${___output}") -eq 0)) { + return 1 + } + + + # execute + if ((STRINGS-Is-Empty "${env:UPSCALER_TEST_MODE}") -ne 0) { + $null = I18N-Report-Simulation "$(UPSCALER-Program-Get) ${___cmd}" + $null = FS-Make-Housing-Directory "${___output}" + $null = FS-Remove-Silently "${___output}" + $___process = FS-Copy-File "${___input}" "${___output}" + if ($___process -eq 0) { + return 0 + } + } + + + # report status + return 0 +} + + + + +function UPSCALER-Batch-Setup { + param( + [string]$___video, + [string]$___model, + [string]$___scale, + [string]$___format, + [string]$___parallel, + [string]$___gpu, + [string]$___input, + [string]$___output + ) + + + # validate input + if ( ((STRINGS-Is-Empty "${___video}") -eq 0) -or + ((STRINGS-Is-Empty "${___model}") -eq 0) -or + ((STRINGS-Is-Empty "${___scale}") -eq 0) -or + ((STRINGS-Is-Empty "${___format}") -eq 0) -or + ((STRINGS-Is-Empty "${___parallel}") -eq 0) -or + ((STRINGS-Is-Empty "${___gpu}") -eq 0) -or + ((STRINGS-Is-Empty "${___input}") -eq 0) -or + ((STRINGS-Is-Empty "${___output}") -eq 0)) { + return 1 + } + + + if ((STRINGS-Is-Empty "$(UPSCALER-Program-Get)") -eq 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/init/services/compilers/upscaler.sh b/init/services/compilers/upscaler.sh index d44b395..d95b319 100644 --- a/init/services/compilers/upscaler.sh +++ b/init/services/compilers/upscaler.sh @@ -37,6 +37,123 @@ +UPSCALER_Batch_Load() { + #___video="$1" + #___model="$2" + #___scale="$3" + #___format="$4" + #___parallel="$5" + #___gpu="$6" + #___input="$7" + #___output="$8" + + + # validate input + if [ "$(STRINGS_Is_Empty "$1")" = "0" ] || + [ "$(STRINGS_Is_Empty "$2")" = "0" ] || + [ "$(STRINGS_Is_Empty "$3")" = "0" ] || + [ "$(STRINGS_Is_Empty "$4")" = "0" ] || + [ "$(STRINGS_Is_Empty "$5")" = "0" ] || + [ "$(STRINGS_Is_Empty "$6")" = "0" ] || + [ "$(STRINGS_Is_Empty "$7")" = "0" ] || + [ "$(STRINGS_Is_Empty "$8")" = "0" ]; then + return 1 + fi + + if [ "$(STRINGS_Is_Empty "$(UPSCALER_Program_Get)")" = "0" ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +UPSCALER_Batch_Run() { + #___video="$1" + #___model="$2" + #___scale="$3" + #___format="$4" + #___parallel="$5" + #___gpu="$6" + #___input="$7" + #___output="$8" + + + # validate input + if [ "$(STRINGS_Is_Empty "$1")" = "0" ] || + [ "$(STRINGS_Is_Empty "$2")" = "0" ] || + [ "$(STRINGS_Is_Empty "$3")" = "0" ] || + [ "$(STRINGS_Is_Empty "$4")" = "0" ] || + [ "$(STRINGS_Is_Empty "$5")" = "0" ] || + [ "$(STRINGS_Is_Empty "$6")" = "0" ] || + [ "$(STRINGS_Is_Empty "$7")" = "0" ] || + [ "$(STRINGS_Is_Empty "$8")" = "0" ]; then + return 1 + fi + + if [ "$(STRINGS_Is_Empty "$(UPSCALER_Program_Get)")" = "0" ]; then + return 1 + fi + + + # execute + if [ ! "$(STRINGS_Is_Empty "$UPSCALER_TEST_MODE")" = "0" ]; then + I18N_Report_Simulation "$(UPSCALER_Program_Get) ${___cmd}" + FS_Make_Housing_Directory "$8" + FS_Remove_Silently "$8" + FS_Copy_File "$7" "$8" + if [ $? -eq 0 ]; then + return 0 + fi + fi + + + # report status + return 0 +} + + + + +UPSCALER_Batch_Setup() { + #___video="$1" + #___model="$2" + #___scale="$3" + #___format="$4" + #___parallel="$5" + #___gpu="$6" + #___input="$7" + #___output="$8" + + + # validate input + if [ "$(STRINGS_Is_Empty "$1")" = "0" ] || + [ "$(STRINGS_Is_Empty "$2")" = "0" ] || + [ "$(STRINGS_Is_Empty "$3")" = "0" ] || + [ "$(STRINGS_Is_Empty "$4")" = "0" ] || + [ "$(STRINGS_Is_Empty "$5")" = "0" ] || + [ "$(STRINGS_Is_Empty "$6")" = "0" ] || + [ "$(STRINGS_Is_Empty "$7")" = "0" ] || + [ "$(STRINGS_Is_Empty "$8")" = "0" ]; then + return 1 + fi + + if [ "$(STRINGS_Is_Empty "$(UPSCALER_Program_Get)")" = "0" ]; then + return 1 + fi + + + # report status + return 0 +} + + + + UPSCALER_Format_Validate() { #___format="$1" diff --git a/init/services/i18n/error-ffmpeg-dissect.ps1 b/init/services/i18n/error-ffmpeg-dissect.ps1 new file mode 100644 index 0000000..7adec5e --- /dev/null +++ b/init/services/i18n/error-ffmpeg-dissect.ps1 @@ -0,0 +1,50 @@ +# BSD 3-Clause License +# +# Copyright (c) 2024 (Holloway) Chew, Kean Ho +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +. "${env:LIBS_UPSCALER}\services\i18n\__printer.ps1" + + + + +function I18N-Error-FFMPEG-Dissect { + # execute + switch (${env:UPSCALER_LANG}) { + { $_ -in "DE", "de" } { + # german + $null = I18N-Status-Print "error" ` + "Die FFMPEG-Frames-Dissektion ist fehlgeschlagen.`n" + } default { + # fallback to default english + $null = I18N-Status-Print "error" "FFMPEG frames dissection failed.`n" + }} + + + # report status + return 0 +} diff --git a/init/services/i18n/error-ffmpeg-dissect.sh b/init/services/i18n/error-ffmpeg-dissect.sh new file mode 100644 index 0000000..4ece962 --- /dev/null +++ b/init/services/i18n/error-ffmpeg-dissect.sh @@ -0,0 +1,51 @@ +# BSD 3-Clause License +# +# Copyright (c) 2024 (Holloway) Chew, Kean Ho +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +. "${LIBS_UPSCALER}/services/i18n/__printer.sh" + + + + +I18N_Error_FFMPEG_Dissect() { + # execute + case "$UPSCALER_LANG" in + DE|de) + # German + I18N_Status_Print "error" "Die FFMPEG-Frames-Dissektion ist fehlgeschlagen.\n" + ;; + *) + # fallback to default english + I18N_Status_Print "error" "FFMPEG frames dissection failed.\n" + ;; + esac + + + # report status + return 0 +} diff --git a/init/services/i18n/error-ffmpeg-unavailable.ps1 b/init/services/i18n/error-ffmpeg-unavailable.ps1 new file mode 100644 index 0000000..c0fb4ca --- /dev/null +++ b/init/services/i18n/error-ffmpeg-unavailable.ps1 @@ -0,0 +1,49 @@ +# BSD 3-Clause License +# +# Copyright (c) 2024 (Holloway) Chew, Kean Ho +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +. "${env:LIBS_UPSCALER}\services\i18n\__printer.ps1" + + + + +function I18N-Error-FFMPEG-Unavailable { + # execute + switch (${env:UPSCALER_LANG}) { + { $_ -in "DE", "de" } { + # german + $null = I18N-Status-Print "error" "FFMPEG | FFPROBE ist nicht verfügbar.`n" + } default { + # fallback to default english + $null = I18N-Status-Print "error" "FFMPEG | FFPROBE is unavailable.`n" + }} + + + # report status + return 0 +} diff --git a/init/services/i18n/error-ffmpeg-unavailable.sh b/init/services/i18n/error-ffmpeg-unavailable.sh new file mode 100644 index 0000000..f2ac843 --- /dev/null +++ b/init/services/i18n/error-ffmpeg-unavailable.sh @@ -0,0 +1,51 @@ +# BSD 3-Clause License +# +# Copyright (c) 2024 (Holloway) Chew, Kean Ho +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +. "${LIBS_UPSCALER}/services/i18n/__printer.sh" + + + + +I18N_Error_FFMPEG_Unavailable() { + # execute + case "$UPSCALER_LANG" in + DE|de) + # German + I18N_Status_Print "error" "FFMPEG | FFPROBE ist nicht verfügbar.\n" + ;; + *) + # fallback to default english + I18N_Status_Print "error" "FFMPEG | FFPROBE is unavailable.\n" + ;; + esac + + + # report status + return 0 +} diff --git a/init/services/i18n/error-video-setup.ps1 b/init/services/i18n/error-video-setup.ps1 new file mode 100644 index 0000000..b442c6a --- /dev/null +++ b/init/services/i18n/error-video-setup.ps1 @@ -0,0 +1,50 @@ +# BSD 3-Clause License +# +# Copyright (c) 2024 (Holloway) Chew, Kean Ho +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +. "${env:LIBS_UPSCALER}\services\i18n\__printer.ps1" + + + + +function I18N-Error-Video-Setup { + # execute + switch (${env:UPSCALER_LANG}) { + { $_ -in "DE", "de" } { + # german + $null = I18N-Status-Print "error" ` + "Die Einrichtung des Arbeitsbereichs für die Videohochskalierung ist fehlgeschlagen.`n" + } default { + # fallback to default english + $null = I18N-Status-Print "error" "Video upscaling workspace setup failed.`n" + }} + + + # report status + return 0 +} diff --git a/init/services/i18n/error-video-setup.sh b/init/services/i18n/error-video-setup.sh new file mode 100644 index 0000000..ba40a40 --- /dev/null +++ b/init/services/i18n/error-video-setup.sh @@ -0,0 +1,52 @@ +# BSD 3-Clause License +# +# Copyright (c) 2024 (Holloway) Chew, Kean Ho +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +. "${LIBS_UPSCALER}/services/i18n/__printer.sh" + + + + +I18N_Error_Video_Setup() { + # execute + case "$UPSCALER_LANG" in + DE|de) + # German + I18N_Status_Print "error" \ + "Die Einrichtung des Arbeitsbereichs für die Videohochskalierung ist fehlgeschlagen.\n" + ;; + *) + # fallback to default english + I18N_Status_Print "error" "Video upscaling workspace setup failed.\n" + ;; + esac + + + # report status + return 0 +} diff --git a/init/services/i18n/error-video-upscale.ps1 b/init/services/i18n/error-video-upscale.ps1 new file mode 100644 index 0000000..6ad9e59 --- /dev/null +++ b/init/services/i18n/error-video-upscale.ps1 @@ -0,0 +1,50 @@ +# BSD 3-Clause License +# +# Copyright (c) 2024 (Holloway) Chew, Kean Ho +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +. "${env:LIBS_UPSCALER}\services\i18n\__printer.ps1" + + + + +function I18N-Error-Video-Upscale { + # execute + switch (${env:UPSCALER_LANG}) { + { $_ -in "DE", "de" } { + # german + $null = I18N-Status-Print "error" ` + "Fehler bei der Skalierung von Videoframes.`n" + } default { + # fallback to default english + $null = I18N-Status-Print "error" "Video frame scaling failed.`n" + }} + + + # report status + return 0 +} diff --git a/init/services/i18n/error-video-upscale.sh b/init/services/i18n/error-video-upscale.sh new file mode 100644 index 0000000..c84999e --- /dev/null +++ b/init/services/i18n/error-video-upscale.sh @@ -0,0 +1,52 @@ +# BSD 3-Clause License +# +# Copyright (c) 2024 (Holloway) Chew, Kean Ho +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +. "${LIBS_UPSCALER}/services/i18n/__printer.sh" + + + + +I18N_Error_Video_Upscale() { + # execute + case "$UPSCALER_LANG" in + DE|de) + # German + I18N_Status_Print "error" \ + "Fehler bei der Skalierung von Videoframes.\n" + ;; + *) + # fallback to default english + I18N_Status_Print "error" "Video frame scaling failed.\n" + ;; + esac + + + # report status + return 0 +} diff --git a/init/start.ps1 b/init/start.ps1 index 86a4a40..9ec64d8 100644 --- a/init/start.ps1 +++ b/init/start.ps1 @@ -91,6 +91,7 @@ ${env:LIBS_UPSCALER} = "${env:UPSCALER_PATH_ROOT}\${env:UPSCALER_PATH_SCRIPTS}" # import fundamental libraries . "${env:LIBS_UPSCALER}\services\io\strings.ps1" +. "${env:LIBS_UPSCALER}\services\compilers\ffmpeg.ps1" . "${env:LIBS_UPSCALER}\services\compilers\upscaler.ps1" . "${env:LIBS_UPSCALER}\services\i18n\error-format-unsupported.ps1" . "${env:LIBS_UPSCALER}\services\i18n\error-gpu-unsupported.ps1" @@ -100,6 +101,8 @@ ${env:LIBS_UPSCALER} = "${env:UPSCALER_PATH_ROOT}\${env:UPSCALER_PATH_SCRIPTS}" . "${env:LIBS_UPSCALER}\services\i18n\error-parallel-unsupported.ps1" . "${env:LIBS_UPSCALER}\services\i18n\error-scale-unknown.ps1" . "${env:LIBS_UPSCALER}\services\i18n\error-unsupported.ps1" +. "${env:LIBS_UPSCALER}\services\i18n\error-video-setup.ps1" +. "${env:LIBS_UPSCALER}\services\i18n\error-video-upscale.ps1" . "${env:LIBS_UPSCALER}\services\i18n\help.ps1" . "${env:LIBS_UPSCALER}\services\i18n\report-info.ps1" . "${env:LIBS_UPSCALER}\services\i18n\report-success.ps1" @@ -303,9 +306,47 @@ if ((${__video} -eq 0) -and (${__batch} -eq 0)) { return 0 } } elseif (${__video} -eq 1) { + $___process = FFMPEG-Is-Available + if ($___process -ne 0) { + $null = I18N-Error-FFMPEG-Unavailable + return 1 + } + $__output = UPSCALER-Output-Filename-Video "${__output}" "${__input}" + # attempt to parse workspace + $___process = UPSCALER-Batch-Load "${__video}" ` + "${__model}" ` + "${__scale}" ` + "${__format}" ` + "${__parallel}" ` + "${__gpu}" ` + "${__input}" ` + "${__output}" + if ($___process -ne 0) { + $___process = FFMPEG-Video-Dissect "${__input}" "${__output}" + if ($___process -ne 0) { + $null = I18N-Error-FFMPEG-Dissect + return 1 + } + + + $___process = UPSCALER-Batch-Setup "${__video}" ` + "${__model}" ` + "${__scale}" ` + "${__format}" ` + "${__parallel}" ` + "${__gpu}" ` + "${__input}" ` + "${__output}" + if ($___process -ne 0) { + $null = I18N-Error-Video-Setup + return 1 + } + } + + # report task info $null = I18N-Report-Info ` "${__batch}" ` @@ -320,6 +361,22 @@ if ((${__video} -eq 0) -and (${__batch} -eq 0)) { # execute + $___process = UPSCALER-Batch-Run "${__video}" ` + "${__model}" ` + "${__scale}" ` + "${__format}" ` + "${__parallel}" ` + "${__gpu}" ` + "${__input}" ` + "${__output}" + if ($___process -ne 0) { + $null = I18N-Error-Video-Upscale + return 1 + } + + + # assemble back to video + $___process = FFMPEG-Video-Reassemble "${__input}" "${__output}" if ($___process -eq 0) { $null = I18N-Report-Success return 0 diff --git a/init/start.sh b/init/start.sh index 91b129c..97f28d0 100644 --- a/init/start.sh +++ b/init/start.sh @@ -83,7 +83,9 @@ export LIBS_UPSCALER="${UPSCALER_PATH_ROOT}/${UPSCALER_PATH_SCRIPTS}" # import fundamental libraries . "${LIBS_UPSCALER}/services/io/strings.sh" +. "${LIBS_UPSCALER}/services/compilers/ffmpeg.sh" . "${LIBS_UPSCALER}/services/compilers/upscaler.sh" +. "${LIBS_UPSCALER}/services/i18n/error-ffmpeg-unavailable.sh" . "${LIBS_UPSCALER}/services/i18n/error-format-unsupported.sh" . "${LIBS_UPSCALER}/services/i18n/error-gpu-unsupported.sh" . "${LIBS_UPSCALER}/services/i18n/error-input-unknown.sh" @@ -92,6 +94,8 @@ export LIBS_UPSCALER="${UPSCALER_PATH_ROOT}/${UPSCALER_PATH_SCRIPTS}" . "${LIBS_UPSCALER}/services/i18n/error-parallel-unsupported.sh" . "${LIBS_UPSCALER}/services/i18n/error-scale-unknown.sh" . "${LIBS_UPSCALER}/services/i18n/error-unsupported.sh" +. "${LIBS_UPSCALER}/services/i18n/error-video-setup.sh" +. "${LIBS_UPSCALER}/services/i18n/error-video-upscale.sh" . "${LIBS_UPSCALER}/services/i18n/help.sh" . "${LIBS_UPSCALER}/services/i18n/report-info.sh" . "${LIBS_UPSCALER}/services/i18n/report-success.sh" @@ -302,9 +306,47 @@ if [ "$__video" = "0" ] && [ "$__batch" = "0" ]; then return 0 fi elif [ "$__video" = "1" ]; then + FFMPEG_Is_Available + if [ $? -ne 0 ]; then + I18N_Error_FFMPEG_Unavailable + return 1 + fi + __output="$(UPSCALER_Output_Filename_Video "$__output" "$__input")" + # attempt to parse workspace + UPSCALER_Batch_Load "${__video}" \ + "${__model}" \ + "${__scale}" \ + "${__format}" \ + "${__parallel}" \ + "${__gpu}" \ + "${__input}" \ + "${__output}" + if [ $? -ne 0 ]; then + FFMPEG_Video_Dissect "${__input}" "${__output}" + if [ $? -ne 0 ]; then + I18N_Error_FFMPEG_Dissect + return 1 + fi + + + UPSCALER_Batch_Setup "${__video}" \ + "${__model}" \ + "${__scale}" \ + "${__format}" \ + "${__parallel}" \ + "${__gpu}" \ + "${__input}" \ + "${__output}" + if [ $? -ne 0 ]; then + I18N_Error_Video_Setup + return 1 + fi + fi + + # report task info I18N_Report_Info \ "${__batch}" \ @@ -319,6 +361,23 @@ elif [ "$__video" = "1" ]; then # execute + UPSCALER_Batch_Run \ + "${__video}" \ + "${__model}" \ + "${__scale}" \ + "${__format}" \ + "${__parallel}" \ + "${__gpu}" \ + "${__input}" \ + "${__output}" + if [ $? -ne 0 ]; then + I18N_Error_Video_Upscale + return 1 + fi + + + # assemble back to video + FFMPEG_Video_Reassemble "${__input}" "${__output}" if [ $? -eq 0 ]; then I18N_Report_Success return 0 diff --git a/tests/02_test_upscale_video_single.sh.ps1 b/tests/02_test_upscale_video_single.sh.ps1 new file mode 100755 index 0000000..4473f0b --- /dev/null +++ b/tests/02_test_upscale_video_single.sh.ps1 @@ -0,0 +1,206 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +echo "[ ERROR ] Use powershell.exe!" +exit /b 1 +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +$PSDefaultParameterValues['*:Encoding'] = 'utf8' +$OutputEncoding = [console]::InputEncoding ` + = [console]::OutputEncoding ` + = New-Object System.Text.UTF8Encoding + + +# Scan for fundamental pathing +${env:UPSCALER_PATH_PWD} = Get-Location +${env:UPSCALER_PATH_SCRIPTS} = "init" + +if (Test-Path ".\start.ps1") { + # currently inside the automataCI directory. + ${env:UPSCALER_PATH_ROOT} = Split-Path -Parent "${env:UPSCALER_PATH_PWD}" +} elseif (Test-Path ".\${env:UPSCALER_PATH_SCRIPTS}\start.ps1") { + # current directory is the root directory. + ${env:UPSCALER_PATH_ROOT} = "${env:UPSCALER_PATH_PWD}" +} else { + # scan from current directory - bottom to top + $__pathing = "${env:UPSCALER_PATH_PWD}" + ${env:UPSCALER_PATH_ROOT} = "" + foreach ($__pathing in (${env:UPSCALER_PATH_PWD}.Split("\"))) { + if (-not [string]::IsNullOrEmpty($env:UPSCLAER_PATH_ROOT)) { + ${env:UPSCALER_PATH_ROOT} += "\" + } + ${env:UPSCALER_PATH_ROOT} += "${__pathing}" + + if (Test-Path -Path ` + "${env:UPSCALER_PATH_ROOT}\${env:UPSCALER_PATH_SCRIPTS}\start.ps1") { + break + } + } + $null = Remove-Variable -Name __pathing + + if (-not (Test-Path "${env:UPSCALER_PATH_ROOT}\${env:UPSCALER_PATH_SCRIPTS}\start.ps1")) { + Write-Error "[ ERROR ] Missing root directory.`n`n" + exit 1 + } +} + +${env:LIBS_UPSCALER} = "${env:UPSCALER_PATH_ROOT}\${env:UPSCALER_PATH_SCRIPTS}" + + + + +# import fundamental libraries +. "${env:LIBS_UPSCALER}\services\i18n\__printer.ps1" + + + + +# execute suite +$null = I18N-Status-Print "note" "RUNNING HELP TEST SUITE`n`n`n" +$__verdict = $true + + +$null = I18N-Status-Print "note" "test single video upscale...`n" +$__process = . "${env:LIBS_UPSCALER}\start.ps1" ` + "--model" "upscayl-nmkd-4x-superscale-sd-178000-g" ` + "--scale" "4" ` + "--parallel" "2" ` + "--input" "${env:UPSCALER_PATH_ROOT}\tests\video\sample-1-640x360.mp4" ` + "--output" "${env:UPSCALER_PATH_ROOT}\tmp\test-01\sample-01-upscaled.mp4" +if ($__process -ne 0) { + $null = I18N-Status-Print "error" "Failed - bad processing.`n`n" + $__verdict = $false +} + +if (-not (Test-Path -Path "${env:UPSCALER_PATH_ROOT}\tmp\test-01\sample-01-upscaled.mp4")) { + $null = I18N-Status-Print "error" "Failed - missing output.`n`n" + $__verdict = $false +} + + + +# report verdict +if (-not $__verdict) { + $null = I18N-Status-Print "error" "TEST SUITE FAILED.`n`n`n" + exit 1 +} + +$null = I18N-Status-Print "success" "TEST SUITE PASSED.`n`n`n" +exit 0 + + +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +exit $__process +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +# Scan for fundamental pathing +export UPSCALER_PATH_PWD="$PWD" +export UPSCALER_PATH_SCRIPTS="init" + +if [ -f "./start.sh" ]; then + UPSCALER_PATH_ROOT="${PWD%/*}/" +elif [ -f "./${UPSCALER_PATH_SCRIPTS}/start.sh" ]; then + # current directory is the root directory. + UPSCALER_PATH_ROOT="$PWD" +else + __pathing="$UPSCALER_PATH_PWD" + __previous="" + while [ "$__pathing" != "" ]; do + UPSCALER_PATH_ROOT="${UPSCALER_PATH_ROOT}${__pathing%%/*}/" + __pathing="${__pathing#*/}" + if [ -f "${UPSCALER_PATH_ROOT}${UPSCALER_PATH_SCRIPTS}/start.sh" ]; then + break + fi + + # stop the scan if the previous pathing is the same as current + if [ "$__previous" = "$__pathing" ]; then + 1>&2 printf "[ ERROR ] Missing root directory.\n" + exit 1 + fi + __previous="$__pathing" + done + unset __pathing __previous + export UPSCALER_PATH_ROOT="${UPSCALER_PATH_ROOT%/*}" + + if [ ! -f "${UPSCALER_PATH_ROOT}/${UPSCALER_PATH_SCRIPTS}/start.sh" ]; then + 1>&2 printf "[ ERROR ] Missing root directory.\n" + exit 1 + fi +fi + +export LIBS_UPSCALER="${UPSCALER_PATH_ROOT}/${UPSCALER_PATH_SCRIPTS}" + + + + +# import fundamental libraries +. "${LIBS_UPSCALER}/services/i18n/__printer.sh" + + + + +# execute suite +I18N_Status_Print "note" "RUNNING HELP TEST SUITE\n\n\n" +__verdict=0 + + +I18N_Status_Print "note" "test single video upscale...\n" +. "${LIBS_UPSCALER}"/start.sh \ + --model upscayl-nmkd-4x-superscale-sd-178000-g \ + --scale 4 \ + --parallel 2 \ + --input "${UPSCALER_PATH_ROOT}/tests/video/sample-1-640x360.mp4" \ + "--output" "${UPSCALER_PATH_ROOT}/tmp/test-01/sample-01-upscaled.mp4" +if [ $? -ne 0 ]; then + I18N_Status_Print "error" "Failed - bad processing.\n\n" + __verdict=1 +fi + +if [ ! -f "${UPSCALER_PATH_ROOT}/tmp/test-01/sample-01-upscaled.mp4" ]; then + I18N_Status_Print "error" "Failed - missing output.\n\n" + __verdict=1 +fi + + + +# report verdict +if [ "$__verdict" != "0" ]; then + I18N_Status_Print "error" "TEST SUITE FAILED.\n\n\n" + exit 1 +fi + +I18N_Status_Print "success" "TEST SUITE PASSED.\n\n\n" +exit 0 +################################################################################ +# Unix Main Codes # +################################################################################ +exit $? +#>