Compare commits
12 commits
Author | SHA1 | Date | |
---|---|---|---|
44f6777f70 | |||
54a4bf1274 | |||
9f903caa28 | |||
3f3de59844 | |||
00925a4908 | |||
555ea0ebbb | |||
e5bf961ddb | |||
debc1755bb | |||
ce62218cda | |||
3802c52ba0 | |||
9c367e5249 | |||
c1f152d8d0 |
7 changed files with 69 additions and 37 deletions
31
PKGBUILD
Normal file
31
PKGBUILD
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# Maintainer: D. Can Celasun <can[at]dcc[dot]im>
|
||||||
|
# Contributor: Ezekiel Bethel <mctinfoilball@gmail.com>
|
||||||
|
|
||||||
|
_pkgname=VNTools
|
||||||
|
pkgname=vntools-git
|
||||||
|
pkgver=2.0.e5bf961
|
||||||
|
pkgrel=1
|
||||||
|
pkgdesc="Collection of tools used by VienDesu! Porting Team"
|
||||||
|
arch=("any")
|
||||||
|
url="https://github.com/VienDesuPorting/VNTools"
|
||||||
|
depends=("python" "python-pillow" "python-pillow-avif-plugin" "python-python-ffmpeg" "python-progress" "python-colorama")
|
||||||
|
makedepends=("python-setuptools" "git")
|
||||||
|
provides=("vntools")
|
||||||
|
source=("git+${url}.git#branch=testing")
|
||||||
|
sha256sums=("SKIP")
|
||||||
|
|
||||||
|
pkgver() {
|
||||||
|
cd "${srcdir}/${_pkgname}"
|
||||||
|
printf "2.0.%s" "$(git rev-parse --short HEAD)"
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd "${srcdir}/${_pkgname}"
|
||||||
|
python -m build --wheel --no-isolation
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "${srcdir}/${_pkgname}"
|
||||||
|
python -m installer --destdir="${pkgdir}" dist/*.whl
|
||||||
|
}
|
||||||
|
|
12
README.md
12
README.md
|
@ -9,17 +9,15 @@ Collection of tools used by VienDesu! Porting Team
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
#### Download from releases:
|
#### Download from releases:
|
||||||
* Windows - `TODO`
|
* Windows - [x64](https://git.viende.su/VienDesuPorting/VNTools/releases/download/2.0.0/vntools-win-x64.zip)
|
||||||
* Linux - `TODO`
|
* Linux - [x86_64](https://git.viende.su/VienDesuPorting/VNTools/releases/download/2.0.0/vntools-linux-x86_64.zip) [arm64](https://git.viende.su/VienDesuPorting/VNTools/releases/download/2.0.0/vntools-linux-arm64.zip)
|
||||||
* MacOS - `TODO`
|
* MacOS - [x86_64](https://git.viende.su/VienDesuPorting/VNTools/releases/download/2.0.0/vntools-darwin-x86_64.zip) [arm64](https://git.viende.su/VienDesuPorting/VNTools/releases/download/2.0.0/vntools-darwin-arm64.zip)
|
||||||
|
|
||||||
#### Build tools as binaries:
|
#### Build tools as binaries:
|
||||||
* Run `./build.sh` on UNIX
|
* Run `./build.sh` for UNIX
|
||||||
* Run `.\build.bat` for Windows
|
* Run `.\build.bat` for Windows
|
||||||
* Arch Linux - `TODO`
|
|
||||||
* NixOS - `TODO`
|
|
||||||
|
|
||||||
#### Install as python package:
|
#### Install as python package:
|
||||||
* Run `pip install -U .` command in project folder
|
* Run `pip install -U .` command in project folder
|
||||||
* Arch Linux - `TODO`
|
* Arch Linux - `paru -Bi .`
|
||||||
* NixOS - `TODO`
|
* NixOS - `TODO`
|
||||||
|
|
|
@ -20,13 +20,13 @@ unrenapk = "unrenapk.application:launch"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "vntools"
|
name = "vntools"
|
||||||
version = "2.0-dev"
|
version = "2.0.0"
|
||||||
requires-python = ">= 3.11"
|
requires-python = ">= 3.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Pillow==10.3.0",
|
"Pillow>=10.3.0",
|
||||||
"pillow-avif-plugin==1.4.3",
|
"pillow-avif-plugin>=1.4.3",
|
||||||
"python-ffmpeg==2.0.12",
|
"python-ffmpeg>=2.0.12",
|
||||||
"progress==1.6",
|
"progress>=1.6",
|
||||||
"colorama==0.4.6",
|
"colorama>=0.4.6",
|
||||||
"argparse~=1.4.0"
|
"argparse>=1.4.0"
|
||||||
]
|
]
|
|
@ -1,6 +1,6 @@
|
||||||
Pillow==10.3.0
|
Pillow>=10.3.0
|
||||||
pillow-avif-plugin==1.4.3
|
pillow-avif-plugin>=1.4.3
|
||||||
python-ffmpeg==2.0.12
|
python-ffmpeg>=2.0.12
|
||||||
progress==1.6
|
progress>=1.6
|
||||||
colorama==0.4.6
|
colorama>=0.4.6
|
||||||
argparse~=1.4.0
|
argparse>=1.4.0
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Compress:
|
||||||
"""
|
"""
|
||||||
bit_rate = self.__params.audio_bitrate
|
bit_rate = self.__params.audio_bitrate
|
||||||
prefix = self.__utils.get_hash(input_path.name)
|
prefix = self.__utils.get_hash(input_path.name)
|
||||||
out_file = Path(output_dir, f'{prefix}_{input_path.stem}.{extension}')
|
out_file = Path(output_dir, f'.{prefix}_{input_path.stem}.{extension}')
|
||||||
try:
|
try:
|
||||||
(FFmpeg()
|
(FFmpeg()
|
||||||
.input(input_path)
|
.input(input_path)
|
||||||
|
@ -93,7 +93,7 @@ class Compress:
|
||||||
"""
|
"""
|
||||||
quality = self.__params.image_quality
|
quality = self.__params.image_quality
|
||||||
prefix = self.__utils.get_hash(input_path.name)
|
prefix = self.__utils.get_hash(input_path.name)
|
||||||
out_file = Path(output_dir, f"{prefix}_{input_path.stem}.{extension}")
|
out_file = Path(output_dir, f".{prefix}_{input_path.stem}.{extension}")
|
||||||
try:
|
try:
|
||||||
image = Image.open(input_path)
|
image = Image.open(input_path)
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class Compress:
|
||||||
(extension == "webp" and not self.__params.webp_rgba)):
|
(extension == "webp" and not self.__params.webp_rgba)):
|
||||||
if File.has_transparency(image):
|
if File.has_transparency(image):
|
||||||
self.__printer.warning(f"{input_path.name} has transparency. Changing to fallback...")
|
self.__printer.warning(f"{input_path.name} has transparency. Changing to fallback...")
|
||||||
out_file = Path(output_dir, f"{prefix}_{input_path.stem}.{self.__params.image_fall_ext}")
|
out_file = Path(output_dir, f".{prefix}_{input_path.stem}.{self.__params.image_fall_ext}")
|
||||||
|
|
||||||
if File.has_transparency(image):
|
if File.has_transparency(image):
|
||||||
image.convert('RGBA')
|
image.convert('RGBA')
|
||||||
|
@ -131,7 +131,7 @@ class Compress:
|
||||||
:return: Path of compressed video file with md5 hash as prefix
|
:return: Path of compressed video file with md5 hash as prefix
|
||||||
"""
|
"""
|
||||||
prefix = self.__utils.get_hash(input_path.name)
|
prefix = self.__utils.get_hash(input_path.name)
|
||||||
out_file = Path(output_dir, f'{prefix}_{input_path.stem}.{extension}')
|
out_file = Path(output_dir, f'.{prefix}_{input_path.stem}.{extension}')
|
||||||
if not self.__params.video_skip:
|
if not self.__params.video_skip:
|
||||||
codec = self.__params.video_codec
|
codec = self.__params.video_codec
|
||||||
crf = self.__params.video_crf
|
crf = self.__params.video_crf
|
||||||
|
@ -160,7 +160,7 @@ class Compress:
|
||||||
:return: Path of compressed file with md5 hash as prefix
|
:return: Path of compressed file with md5 hash as prefix
|
||||||
"""
|
"""
|
||||||
prefix = self.__utils.get_hash(input_path.name)
|
prefix = self.__utils.get_hash(input_path.name)
|
||||||
out_file = Path(output_dir, f"{prefix}_{input_path.name}")
|
out_file = Path(output_dir, f".{prefix}_{input_path.name}")
|
||||||
if self.__params.force_compress:
|
if self.__params.force_compress:
|
||||||
self.__printer.unknown_file(input_path.name)
|
self.__printer.unknown_file(input_path.name)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -68,7 +68,10 @@ class Params:
|
||||||
video_ext = config["VIDEO"]["Extension"] if args.config else args.v_ext
|
video_ext = config["VIDEO"]["Extension"] if args.config else args.v_ext
|
||||||
video_codec = config["VIDEO"]["Codec"] if args.config else args.v_codec
|
video_codec = config["VIDEO"]["Codec"] if args.config else args.v_codec
|
||||||
source = Path(args.source)
|
source = Path(args.source)
|
||||||
dest = Path(f"{args.source}_compressed")
|
if not source.exists():
|
||||||
|
print("Requested path does not exists. Exiting!")
|
||||||
|
exit(255)
|
||||||
|
dest = Path(source.parent, source.name + f"_compressed")
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
copy_unprocessed, force_compress, mimic_mode, hide_errors, webp_rgba, workers,
|
copy_unprocessed, force_compress, mimic_mode, hide_errors, webp_rgba, workers,
|
||||||
|
@ -93,17 +96,17 @@ class Params:
|
||||||
parser.add_argument("-nm", "--no-mimic", dest='mimic', action='store_false', help="Disable mimic mode")
|
parser.add_argument("-nm", "--no-mimic", dest='mimic', action='store_false', help="Disable mimic mode")
|
||||||
parser.add_argument("-v", "--show_errors", action='store_false', help="Show recode errors")
|
parser.add_argument("-v", "--show_errors", action='store_false', help="Show recode errors")
|
||||||
parser.add_argument("--webp-rgb", dest='webp_rgba', action='store_false', help="Recode .webp without alpha channel")
|
parser.add_argument("--webp-rgb", dest='webp_rgba', action='store_false', help="Recode .webp without alpha channel")
|
||||||
parser.add_argument("-j", "--jobs", type=int, help="Number of threads", default=16)
|
parser.add_argument("-j", "--jobs", type=int, help="Number of threads (default: 16)", default=16)
|
||||||
parser.add_argument("-ae", dest="a_ext", help="Audio extension", default="opus")
|
parser.add_argument("-ae", dest="a_ext", help="Audio extension (default: opus)", default="opus")
|
||||||
parser.add_argument("-ab", dest="a_bit", help="Audio bit rate", default="128k")
|
parser.add_argument("-ab", dest="a_bit", help="Audio bit rate (default: 128k)", default="128k")
|
||||||
parser.add_argument("-id", dest="i_down", type=int, help="Image resolution downscale multiplier", default=1)
|
parser.add_argument("-id", dest="i_down", type=float, help="Image resolution downscale multiplier (default: 1)", default=1)
|
||||||
parser.add_argument("-ie", dest="i_ext", help="Image extension", default="avif")
|
parser.add_argument("-ie", dest="i_ext", help="Image extension (default: avif)", default="avif")
|
||||||
parser.add_argument("-ife", dest="i_fallext", help="Image fallback extension", default="webp")
|
parser.add_argument("-ife", dest="i_fallext", help="Image fallback extension (default: webp)", default="webp")
|
||||||
parser.add_argument("-il", dest='i_lossless', action='store_false', help="Image losing compression mode")
|
parser.add_argument("-il", dest='i_lossless', action='store_false', help="Image losing compression mode")
|
||||||
parser.add_argument("-iq", dest="i_quality", type=int, help="Image quality", default=100)
|
parser.add_argument("-iq", dest="i_quality", type=int, help="Image quality (default: 100)", default=100)
|
||||||
parser.add_argument("--v_crf", help="Video CRF number", type=int, default=27)
|
parser.add_argument("--v_crf", help="Video CRF number (default: 27)", type=int, default=27)
|
||||||
parser.add_argument("-vs", dest="v_skip", action='store_true', help="Skip video recoding")
|
parser.add_argument("-vs", dest="v_skip", action='store_true', help="Skip video recoding")
|
||||||
parser.add_argument("-ve", dest="v_ext", help="Video extension", default="webm")
|
parser.add_argument("-ve", dest="v_ext", help="Video extension (default: webm)", default="webm")
|
||||||
parser.add_argument("-vc", dest="v_codec", help="Video codec name", default="libvpx-vp9")
|
parser.add_argument("-vc", dest="v_codec", help="Video codec name (default: libvpx-vp9)", default="libvpx-vp9")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
|
@ -16,7 +16,7 @@ class Printer:
|
||||||
file_count = 0
|
file_count = 0
|
||||||
for folder, folders, file in os.walk(source):
|
for folder, folders, file in os.walk(source):
|
||||||
file_count += len(file)
|
file_count += len(file)
|
||||||
self.bar = IncrementalBar('Compressing', max=file_count, suffix='[%(index)d/%(max)d] (%(percent).1f%%)')
|
self.bar = IncrementalBar('Recoding', max=file_count, suffix='[%(index)d/%(max)d] (%(percent).1f%%)')
|
||||||
self.bar.update()
|
self.bar.update()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue