Compare commits

...

270 Commits
v6.6 ... main

Author SHA1 Message Date
1baec22b5c Fix error message when using ffmpeg git version 2025-01-04 11:07:29 +01:00
dbf77c2ea6 Static build with Makefiles 2024-11-25 13:11:53 +01:00
4986242219 README.md 2024-08-17 12:57:20 +02:00
2b84f9db3b README.md 2024-07-18 17:10:59 +02:00
ecda4e59d6 Update doc 2024-05-01 11:26:47 +02:00
5f02d5bc69 README.md (v8.5) 2024-01-04 15:59:02 +01:00
a7dcddeaf9 Bump up version number to 8.5 2024-01-04 15:56:11 +01:00
873e9156ba Fix error messages on MacOS 2023-11-06 20:07:07 +01:00
348a1550e8 Fix error messages on MacOS 2023-11-06 19:38:49 +01:00
8b758765a6 Fix wrappers for Homebrew 2023-11-02 20:21:56 +01:00
68ceaadb04 README.md 2023-11-02 19:46:53 +01:00
2ca3dc16d5 Fix error message without Linux Homebrew installed 2023-11-02 19:45:59 +01:00
4b4c314d88 README.md 2023-11-01 21:08:36 +01:00
158085ce20 README.md 2023-11-01 21:05:52 +01:00
be7063cfd5 Add Makefile for MacOS Homebrew 2023-11-01 21:00:33 +01:00
7699d01b0c Add support for MacOS Homebrew 2023-11-01 20:54:07 +01:00
be3ebf6f02 Makefile.linuxbrew 2023-11-01 20:34:30 +01:00
771cd06af6 Add support for Linux Homebrew 2023-11-01 20:28:02 +01:00
bbc9846adf Add support for Linux Homebrew 2023-11-01 20:24:52 +01:00
d4cc9909ee Fix detect resolution with two or more video tracks 2023-05-26 18:36:36 +02:00
6fc7c1a692 Add bc alias for Cygwin 2023-05-22 17:10:28 +02:00
1c92e6b74b Fix checksum test (ks-upr) 2023-05-22 16:45:30 +02:00
14a4dc6747 README.md (Add bc dependency) 2023-05-22 16:15:35 +02:00
a7015d228b Change calc command for bc 2023-05-22 16:13:52 +02:00
e2e801e741 Added function for detecting proper resolution scaling 2023-05-22 15:31:27 +02:00
bb45e2fe88 Change default settings for ks-mp4 2023-03-19 12:32:55 +01:00
7f5df78576 Fix reset config for ks-av1(s) 2023-03-18 22:25:55 +01:00
b4a88231a5 Show errors with recursive checksum 2023-03-13 18:20:16 +01:00
c7de69f2c4 Fix text for error message 2023-03-13 18:07:40 +01:00
e57c79f92f Add checksum for recursive upload (ks-upr) 2023-03-13 18:03:25 +01:00
c0b2101435 Update documentation 2023-03-12 19:03:35 +01:00
8c39912218 Setting scp-pem as default when select certificate (ks-upv/upa/upf/upr) 2023-03-12 19:01:23 +01:00
5c384a0350 Change upload tool when select password 2023-03-12 18:51:03 +01:00
e054341701 Change upload tool when select certificate 2023-03-12 18:47:26 +01:00
faead28243 Cancel configuration if certificate is invalid (ks-upv/upa/upf/upr) 2023-03-12 18:32:32 +01:00
f5f32b9208 Change title text 2023-03-12 18:10:42 +01:00
1986d7ff94 Change title text 2023-03-12 18:09:39 +01:00
0904ffc312 Fix video & audio track detection (wrappers) 2023-03-12 15:33:06 +01:00
49e6641085 Update README.md 2023-03-12 15:08:05 +01:00
935c590dfa Set the correct permissions to the pem file (ks-upv/upa/upf/upr) 2023-03-12 15:05:07 +01:00
906cb000d9 Assign the correct permissions to the pem file when importing it (ks-upv/upa/upf/upr) 2023-03-12 15:01:04 +01:00
147753c1a0 Bump up version number to 8.5-dev 2023-03-12 14:52:54 +01:00
26cabcda89 Bump up version number to 8.4 2023-03-11 18:46:17 +01:00
1dc9297491 Update documentation 2023-03-11 15:46:16 +01:00
438afccf7a README.md 2023-03-11 14:37:58 +01:00
85845c59c7 Add support for connect using pem certificate (ks-upv/upa/upf/upr) 2023-03-11 14:36:57 +01:00
f84e808df3 Fix function to generate certificate on remote machine (ks-up*) 2023-03-11 13:04:25 +01:00
1682255e62 Added option to generate certificate on remote machine (ks-up*) 2023-03-11 12:49:52 +01:00
2ce46a33a4 Remove parameter -async 1 (ks-crop) 2023-03-11 12:25:21 +01:00
d25a15babb Support for H265 HDR conversion to H264 (ks-mix) 2023-03-11 12:24:34 +01:00
8e1b7e01e3 Change name for output folder 2023-03-10 20:58:36 +01:00
ddf3080d68 Update Makefiles 2023-03-10 20:54:45 +01:00
b4f408f634 Fix load profile with libsvtav1 codec (ks-av1s) 2023-03-10 20:54:32 +01:00
2d85f66888 Add support for ks-av1(s) from ks-conf tool 2023-03-10 20:46:10 +01:00
36ac1bed0c Update README.md 2023-03-10 20:25:47 +01:00
c7bfcf62a7 Add tool ks-av1s-folder 2023-03-10 20:23:20 +01:00
b19b714e88 Update Makefiles 2023-03-10 20:18:04 +01:00
6109e960b4 Add doc for ks-av1(s)-wrapper 2023-03-10 20:12:29 +01:00
09958c2a0a Fix load config variables (wrappers) 2023-03-10 20:09:19 +01:00
15c1245441 Add ks-av1(s)-wrapper 2023-03-10 20:04:49 +01:00
8aa97437e4 README.md 2023-03-10 19:54:32 +01:00
caa5bfe080 README.md 2023-03-10 19:46:37 +01:00
3cc479b994 Makefile.Cygwin 2023-03-10 18:54:41 +01:00
a6818a633c Add script for build ffmpeg on Cygwin x86_64 2023-03-10 18:53:35 +01:00
cd5bd77f9f Remove files 2023-03-10 18:45:39 +01:00
03192865cc Makefile 2023-03-10 18:43:44 +01:00
c514d44588 README.md 2023-03-10 00:35:32 +01:00
ee762b4025 Update Makefile 2023-03-10 00:32:46 +01:00
c35d7d322f Add documentation for ks-av1/ks-av1s 2023-03-10 00:22:58 +01:00
c7cd5db478 Update date for ks-av1/ks-av1s 2023-03-10 00:15:49 +01:00
7518d0bc3b Add ks-av1 & ks-av1s tools 2023-03-10 00:14:18 +01:00
af1c6ded2b Fixed video profile for different codecs 2023-03-07 23:16:12 +01:00
e5de2ca52e Remove year from title metadata (ks-mp4s) 2023-02-24 18:08:47 +01:00
f23a215a10 Fix subtitle error of last commit 2023-02-20 18:38:07 +01:00
fddfa1bd9d Add support for convert to h264 from h265 HDR (ks-mp4/s/k) 2023-02-20 00:03:32 +01:00
4236268df1 Add support for convert to h264 from h265 HDR (ks-mp4/s/k) 2023-02-20 00:00:42 +01:00
035842912e Add ssh-keyscan dependency (ks-upv/upa/upr/upf) 2023-02-13 19:41:22 +01:00
c9af167626 Add function to check all dependencies 2023-02-13 19:27:56 +01:00
aa794ea621 Remove sleep for scanning 2023-02-12 13:10:18 +01:00
53fedec45c Rewrite function for check dependencies (ks-upv/upa/upf/upr) 2023-02-12 13:07:50 +01:00
79752b15c5 Fix fail recursive upload using scp + expect (ks-upr) 2023-02-11 17:00:29 +01:00
8c2aa0f375 Fix IFS unset 2023-02-11 14:46:48 +01:00
8f47ebabed Fix fps_mode parameter with old ffmpeg releases 2023-02-11 14:33:51 +01:00
400318bdb4 Update documentation 2023-02-10 18:48:25 +01:00
c9aa8b2d37 Update deprecated -vsync to -fps_mode 2023-02-10 18:38:08 +01:00
573f92e978 Update date for last change 2023-02-10 18:30:24 +01:00
ea2629c2a5 Add support for using expect for login uploads (ks-upv/upf/upa/upr) 2023-02-10 18:28:20 +01:00
7d507549b8 Bump up version number to 8.4-dev 2023-02-10 13:24:07 +01:00
7f90051d4a Bump up version number to 8.4-dev 2023-02-10 13:20:13 +01:00
1e27c06547 Remove check_fingerprint function (ks-upX) 2023-02-10 13:11:36 +01:00
20b928a291 Makefile.Cygwin 2023-02-08 19:34:45 +01:00
94791c7f4f Update Makefile 2023-02-08 19:34:33 +01:00
ae216ccee7 Remove disabled ks-zui 2023-02-08 19:22:03 +01:00
2d25717acb Disable x264opts colorprim=bt2020:colormatrix=bt2020nc:transfer=smpte2084:chromaloc=2 2023-02-08 19:19:17 +01:00
c128723a1c Default slow preset for ks-mp4s (config) 2023-02-08 18:56:12 +01:00
9ff3034b05 Default slow preset for ks-mp4s 2023-02-08 18:53:32 +01:00
30132339f4 Update documentation 2022-10-12 13:17:48 +02:00
80badbf796 Update ks-tools packages links 2022-10-12 13:13:20 +02:00
q3aql
5736ddc91b Update Makefile 2022-04-21 21:07:36 +02:00
q3aql
ea7bd033e6 Script for rename ffmpeg to ffmpeg-av (My build for Arch Linux) 2022-04-21 21:03:27 +02:00
q3aql
2f21131b80 Change aresample to soft (squeeze/stretch) compensation 2022-04-21 20:41:30 +02:00
q3aql
6dad9f9318 Update README.md 2022-03-26 23:12:06 +01:00
q3aql
318bd98a2d Update doc 2022-03-26 14:53:14 +01:00
q3aql
41359771de README.md (v8.3.1) 2022-02-04 17:14:38 +01:00
q3aql
83c0343b5a Bump up version number to 8.3.1 2022-02-04 17:07:26 +01:00
q3aql
fec69289f8 Update vsync syntax (ks-mix) 2022-02-04 16:26:11 +01:00
q3aql
de8d05135e Fix fail to crop video with audio filter (ks-crop) 2022-02-04 16:25:16 +01:00
q3aql
4fe9b2a15d README.md (v8.3) 2022-01-28 19:02:13 +01:00
q3aql
a8bc1002ae Bump up version number to 8.3 2022-01-28 18:52:21 +01:00
q3aql
7af70dccf6 Fixed failure to display cut-off time (ks-mix) 2022-01-28 18:42:06 +01:00
q3aql
6e35a2a980 Text for entering the password is changed 2022-01-28 18:15:10 +01:00
q3aql
442dd14096 Update Makefile 2022-01-28 18:10:38 +01:00
q3aql
fbfb4c5969 Added error checking when defining time (ks-mix) 2022-01-28 18:05:25 +01:00
q3aql
cdb03d2157 Fix help info (ks-mix) 2022-01-28 16:49:19 +01:00
q3aql
dcbd799252 Update documentation 2022-01-25 20:21:47 +01:00
q3aql
8de980a6fc Add option for set port connection 2022-01-25 20:11:59 +01:00
q3aql
36535837e2 Fix info comment 2022-01-23 00:09:05 +01:00
q3aql
36fee80af7 Add option for legacy RSA Algorithm 2022-01-23 00:04:06 +01:00
q3aql
209c2167ab Add option for legacy RSA Algorithm 2022-01-23 00:03:17 +01:00
q3aql
9e970d5e37 README.md (v8.2) 2022-01-22 12:59:00 +01:00
q3aql
82da7c0b6d Bump up version number to 8.2 2022-01-22 12:52:37 +01:00
q3aql
3599bb9b38 Update Makefile 2022-01-22 12:38:54 +01:00
q3aql
d1f62b05a4 Update files-here.txt 2022-01-22 12:30:59 +01:00
q3aql
bacd8bb33a Update Makefile 2022-01-22 12:22:27 +01:00
q3aql
994aaa64e5 Add more detection format extensions 2022-01-22 12:13:28 +01:00
q3aql
e2f294877c Add check first connection to save fingerprint 2022-01-22 11:42:42 +01:00
q3aql
573a691fac Update documentation 2022-01-22 00:10:10 +01:00
q3aql
32a70bfeed Add more dependencies commands 2022-01-21 23:55:41 +01:00
q3aql
ef0ca8219e Show message if you use scp 2022-01-21 23:41:16 +01:00
q3aql
d2e28f22e6 Update documentation 2022-01-21 22:59:30 +01:00
q3aql
9253822184 Remove temp files 2022-01-21 22:50:47 +01:00
q3aql
27552047a8 Fix alias variable (ks-upr) 2022-01-21 22:50:16 +01:00
q3aql
65ce82f437 Remove temp files 2022-01-21 22:20:50 +01:00
q3aql
620ee69b65 Fix recursive upload with Cygwin 2022-01-21 22:19:41 +01:00
q3aql
2c034253b4 Fix upload & checksum fail with Cygwin (for Windows) 2022-01-21 22:06:47 +01:00
q3aql
9fc9c42f1a Add option for select scp or rsync for upload 2022-01-21 21:22:01 +01:00
q3aql
27a636b32c
Update README.md 2022-01-19 20:55:54 +01:00
q3aql
b9ec1ccda0 Update README.md (FFmpeg URL builds) 2022-01-19 19:57:53 +01:00
q3aql
393960c9c4 Update documentation (ks-crop) 2022-01-18 21:28:53 +01:00
q3aql
524ae47774 Update documentation (ks-crop) 2022-01-18 21:28:06 +01:00
q3aql
25068647bb Update documentation 2022-01-18 21:25:57 +01:00
q3aql
21520f4b83 Update documentation 2022-01-18 20:56:36 +01:00
q3aql
a255c296bf Update vsync & async syntax 2022-01-18 20:53:03 +01:00
q3aql
ac485f2139 README.md (v8.1) 2022-01-04 12:54:30 +01:00
q3aql
d32bec8f5b Bump up version number to 8.1 2022-01-04 12:35:09 +01:00
q3aql
7e07cae7fe Ask for confirmation before deleting the configuration 2022-01-04 12:10:33 +01:00
q3aql
7910ba6dc9 Add option for create configuration without upload directly 2022-01-04 11:58:24 +01:00
q3aql
90c373df23 Fix ISO Codes URL && add info for bitrate (ks-conf) 2022-01-04 11:22:17 +01:00
q3aql
3fbf90c630 Update documentation 2022-01-03 19:34:53 +01:00
q3aql
3c11961951 Check and migrate old configuration 2022-01-03 19:31:11 +01:00
q3aql
e1f657c6be Change config files for upload tools 2022-01-03 19:06:15 +01:00
q3aql
e6c738fc38 Remove dependencies for cygwin version 2022-01-02 19:10:35 +01:00
q3aql
65530e8796 Fix error reading config file (ks-conf) 2022-01-02 19:07:06 +01:00
q3aql
7c0ea17a11 Update README.md (v8.0) 2022-01-02 18:14:57 +01:00
q3aql
d2a79efa85 Bump up version number to 8.0 2022-01-02 18:14:43 +01:00
q3aql
d6a0385270 Bump up version number to 8.0 2022-01-02 17:20:24 +01:00
q3aql
75cd8bc8cc Update script for dependencies on Cygwin 2022-01-02 17:02:55 +01:00
q3aql
4e37689196 Update documentation 2022-01-02 16:47:57 +01:00
q3aql
19fd44fe58 Update README.md (ks-conf.md) 2022-01-02 16:39:06 +01:00
q3aql
d0fe75be0b Add doc for ks-conf 2022-01-02 16:35:47 +01:00
q3aql
93c8a858fc Add doc for ks-conf 2022-01-02 16:34:44 +01:00
q3aql
e69a8009b7 Update Makefile 2022-01-02 15:36:54 +01:00
q3aql
ee1eb401c1 Add tool for editing all configs 2022-01-02 15:30:48 +01:00
q3aql
74f8efc496 Update documentation 2022-01-02 12:28:09 +01:00
q3aql
f6664328ec Update documentation 2022-01-02 12:25:43 +01:00
q3aql
72c83f80e5 Read configuration from file on ~/.ks-tools/ 2022-01-02 12:17:53 +01:00
q3aql
27656677d3 Read configuration from file on ~/.ks-tools/ 2022-01-02 12:03:27 +01:00
q3aql
b8a51234bf
Update ks-mix.md 2021-08-03 15:30:48 +02:00
q3aql
3834c7a06c
Fix word on README.md 2021-08-03 15:16:16 +02:00
q3aql
809e9bbfc1 README.md (v7.3) 2021-05-03 01:26:05 +02:00
q3aql
015d1d6554 Bump up version number to 7.3 2021-05-03 01:10:00 +02:00
q3aql
af4f06f60f Update Windows instructions (README.md) 2021-05-03 00:58:16 +02:00
q3aql
511ca677ef Add alias for Cygwin drives 2021-04-23 22:39:51 +02:00
q3aql
44b881009c Fix bad messages (ks-mix) 2021-04-23 22:31:05 +02:00
q3aql
4f836e1820 Fix vsync & async (ks-avi) 2021-04-18 00:37:12 +02:00
q3aql
1767635a45 Add tabs (doc) 2021-04-18 00:33:15 +02:00
q3aql
61c1e0e26a Fix doc 2021-04-18 00:27:13 +02:00
q3aql
f0e53425b1 Update all doc 2021-04-18 00:21:59 +02:00
q3aql
b4edbae0ae Update README.md 2021-04-17 22:51:20 +02:00
q3aql
ccac3ec582 Fix ks-mix 2021-04-05 11:58:53 +02:00
q3aql
9f06fdce99 Crop video original color with H265 10-bit codec (ks-crop) 2021-04-05 11:58:34 +02:00
q3aql
8a01b8f2fb Preserve original color extracting H265 10-bit codec 2021-04-05 11:36:13 +02:00
q3aql
3f7edb95a2 Better conversion color from H265 10-bit to H264 8-bit 2021-04-05 11:21:47 +02:00
q3aql
ba59c1431e README.md (v7.2) 2021-03-30 18:42:04 +02:00
q3aql
a5d3552b42 Bump up version number to 7.2 2021-03-30 18:25:13 +02:00
q3aql
e6e3d843b3 Change resolution for IMAX crop (ks-crop) 2021-03-30 00:07:54 +02:00
q3aql
7fd5b59ae0 Set retries of send & checksum in 3 (ks-upv/upa/upf) 2021-03-29 18:26:37 +02:00
q3aql
80f6ed1bf4 Fix retry & checksum on cygwin (ks-upv/upa/upr) 2021-03-29 18:08:57 +02:00
q3aql
5e59548854 Fix bad word (ks-mix) 2021-03-28 23:04:06 +02:00
q3aql
5247cac8a3 Better indent in source code 2021-03-28 01:56:41 +01:00
q3aql
d13e30f881 README.md (v7.1) 2021-03-26 22:21:10 +01:00
q3aql
574b9c69ca
Update files-here.txt 2021-03-26 21:50:00 +01:00
q3aql
9b726564cd Bump up version number to 7.1 2021-03-26 21:04:55 +01:00
q3aql
7d0f1bcb58 More info with CMD installer for Windows/Cygwin 2021-03-26 20:56:21 +01:00
q3aql
b2a132be5d Add checking cygwin alias (for Windows) 2021-03-26 18:19:27 +01:00
q3aql
0502eb069c Cygwin alias script (for Windows) 2021-03-26 15:00:22 +01:00
q3aql
d6879b168c Fix bad syntax & example (ks-mp3/oga-album) 2021-03-26 14:55:03 +01:00
q3aql
798007c209 README.md (v7.0) 2021-03-25 16:55:25 +01:00
q3aql
33838caf9d Bump up version number to 7.0 2021-03-25 16:50:54 +01:00
q3aql
14935483fb Alias for Cygwin terminal 2021-03-25 16:25:42 +01:00
q3aql
ce3a10c7ca Makefile 2021-03-24 23:14:44 +01:00
q3aql
dc4d806837 Update documentation of ks-mix.md 2021-03-24 21:26:16 +01:00
q3aql
2a83767b81 Add function for extract video + audio from specific hour-minute-second 2021-03-24 21:14:56 +01:00
q3aql
51fffcd9b9 Add function for extract video or audio from specific hour-minute-second (ks-mix) 2021-03-24 21:02:27 +01:00
q3aql
b23ffa3246 Added generic solution if fail detection of resolution (ks-crop) 2021-03-24 18:05:57 +01:00
q3aql
2962e4aa1d Add calculate for ih crop height resolution (ks-crop) 2021-03-24 15:00:34 +01:00
q3aql
a5475fa128 Remove xterm dependency (README.md) 2021-03-23 17:52:28 +01:00
q3aql
417b1adc55 Improved error handling (ks-crop) 2021-03-23 17:49:13 +01:00
q3aql
5130508894 Change internal name variables (wrappers) 2021-03-23 16:07:59 +01:00
q3aql
b40171b74e Fix bad crop on 1080 height size (ks-crop) 2021-03-23 16:05:01 +01:00
q3aql
7f723e2b60 Update README.md (v6.9) 2021-03-23 14:12:02 +01:00
q3aql
800798f198 Bump up version number to 6.9 2021-03-23 14:05:48 +01:00
q3aql
9db05860b1 Add more resolution detection (ks-crop) 2021-03-23 13:57:17 +01:00
q3aql
dc4719c548 Xterm dependency removed 2021-03-23 11:49:30 +01:00
q3aql
7969ce9a52 Fix variable (ks-mix) 2021-03-23 11:40:22 +01:00
q3aql
fe6af909b9 Update ks-mix.md 2021-03-23 11:37:49 +01:00
q3aql
9590410a8e Change words from help (ks-mix) 2021-03-23 03:20:03 +01:00
q3aql
317602ae41 Better support for crop to 16:9 with different resolutions (ks-crop) 2021-03-23 02:15:13 +01:00
q3aql
d9577243a3 Add support for H265/MPEG4/Xvid source input (ks-mix) 2021-03-23 00:05:05 +01:00
q3aql
03eaa44b10 Fix bug with set bitrate (ks-crop) 2021-03-22 20:01:58 +01:00
q3aql
3f63b7cbfb Bug showing menu with bad syntax (ks-crop) 2021-03-22 19:55:32 +01:00
q3aql
b86b66de25 Fix name output file (ks-crop) 2021-03-22 19:52:47 +01:00
q3aql
c5a959a058 Fix bug with spaces name files (ks-crop) 2021-03-22 19:44:26 +01:00
q3aql
d6fdb87751 Bump up version number to 6.8 2021-03-22 19:16:53 +01:00
q3aql
6e72c968e6
Update README.md (v6.8) 2021-03-22 19:08:09 +01:00
q3aql
282091087d Update README.md (v6.8) 2021-03-22 19:05:30 +01:00
q3aql
4c1b6d0fbd Bump up version number to 6.8 2021-03-22 19:01:31 +01:00
q3aql
823f921e3d Fix doc/*.md 2021-03-22 18:43:19 +01:00
q3aql
4752bd2ffa Add ks-crop to Makefile 2021-03-22 18:37:33 +01:00
q3aql
af567583a3 Update README.md 2021-03-22 18:20:02 +01:00
q3aql
bd43d7c420 Add ks-crop.md doc 2021-03-22 18:17:56 +01:00
q3aql
a30ee7c5c8 Add tool for crop videos (ks-crop) 2021-03-22 17:52:11 +01:00
q3aql
0b6b9726fa
Update README.md (add rpm package 6.7) 2021-03-10 01:38:15 +01:00
q3aql
20d34ba2a8
Update README.md (v6.7) 2021-03-10 01:18:14 +01:00
q3aql
2251214fee
Up version to 6.7 (.bashrc) 2021-03-10 01:13:23 +01:00
q3aql
f9586be4e1
Up version to 6.7 (prompt Cygwin) 2021-03-10 01:13:01 +01:00
q3aql
39a1263077
Up version to 6.7 (prompt Cygwin) 2021-03-10 01:12:46 +01:00
q3aql
ffe67e00e2 Remove extension .flac,.wav,.opus from title detection 2021-03-10 01:04:48 +01:00
q3aql
a73c0dbd3d Up version to 6.7 2021-03-10 00:58:57 +01:00
q3aql
30c9e0c7ad Update ks-avi.md 2021-03-10 00:49:13 +01:00
q3aql
d456e347a9 Correct tab syntax (ks-avi) 2021-03-10 00:44:54 +01:00
q3aql
147ce556ef Update ks-avi.md 2021-03-10 00:40:30 +01:00
q3aql
eb549a966c Default preset slow & H265 detection (ks-avi) 2021-03-10 00:38:53 +01:00
q3aql
2294f62765 Correct tab syntax (ks-mp3/oga-album) 2021-03-09 13:05:03 +01:00
q3aql
ed963cbb37 Change tracks 5.1/7.1 to stereo (ks-mp3/oga-album) 2021-03-09 13:01:11 +01:00
q3aql
c276345ec6 Detect audio 5.1/7.1 & change to stereo (ks-mp3/oga) 2021-03-09 12:51:21 +01:00
q3aql
529db471c4 Add .ts format detection (ks-upf) 2021-03-09 10:47:19 +01:00
q3aql
f541bedaaf Add .ts format detection (ks-upv) 2021-03-09 10:46:57 +01:00
q3aql
cbc7910c29 Add .ts format detection (ks-mp4s-folder) 2021-03-09 10:46:33 +01:00
q3aql
cc41df4b4b Empty dirs for Cygwin/Windows 2021-03-08 01:52:13 +01:00
q3aql
7fb45cc52b Cygwin files 2021-03-08 01:50:04 +01:00
q3aql
a88b875013 Prompt files for Cygwin/Windows 2021-03-08 01:49:48 +01:00
q3aql
f1675da977 Run script ks-tools.cmd for Cygwin/Windows 2021-03-08 01:49:07 +01:00
q3aql
c3403d9132 Install.cmd for Cygwin/Windows 2021-03-08 01:48:34 +01:00
q3aql
1c7514934b Fix ks-mp3.md 2021-03-08 01:39:08 +01:00
q3aql
7b28d0166a Change CLI interface on ks-up* tools 2021-03-08 01:37:15 +01:00
q3aql
692c443802 Add more detection audio formats (ks-oga-album) 2021-03-08 00:29:24 +01:00
q3aql
34efd8b8d5 Add more detection audio formats (ks-mp3-album) 2021-03-08 00:28:27 +01:00
q3aql
f76c9ac562 Fix folder output name (ks-mp3-album) 2021-03-08 00:26:09 +01:00
q3aql
aae115fff8 Fix ks-mix.md 2021-03-08 00:23:43 +01:00
q3aql
e25582497a Doc for ks-mix 2021-03-08 00:21:24 +01:00
q3aql
432388dae8 Doc for audio convert tools 2021-03-07 21:24:26 +01:00
q3aql
7ab1aea83e Documentation for convert tools 2021-03-07 20:10:48 +01:00
q3aql
13760df938 Add more documentation 2021-03-07 19:10:24 +01:00
q3aql
7f39172f8b doc/ks-up*.md 2021-03-07 18:48:07 +01:00
q3aql
8eb08611f2 Fix URL Github on README.md 2021-03-07 18:43:28 +01:00
q3aql
230da45709 Add back button 2021-03-07 18:42:36 +01:00
q3aql
ec17637fd0 Fix documentation 2021-03-07 18:35:27 +01:00
q3aql
bb6e7f68da Upload tools documentation 2021-03-07 18:29:39 +01:00
q3aql
bae3df83a2
Update README.md 2021-03-06 21:26:39 +01:00
70 changed files with 15196 additions and 4592 deletions

285
Makefile
View File

@ -23,8 +23,14 @@ install:
chmod +x $(PREFIX)/bin/ks-mp4s
cp -rf src/ks-mp4s-folder $(PREFIX)/bin/ks-mp4s-folder
chmod +x $(PREFIX)/bin/ks-mp4s-folder
cp -rf src/ks-av1s-folder $(PREFIX)/bin/ks-av1s-folder
chmod +x $(PREFIX)/bin/ks-av1s-folder
cp -rf src/ks-vob $(PREFIX)/bin/ks-vob
chmod +x $(PREFIX)/bin/ks-vob
cp -rf src/ks-av1 $(PREFIX)/bin/ks-av1
chmod +x $(PREFIX)/bin/ks-av1
cp -rf src/ks-av1s $(PREFIX)/bin/ks-av1s
chmod +x $(PREFIX)/bin/ks-av1s
cp -rf src/ks-oga $(PREFIX)/bin/ks-oga
chmod +x $(PREFIX)/bin/ks-oga
cp -rf src/ks-mp3 $(PREFIX)/bin/ks-mp3
@ -35,6 +41,10 @@ install:
chmod +x $(PREFIX)/bin/ks-mp3-album
cp -rf src/ks-mix $(PREFIX)/bin/ks-mix
chmod +x $(PREFIX)/bin/ks-mix
cp -rf src/ks-crop $(PREFIX)/bin/ks-crop
chmod +x $(PREFIX)/bin/ks-crop
cp -rf src/ks-conf $(PREFIX)/bin/ks-conf
chmod +x $(PREFIX)/bin/ks-conf
cp -rf wrapper/ks-mp4-wrapper $(PREFIX)/bin/ks-mp4-wrapper
chmod +x $(PREFIX)/bin/ks-mp4-wrapper
cp -rf wrapper/ks-mp4k-wrapper $(PREFIX)/bin/ks-mp4k-wrapper
@ -45,19 +55,263 @@ install:
chmod +x $(PREFIX)/bin/ks-avi-wrapper
cp -rf wrapper/ks-vob-wrapper $(PREFIX)/bin/ks-vob-wrapper
chmod +x $(PREFIX)/bin/ks-vob-wrapper
cp -rf wrapper/ks-av1-wrapper $(PREFIX)/bin/ks-av1-wrapper
chmod +x $(PREFIX)/bin/ks-av1-wrapper
cp -rf wrapper/ks-av1s-wrapper $(PREFIX)/bin/ks-av1s-wrapper
chmod +x $(PREFIX)/bin/ks-av1s-wrapper
cp -rf cygwin/cygwin-path $(PREFIX)/bin/cygwin-path
chmod +x $(PREFIX)/bin/cygwin-path
mkdir -p $(PREFIX)/share/ks-tools
cp -rf prompt/ks-tools-rc $(PREFIX)/share/ks-tools
cp -rf prompt/ks-tools $(PREFIX)/share/ks-tools
cp -rf prompt/ks-tools-zui $(PREFIX)/share/ks-tools
cp -rf prompt/ks-tools.svg $(PREFIX)/share/ks-tools
cp -rf prompt/ks-tools.desktop $(PREFIX)/share/ks-tools
cp -rf prompt/ks-tools.desktop $(PREFIX)/share/applications
cp -rf prompt/ks-tools-zui.desktop $(PREFIX)/share/ks-tools
chmod +x $(PREFIX)/share/ks-tools/ks-tools
chmod +x $(PREFIX)/share/ks-tools/ks-tools-zui
compile:
mkdir -p build/
cp -rf src/ks-avi build
cp -rf src/ks-crop build
cp -rf src/ks-mix build
cp -rf src/ks-mp3 build
cp -rf src/ks-mp3-album build
cp -rf src/ks-mp4 build
cp -rf src/ks-mp4k build
cp -rf src/ks-mp4s build
cp -rf src/ks-mp4s-folder build
cp -rf src/ks-av1s-folder build
cp -rf src/ks-oga build
cp -rf src/ks-oga-album build
cp -rf src/ks-upa build
cp -rf src/ks-upf build
cp -rf src/ks-upr build
cp -rf src/ks-upv build
cp -rf src/ks-vob build
cp -rf src/ks-av1 build
cp -rf src/ks-av1s build
cp -rf src/ks-conf build
cp -rf wrapper/ks-avi-wrapper build
cp -rf wrapper/ks-mp4k-wrapper build
cp -rf wrapper/ks-mp4s-wrapper build
cp -rf wrapper/ks-mp4-wrapper build
cp -rf wrapper/ks-vob-wrapper build
cp -rf wrapper/ks-av1-wrapper build
cp -rf wrapper/ks-av1s-wrapper build
shc -rS -f build/ks-avi -o build/ks-avi.out
shc -rS -f build/ks-crop -o build/ks-crop.out
shc -rS -f build/ks-mix -o build/ks-mix.out
shc -rS -f build/ks-mp3 -o build/ks-mp3.out
shc -rS -f build/ks-mp3-album -o build/ks-mp3-album.out
shc -rS -f build/ks-mp4 -o build/ks-mp4.out
shc -rS -f build/ks-mp4k -o build/ks-mp4k.out
shc -rS -f build/ks-mp4s -o build/ks-mp4s.out
shc -rS -f build/ks-mp4s-folder -o build/ks-mp4s-folder.out
shc -rS -f build/ks-av1s-folder -o build/ks-av1s-folder.out
shc -rS -f build/ks-oga -o build/ks-oga.out
shc -rS -f build/ks-oga-album -o build/ks-oga-album.out
shc -rS -f build/ks-upa -o build/ks-upa.out
shc -rS -f build/ks-upf -o build/ks-upf.out
shc -rS -f build/ks-upr -o build/ks-upr.out
shc -rS -f build/ks-upv -o build/ks-upv.out
shc -rS -f build/ks-vob -o build/ks-vob.out
shc -rS -f build/ks-av1 -o build/ks-av1.out
shc -rS -f build/ks-av1s -o build/ks-av1s.out
shc -rS -f build/ks-conf -o build/ks-conf.out
shc -rS -f build/ks-avi-wrapper -o build/ks-avi-wrapper.out
shc -rS -f build/ks-mp4k-wrapper -o build/ks-mp4k-wrapper.out
shc -rS -f build/ks-mp4s-wrapper -o build/ks-mp4s-wrapper.out
shc -rS -f build/ks-mp4-wrapper -o build/ks-mp4-wrapper.out
shc -rS -f build/ks-vob-wrapper -o build/ks-vob-wrapper.out
shc -rS -f build/ks-av1-wrapper -o build/ks-av1-wrapper.out
shc -rS -f build/ks-av1s-wrapper -o build/ks-av1s-wrapper.out
rm -rf build/ks-avi.out
rm -rf build/ks-crop.out
rm -rf build/ks-mix.out
rm -rf build/ks-mp3.out
rm -rf build/ks-mp3-album.out
rm -rf build/ks-mp4.out
rm -rf build/ks-mp4k.out
rm -rf build/ks-mp4s.out
rm -rf build/ks-mp4s-folder.out
rm -rf build/ks-av1s-folder.out
rm -rf build/ks-oga.out
rm -rf build/ks-oga-album.out
rm -rf build/ks-upa.out
rm -rf build/ks-upf.out
rm -rf build/ks-upr.out
rm -rf build/ks-upv.out
rm -rf build/ks-vob.out
rm -rf build/ks-av1.out
rm -rf build/ks-av1s.out
rm -rf build/ks-conf.out
rm -rf build/ks-avi-wrapper.out
rm -rf build/ks-mp4k-wrapper.out
rm -rf build/ks-mp4s-wrapper.out
rm -rf build/ks-mp4-wrapper.out
rm -rf build/ks-vob-wrapper.out
rm -rf build/ks-av1-wrapper.out
rm -rf build/ks-av1s-wrapper.out
rm -rf build/ks-avi
rm -rf build/ks-crop
rm -rf build/ks-mix
rm -rf build/ks-mp3
rm -rf build/ks-mp3-album
rm -rf build/ks-mp4
rm -rf build/ks-mp4k
rm -rf build/ks-mp4s
rm -rf build/ks-mp4s-folder
rm -rf build/ks-av1s-folder
rm -rf build/ks-oga
rm -rf build/ks-oga-album
rm -rf build/ks-upa
rm -rf build/ks-upf
rm -rf build/ks-upr
rm -rf build/ks-upv
rm -rf build/ks-vob
rm -rf build/ks-conf
rm -rf build/ks-avi-wrapper
rm -rf build/ks-mp4k-wrapper
rm -rf build/ks-mp4s-wrapper
rm -rf build/ks-mp4-wrapper
rm -rf build/ks-vob-wrapper
rm -rf build/ks-av1-wrapper
rm -rf build/ks-av1s-wrapper
mv build/ks-avi.x.c build/ks-avi.c
mv build/ks-crop.x.c build/ks-crop.c
mv build/ks-mix.x.c build/ks-mix.c
mv build/ks-mp3.x.c build/ks-mp3.c
mv build/ks-mp3-album.x.c build/ks-mp3-album.c
mv build/ks-mp4.x.c build/ks-mp4.c
mv build/ks-mp4k.x.c build/ks-mp4k.c
mv build/ks-mp4s.x.c build/ks-mp4s.c
mv build/ks-mp4s-folder.x.c build/ks-mp4s-folder.c
mv build/ks-av1s-folder.x.c build/ks-av1s-folder.c
mv build/ks-oga.x.c build/ks-oga.c
mv build/ks-oga-album.x.c build/ks-oga-album.c
mv build/ks-upa.x.c build/ks-upa.c
mv build/ks-upf.x.c build/ks-upf.c
mv build/ks-upr.x.c build/ks-upr.c
mv build/ks-upv.x.c build/ks-upv.c
mv build/ks-vob.x.c build/ks-vob.c
mv build/ks-av1.x.c build/ks-av1.c
mv build/ks-av1s.x.c build/ks-av1s.c
mv build/ks-conf.x.c build/ks-conf.c
mv build/ks-avi-wrapper.x.c build/ks-avi-wrapper.c
mv build/ks-mp4k-wrapper.x.c build/ks-mp4k-wrapper.c
mv build/ks-mp4s-wrapper.x.c build/ks-mp4s-wrapper.c
mv build/ks-mp4-wrapper.x.c build/ks-mp4-wrapper.c
mv build/ks-vob-wrapper.x.c build/ks-vob-wrapper.c
mv build/ks-av1-wrapper.x.c build/ks-av1-wrapper.c
mv build/ks-av1s-wrapper.x.c build/ks-av1s-wrapper.c
gcc -static build/ks-avi.c -o build/ks-avi
gcc -static build/ks-avi-wrapper.c -o build/ks-avi-wrapper
gcc -static build/ks-crop.c -o build/ks-crop
gcc -static build/ks-mix.c -o build/ks-mix
gcc -static build/ks-mp3-album.c -o build/ks-mp3-album
gcc -static build/ks-mp3.c -o build/ks-mp3
gcc -static build/ks-mp4.c -o build/ks-mp4
gcc -static build/ks-mp4k.c -o build/ks-mp4k
gcc -static build/ks-mp4k-wrapper.c -o build/ks-mp4k-wrapper
gcc -static build/ks-mp4s.c -o build/ks-mp4s
gcc -static build/ks-mp4s-folder.c -o build/ks-mp4s-folder
gcc -static build/ks-av1s-folder.c -o build/ks-av1s-folder
gcc -static build/ks-mp4s-wrapper.c -o build/ks-mp4s-wrapper
gcc -static build/ks-mp4-wrapper.c -o build/ks-mp4-wrapper
gcc -static build/ks-oga-album.c -o build/ks-oga-album
gcc -static build/ks-oga.c -o build/ks-oga
gcc -static build/ks-upa.c -o build/ks-upa
gcc -static build/ks-upf.c -o build/ks-upf
gcc -static build/ks-upr.c -o build/ks-upr
gcc -static build/ks-upv.c -o build/ks-upv
gcc -static build/ks-vob.c -o build/ks-vob
gcc -static build/ks-av1.c -o build/ks-av1
gcc -static build/ks-av1s.c -o build/ks-av1s
gcc -static build/ks-conf.c -o build/ks-conf
gcc -static build/ks-vob-wrapper.c -o build/ks-vob-wrapper
gcc -static build/ks-av1-wrapper.c -o build/ks-av1-wrapper
gcc -static build/ks-av1s-wrapper.c -o build/ks-av1s-wrapper
compile-install:
cp -rf build/ks-upv $(PREFIX)/bin/ks-upv
chmod +x $(PREFIX)/bin/ks-upv
cp -rf build/ks-upa $(PREFIX)/bin/ks-upa
chmod +x $(PREFIX)/bin/ks-upa
cp -rf build/ks-upf $(PREFIX)/bin/ks-upf
chmod +x $(PREFIX)/bin/ks-upf
cp -rf build/ks-upr $(PREFIX)/bin/ks-upr
chmod +x $(PREFIX)/bin/ks-upr
cp -rf build/ks-avi $(PREFIX)/bin/ks-avi
chmod +x $(PREFIX)/bin/ks-avi
cp -rf build/ks-mp4 $(PREFIX)/bin/ks-mp4
chmod +x $(PREFIX)/bin/ks-mp4
cp -rf build/ks-mp4k $(PREFIX)/bin/ks-mp4k
chmod +x $(PREFIX)/bin/ks-mp4k
cp -rf build/ks-mp4s $(PREFIX)/bin/ks-mp4s
chmod +x $(PREFIX)/bin/ks-mp4s
cp -rf build/ks-mp4s-folder $(PREFIX)/bin/ks-mp4s-folder
chmod +x $(PREFIX)/bin/ks-mp4s-folder
cp -rf build/ks-av1s-folder $(PREFIX)/bin/ks-av1s-folder
chmod +x $(PREFIX)/bin/ks-av1s-folder
cp -rf build/ks-vob $(PREFIX)/bin/ks-vob
chmod +x $(PREFIX)/bin/ks-vob
cp -rf build/ks-av1 $(PREFIX)/bin/ks-av1
chmod +x $(PREFIX)/bin/ks-av1
cp -rf build/ks-av1s $(PREFIX)/bin/ks-av1s
chmod +x $(PREFIX)/bin/ks-av1s
cp -rf build/ks-oga $(PREFIX)/bin/ks-oga
chmod +x $(PREFIX)/bin/ks-oga
cp -rf build/ks-mp3 $(PREFIX)/bin/ks-mp3
chmod +x $(PREFIX)/bin/ks-mp3
cp -rf build/ks-oga-album $(PREFIX)/bin/ks-oga-album
chmod +x $(PREFIX)/bin/ks-oga-album
cp -rf build/ks-mp3-album $(PREFIX)/bin/ks-mp3-album
chmod +x $(PREFIX)/bin/ks-mp3-album
cp -rf build/ks-mix $(PREFIX)/bin/ks-mix
chmod +x $(PREFIX)/bin/ks-mix
cp -rf build/ks-crop $(PREFIX)/bin/ks-crop
chmod +x $(PREFIX)/bin/ks-crop
cp -rf build/ks-conf $(PREFIX)/bin/ks-conf
chmod +x $(PREFIX)/bin/ks-conf
cp -rf build/ks-mp4-wrapper $(PREFIX)/bin/ks-mp4-wrapper
chmod +x $(PREFIX)/bin/ks-mp4-wrapper
cp -rf build/ks-mp4k-wrapper $(PREFIX)/bin/ks-mp4k-wrapper
chmod +x $(PREFIX)/bin/ks-mp4k-wrapper
cp -rf build/ks-mp4s-wrapper $(PREFIX)/bin/ks-mp4s-wrapper
chmod +x $(PREFIX)/bin/ks-mp4s-wrapper
cp -rf build/ks-avi-wrapper $(PREFIX)/bin/ks-avi-wrapper
chmod +x $(PREFIX)/bin/ks-avi-wrapper
cp -rf build/ks-vob-wrapper $(PREFIX)/bin/ks-vob-wrapper
chmod +x $(PREFIX)/bin/ks-vob-wrapper
cp -rf build/ks-av1-wrapper $(PREFIX)/bin/ks-av1-wrapper
chmod +x $(PREFIX)/bin/ks-av1-wrapper
cp -rf build/ks-av1s-wrapper $(PREFIX)/bin/ks-av1s-wrapper
chmod +x $(PREFIX)/bin/ks-av1s-wrapper
cp -rf cygwin/cygwin-path $(PREFIX)/bin/cygwin-path
chmod +x $(PREFIX)/bin/cygwin-path
compile-clean:
rm -rf build/ks-avi
rm -rf build/ks-crop
rm -rf build/ks-mix
rm -rf build/ks-mp3
rm -rf build/ks-mp3-album
rm -rf build/ks-mp4
rm -rf build/ks-mp4k
rm -rf build/ks-mp4s
rm -rf build/ks-mp4s-folder
rm -rf build/ks-av1s-folder
rm -rf build/ks-oga
rm -rf build/ks-oga-album
rm -rf build/ks-upa
rm -rf build/ks-upf
rm -rf build/ks-upr
rm -rf build/ks-upv
rm -rf build/ks-vob
rm -rf build/ks-av1
rm -rf build/ks-av1s
rm -rf build/ks-conf
rm -rf build/ks-avi-wrapper
rm -rf build/ks-mp4k-wrapper
rm -rf build/ks-mp4s-wrapper
rm -rf build/ks-mp4-wrapper
rm -rf build/ks-vob-wrapper
rm -rf build/ks-av1-wrapper
rm -rf build/ks-av1s-wrapper
uninstall:
rm -rf $(PREFIX)/bin/ks-upv
rm -rf $(PREFIX)/bin/ks-upa
@ -68,17 +322,22 @@ uninstall:
rm -rf $(PREFIX)/bin/ks-mp4k
rm -rf $(PREFIX)/bin/ks-mp4s
rm -rf $(PREFIX)/bin/ks-mp4s-folder
rm -rf $(PREFIX)/bin/ks-av1s-folder
rm -rf $(PREFIX)/bin/ks-vob
rm -rf $(PREFIX)/bin/ks-av1
rm -rf $(PREFIX)/bin/ks-av1s
rm -rf $(PREFIX)/bin/ks-oga
rm -rf $(PREFIX)/bin/ks-oga-album
rm -rf $(PREFIX)/bin/ks-mp3
rm -rf $(PREFIX)/bin/ks-mp3-album
rm -rf $(PREFIX)/bin/ks-mix
rm -rf $(PREFIX)/bin/ks-crop
rm -rf $(PREFIX)/bin/ks-conf
rm -rf $(PREFIX)/bin/ks-mp4-wrapper
rm -rf $(PREFIX)/bin/ks-mp4k-wrapper
rm -rf $(PREFIX)/bin/ks-mp4s-wrapper
rm -rf $(PREFIX)/bin/ks-avi-wrapper
rm -rf $(PREFIX)/bin/ks-vob-wrapper
rm -rf $(PREFIX)/bin/ks-av1-wrapper
rm -rf $(PREFIX)/bin/ks-av1s-wrapper
rm -rf $(PREFIX)/bin/cygwin-path
rm -rf $(PREFIX)/share/ks-tools
rm -rf $(PREFIX)/share/applications/ks-tools.desktop

96
Makefile.Cygwin Executable file
View File

@ -0,0 +1,96 @@
##################################
# Installing ks-tools (Cygwin) #
##################################
PREFIX=/usr
install:
cp -rf src/ks-upv $(PREFIX)/bin/ks-upv
chmod +x $(PREFIX)/bin/ks-upv
cp -rf src/ks-upa $(PREFIX)/bin/ks-upa
chmod +x $(PREFIX)/bin/ks-upa
cp -rf src/ks-upf $(PREFIX)/bin/ks-upf
chmod +x $(PREFIX)/bin/ks-upf
cp -rf src/ks-upr $(PREFIX)/bin/ks-upr
chmod +x $(PREFIX)/bin/ks-upr
cp -rf src/ks-avi $(PREFIX)/bin/ks-avi
chmod +x $(PREFIX)/bin/ks-avi
cp -rf src/ks-mp4 $(PREFIX)/bin/ks-mp4
chmod +x $(PREFIX)/bin/ks-mp4
cp -rf src/ks-mp4k $(PREFIX)/bin/ks-mp4k
chmod +x $(PREFIX)/bin/ks-mp4k
cp -rf src/ks-mp4s $(PREFIX)/bin/ks-mp4s
chmod +x $(PREFIX)/bin/ks-mp4s
cp -rf src/ks-mp4s-folder $(PREFIX)/bin/ks-mp4s-folder
chmod +x $(PREFIX)/bin/ks-mp4s-folder
cp -rf src/ks-av1s-folder $(PREFIX)/bin/ks-av1s-folder
chmod +x $(PREFIX)/bin/ks-av1s-folder
cp -rf src/ks-vob $(PREFIX)/bin/ks-vob
chmod +x $(PREFIX)/bin/ks-vob
cp -rf src/ks-av1 $(PREFIX)/bin/ks-av1
chmod +x $(PREFIX)/bin/ks-av1
cp -rf src/ks-av1s $(PREFIX)/bin/ks-av1s
chmod +x $(PREFIX)/bin/ks-av1s
cp -rf src/ks-oga $(PREFIX)/bin/ks-oga
chmod +x $(PREFIX)/bin/ks-oga
cp -rf src/ks-mp3 $(PREFIX)/bin/ks-mp3
chmod +x $(PREFIX)/bin/ks-mp3
cp -rf src/ks-oga-album $(PREFIX)/bin/ks-oga-album
chmod +x $(PREFIX)/bin/ks-oga-album
cp -rf src/ks-mp3-album $(PREFIX)/bin/ks-mp3-album
chmod +x $(PREFIX)/bin/ks-mp3-album
cp -rf src/ks-mix $(PREFIX)/bin/ks-mix
chmod +x $(PREFIX)/bin/ks-mix
cp -rf src/ks-crop $(PREFIX)/bin/ks-crop
chmod +x $(PREFIX)/bin/ks-crop
cp -rf src/ks-conf $(PREFIX)/bin/ks-conf
chmod +x $(PREFIX)/bin/ks-conf
cp -rf wrapper/ks-mp4-wrapper $(PREFIX)/bin/ks-mp4-wrapper
chmod +x $(PREFIX)/bin/ks-mp4-wrapper
cp -rf wrapper/ks-mp4k-wrapper $(PREFIX)/bin/ks-mp4k-wrapper
chmod +x $(PREFIX)/bin/ks-mp4k-wrapper
cp -rf wrapper/ks-mp4s-wrapper $(PREFIX)/bin/ks-mp4s-wrapper
chmod +x $(PREFIX)/bin/ks-mp4s-wrapper
cp -rf wrapper/ks-avi-wrapper $(PREFIX)/bin/ks-avi-wrapper
chmod +x $(PREFIX)/bin/ks-avi-wrapper
cp -rf wrapper/ks-vob-wrapper $(PREFIX)/bin/ks-vob-wrapper
chmod +x $(PREFIX)/bin/ks-vob-wrapper
cp -rf wrapper/ks-av1-wrapper $(PREFIX)/bin/ks-av1-wrapper
chmod +x $(PREFIX)/bin/ks-av1-wrapper
cp -rf wrapper/ks-av1s-wrapper $(PREFIX)/bin/ks-av1s-wrapper
chmod +x $(PREFIX)/bin/ks-av1s-wrapper
cp -rf cygwin/cygwin-path $(PREFIX)/bin/cygwin-path
chmod +x $(PREFIX)/bin/cygwin-path
cp -rf cygwin/cygwin-alias.sh $(PREFIX)/bin
chmod +x $(PREFIX)/bin/cygwin-alias.sh
uninstall:
rm -rf $(PREFIX)/bin/ks-upv
rm -rf $(PREFIX)/bin/ks-upa
rm -rf $(PREFIX)/bin/ks-upf
rm -rf $(PREFIX)/bin/ks-upr
rm -rf $(PREFIX)/bin/ks-avi
rm -rf $(PREFIX)/bin/ks-mp4
rm -rf $(PREFIX)/bin/ks-mp4k
rm -rf $(PREFIX)/bin/ks-mp4s
rm -rf $(PREFIX)/bin/ks-mp4s-folder
rm -rf $(PREFIX)/bin/ks-av1s-folder
rm -rf $(PREFIX)/bin/ks-vob
rm -rf $(PREFIX)/bin/ks-av1
rm -rf $(PREFIX)/bin/ks-av1s
rm -rf $(PREFIX)/bin/ks-oga
rm -rf $(PREFIX)/bin/ks-oga-album
rm -rf $(PREFIX)/bin/ks-mp3
rm -rf $(PREFIX)/bin/ks-mp3-album
rm -rf $(PREFIX)/bin/ks-mix
rm -rf $(PREFIX)/bin/ks-crop
rm -rf $(PREFIX)/bin/ks-conf
rm -rf $(PREFIX)/bin/ks-mp4-wrapper
rm -rf $(PREFIX)/bin/ks-mp4k-wrapper
rm -rf $(PREFIX)/bin/ks-mp4s-wrapper
rm -rf $(PREFIX)/bin/ks-avi-wrapper
rm -rf $(PREFIX)/bin/ks-vob-wrapper
rm -rf $(PREFIX)/bin/ks-av1-wrapper
rm -rf $(PREFIX)/bin/ks-av1s-wrapper
rm -rf $(PREFIX)/bin/cygwin-path
rm -rf $(PREFIX)/bin/cygwin-alias.sh

343
Makefile.linuxbrew Executable file
View File

@ -0,0 +1,343 @@
#################################################
# Installing ks-tools (Linux Homebrew) #
#################################################
PREFIX=/home/linuxbrew/.linuxbrew
install:
cp -rf src/ks-upv $(PREFIX)/bin/ks-upv
chmod +x $(PREFIX)/bin/ks-upv
cp -rf src/ks-upa $(PREFIX)/bin/ks-upa
chmod +x $(PREFIX)/bin/ks-upa
cp -rf src/ks-upf $(PREFIX)/bin/ks-upf
chmod +x $(PREFIX)/bin/ks-upf
cp -rf src/ks-upr $(PREFIX)/bin/ks-upr
chmod +x $(PREFIX)/bin/ks-upr
cp -rf src/ks-avi $(PREFIX)/bin/ks-avi
chmod +x $(PREFIX)/bin/ks-avi
cp -rf src/ks-mp4 $(PREFIX)/bin/ks-mp4
chmod +x $(PREFIX)/bin/ks-mp4
cp -rf src/ks-mp4k $(PREFIX)/bin/ks-mp4k
chmod +x $(PREFIX)/bin/ks-mp4k
cp -rf src/ks-mp4s $(PREFIX)/bin/ks-mp4s
chmod +x $(PREFIX)/bin/ks-mp4s
cp -rf src/ks-mp4s-folder $(PREFIX)/bin/ks-mp4s-folder
chmod +x $(PREFIX)/bin/ks-mp4s-folder
cp -rf src/ks-av1s-folder $(PREFIX)/bin/ks-av1s-folder
chmod +x $(PREFIX)/bin/ks-av1s-folder
cp -rf src/ks-vob $(PREFIX)/bin/ks-vob
chmod +x $(PREFIX)/bin/ks-vob
cp -rf src/ks-av1 $(PREFIX)/bin/ks-av1
chmod +x $(PREFIX)/bin/ks-av1
cp -rf src/ks-av1s $(PREFIX)/bin/ks-av1s
chmod +x $(PREFIX)/bin/ks-av1s
cp -rf src/ks-oga $(PREFIX)/bin/ks-oga
chmod +x $(PREFIX)/bin/ks-oga
cp -rf src/ks-mp3 $(PREFIX)/bin/ks-mp3
chmod +x $(PREFIX)/bin/ks-mp3
cp -rf src/ks-oga-album $(PREFIX)/bin/ks-oga-album
chmod +x $(PREFIX)/bin/ks-oga-album
cp -rf src/ks-mp3-album $(PREFIX)/bin/ks-mp3-album
chmod +x $(PREFIX)/bin/ks-mp3-album
cp -rf src/ks-mix $(PREFIX)/bin/ks-mix
chmod +x $(PREFIX)/bin/ks-mix
cp -rf src/ks-crop $(PREFIX)/bin/ks-crop
chmod +x $(PREFIX)/bin/ks-crop
cp -rf src/ks-conf $(PREFIX)/bin/ks-conf
chmod +x $(PREFIX)/bin/ks-conf
cp -rf wrapper/ks-mp4-wrapper $(PREFIX)/bin/ks-mp4-wrapper
chmod +x $(PREFIX)/bin/ks-mp4-wrapper
cp -rf wrapper/ks-mp4k-wrapper $(PREFIX)/bin/ks-mp4k-wrapper
chmod +x $(PREFIX)/bin/ks-mp4k-wrapper
cp -rf wrapper/ks-mp4s-wrapper $(PREFIX)/bin/ks-mp4s-wrapper
chmod +x $(PREFIX)/bin/ks-mp4s-wrapper
cp -rf wrapper/ks-avi-wrapper $(PREFIX)/bin/ks-avi-wrapper
chmod +x $(PREFIX)/bin/ks-avi-wrapper
cp -rf wrapper/ks-vob-wrapper $(PREFIX)/bin/ks-vob-wrapper
chmod +x $(PREFIX)/bin/ks-vob-wrapper
cp -rf wrapper/ks-av1-wrapper $(PREFIX)/bin/ks-av1-wrapper
chmod +x $(PREFIX)/bin/ks-av1-wrapper
cp -rf wrapper/ks-av1s-wrapper $(PREFIX)/bin/ks-av1s-wrapper
chmod +x $(PREFIX)/bin/ks-av1s-wrapper
cp -rf cygwin/cygwin-path $(PREFIX)/bin/cygwin-path
chmod +x $(PREFIX)/bin/cygwin-path
compile:
mkdir -p build/
cp -rf src/ks-avi build
cp -rf src/ks-crop build
cp -rf src/ks-mix build
cp -rf src/ks-mp3 build
cp -rf src/ks-mp3-album build
cp -rf src/ks-mp4 build
cp -rf src/ks-mp4k build
cp -rf src/ks-mp4s build
cp -rf src/ks-mp4s-folder build
cp -rf src/ks-av1s-folder build
cp -rf src/ks-oga build
cp -rf src/ks-oga-album build
cp -rf src/ks-upa build
cp -rf src/ks-upf build
cp -rf src/ks-upr build
cp -rf src/ks-upv build
cp -rf src/ks-vob build
cp -rf src/ks-av1 build
cp -rf src/ks-av1s build
cp -rf src/ks-conf build
cp -rf wrapper/ks-avi-wrapper build
cp -rf wrapper/ks-mp4k-wrapper build
cp -rf wrapper/ks-mp4s-wrapper build
cp -rf wrapper/ks-mp4-wrapper build
cp -rf wrapper/ks-vob-wrapper build
cp -rf wrapper/ks-av1-wrapper build
cp -rf wrapper/ks-av1s-wrapper build
shc -rS -f build/ks-avi -o build/ks-avi.out
shc -rS -f build/ks-crop -o build/ks-crop.out
shc -rS -f build/ks-mix -o build/ks-mix.out
shc -rS -f build/ks-mp3 -o build/ks-mp3.out
shc -rS -f build/ks-mp3-album -o build/ks-mp3-album.out
shc -rS -f build/ks-mp4 -o build/ks-mp4.out
shc -rS -f build/ks-mp4k -o build/ks-mp4k.out
shc -rS -f build/ks-mp4s -o build/ks-mp4s.out
shc -rS -f build/ks-mp4s-folder -o build/ks-mp4s-folder.out
shc -rS -f build/ks-av1s-folder -o build/ks-av1s-folder.out
shc -rS -f build/ks-oga -o build/ks-oga.out
shc -rS -f build/ks-oga-album -o build/ks-oga-album.out
shc -rS -f build/ks-upa -o build/ks-upa.out
shc -rS -f build/ks-upf -o build/ks-upf.out
shc -rS -f build/ks-upr -o build/ks-upr.out
shc -rS -f build/ks-upv -o build/ks-upv.out
shc -rS -f build/ks-vob -o build/ks-vob.out
shc -rS -f build/ks-av1 -o build/ks-av1.out
shc -rS -f build/ks-av1s -o build/ks-av1s.out
shc -rS -f build/ks-conf -o build/ks-conf.out
shc -rS -f build/ks-avi-wrapper -o build/ks-avi-wrapper.out
shc -rS -f build/ks-mp4k-wrapper -o build/ks-mp4k-wrapper.out
shc -rS -f build/ks-mp4s-wrapper -o build/ks-mp4s-wrapper.out
shc -rS -f build/ks-mp4-wrapper -o build/ks-mp4-wrapper.out
shc -rS -f build/ks-vob-wrapper -o build/ks-vob-wrapper.out
shc -rS -f build/ks-av1-wrapper -o build/ks-av1-wrapper.out
shc -rS -f build/ks-av1s-wrapper -o build/ks-av1s-wrapper.out
rm -rf build/ks-avi.out
rm -rf build/ks-crop.out
rm -rf build/ks-mix.out
rm -rf build/ks-mp3.out
rm -rf build/ks-mp3-album.out
rm -rf build/ks-mp4.out
rm -rf build/ks-mp4k.out
rm -rf build/ks-mp4s.out
rm -rf build/ks-mp4s-folder.out
rm -rf build/ks-av1s-folder.out
rm -rf build/ks-oga.out
rm -rf build/ks-oga-album.out
rm -rf build/ks-upa.out
rm -rf build/ks-upf.out
rm -rf build/ks-upr.out
rm -rf build/ks-upv.out
rm -rf build/ks-vob.out
rm -rf build/ks-av1.out
rm -rf build/ks-av1s.out
rm -rf build/ks-conf.out
rm -rf build/ks-avi-wrapper.out
rm -rf build/ks-mp4k-wrapper.out
rm -rf build/ks-mp4s-wrapper.out
rm -rf build/ks-mp4-wrapper.out
rm -rf build/ks-vob-wrapper.out
rm -rf build/ks-av1-wrapper.out
rm -rf build/ks-av1s-wrapper.out
rm -rf build/ks-avi
rm -rf build/ks-crop
rm -rf build/ks-mix
rm -rf build/ks-mp3
rm -rf build/ks-mp3-album
rm -rf build/ks-mp4
rm -rf build/ks-mp4k
rm -rf build/ks-mp4s
rm -rf build/ks-mp4s-folder
rm -rf build/ks-av1s-folder
rm -rf build/ks-oga
rm -rf build/ks-oga-album
rm -rf build/ks-upa
rm -rf build/ks-upf
rm -rf build/ks-upr
rm -rf build/ks-upv
rm -rf build/ks-vob
rm -rf build/ks-conf
rm -rf build/ks-avi-wrapper
rm -rf build/ks-mp4k-wrapper
rm -rf build/ks-mp4s-wrapper
rm -rf build/ks-mp4-wrapper
rm -rf build/ks-vob-wrapper
rm -rf build/ks-av1-wrapper
rm -rf build/ks-av1s-wrapper
mv build/ks-avi.x.c build/ks-avi.c
mv build/ks-crop.x.c build/ks-crop.c
mv build/ks-mix.x.c build/ks-mix.c
mv build/ks-mp3.x.c build/ks-mp3.c
mv build/ks-mp3-album.x.c build/ks-mp3-album.c
mv build/ks-mp4.x.c build/ks-mp4.c
mv build/ks-mp4k.x.c build/ks-mp4k.c
mv build/ks-mp4s.x.c build/ks-mp4s.c
mv build/ks-mp4s-folder.x.c build/ks-mp4s-folder.c
mv build/ks-av1s-folder.x.c build/ks-av1s-folder.c
mv build/ks-oga.x.c build/ks-oga.c
mv build/ks-oga-album.x.c build/ks-oga-album.c
mv build/ks-upa.x.c build/ks-upa.c
mv build/ks-upf.x.c build/ks-upf.c
mv build/ks-upr.x.c build/ks-upr.c
mv build/ks-upv.x.c build/ks-upv.c
mv build/ks-vob.x.c build/ks-vob.c
mv build/ks-av1.x.c build/ks-av1.c
mv build/ks-av1s.x.c build/ks-av1s.c
mv build/ks-conf.x.c build/ks-conf.c
mv build/ks-avi-wrapper.x.c build/ks-avi-wrapper.c
mv build/ks-mp4k-wrapper.x.c build/ks-mp4k-wrapper.c
mv build/ks-mp4s-wrapper.x.c build/ks-mp4s-wrapper.c
mv build/ks-mp4-wrapper.x.c build/ks-mp4-wrapper.c
mv build/ks-vob-wrapper.x.c build/ks-vob-wrapper.c
mv build/ks-av1-wrapper.x.c build/ks-av1-wrapper.c
mv build/ks-av1s-wrapper.x.c build/ks-av1s-wrapper.c
gcc -static build/ks-avi.c -o build/ks-avi
gcc -static build/ks-avi-wrapper.c -o build/ks-avi-wrapper
gcc -static build/ks-crop.c -o build/ks-crop
gcc -static build/ks-mix.c -o build/ks-mix
gcc -static build/ks-mp3-album.c -o build/ks-mp3-album
gcc -static build/ks-mp3.c -o build/ks-mp3
gcc -static build/ks-mp4.c -o build/ks-mp4
gcc -static build/ks-mp4k.c -o build/ks-mp4k
gcc -static build/ks-mp4k-wrapper.c -o build/ks-mp4k-wrapper
gcc -static build/ks-mp4s.c -o build/ks-mp4s
gcc -static build/ks-mp4s-folder.c -o build/ks-mp4s-folder
gcc -static build/ks-av1s-folder.c -o build/ks-av1s-folder
gcc -static build/ks-mp4s-wrapper.c -o build/ks-mp4s-wrapper
gcc -static build/ks-mp4-wrapper.c -o build/ks-mp4-wrapper
gcc -static build/ks-oga-album.c -o build/ks-oga-album
gcc -static build/ks-oga.c -o build/ks-oga
gcc -static build/ks-upa.c -o build/ks-upa
gcc -static build/ks-upf.c -o build/ks-upf
gcc -static build/ks-upr.c -o build/ks-upr
gcc -static build/ks-upv.c -o build/ks-upv
gcc -static build/ks-vob.c -o build/ks-vob
gcc -static build/ks-av1.c -o build/ks-av1
gcc -static build/ks-av1s.c -o build/ks-av1s
gcc -static build/ks-conf.c -o build/ks-conf
gcc -static build/ks-vob-wrapper.c -o build/ks-vob-wrapper
gcc -static build/ks-av1-wrapper.c -o build/ks-av1-wrapper
gcc -static build/ks-av1s-wrapper.c -o build/ks-av1s-wrapper
compile-install:
cp -rf build/ks-upv $(PREFIX)/bin/ks-upv
chmod +x $(PREFIX)/bin/ks-upv
cp -rf build/ks-upa $(PREFIX)/bin/ks-upa
chmod +x $(PREFIX)/bin/ks-upa
cp -rf build/ks-upf $(PREFIX)/bin/ks-upf
chmod +x $(PREFIX)/bin/ks-upf
cp -rf build/ks-upr $(PREFIX)/bin/ks-upr
chmod +x $(PREFIX)/bin/ks-upr
cp -rf build/ks-avi $(PREFIX)/bin/ks-avi
chmod +x $(PREFIX)/bin/ks-avi
cp -rf build/ks-mp4 $(PREFIX)/bin/ks-mp4
chmod +x $(PREFIX)/bin/ks-mp4
cp -rf build/ks-mp4k $(PREFIX)/bin/ks-mp4k
chmod +x $(PREFIX)/bin/ks-mp4k
cp -rf build/ks-mp4s $(PREFIX)/bin/ks-mp4s
chmod +x $(PREFIX)/bin/ks-mp4s
cp -rf build/ks-mp4s-folder $(PREFIX)/bin/ks-mp4s-folder
chmod +x $(PREFIX)/bin/ks-mp4s-folder
cp -rf build/ks-av1s-folder $(PREFIX)/bin/ks-av1s-folder
chmod +x $(PREFIX)/bin/ks-av1s-folder
cp -rf build/ks-vob $(PREFIX)/bin/ks-vob
chmod +x $(PREFIX)/bin/ks-vob
cp -rf build/ks-av1 $(PREFIX)/bin/ks-av1
chmod +x $(PREFIX)/bin/ks-av1
cp -rf build/ks-av1s $(PREFIX)/bin/ks-av1s
chmod +x $(PREFIX)/bin/ks-av1s
cp -rf build/ks-oga $(PREFIX)/bin/ks-oga
chmod +x $(PREFIX)/bin/ks-oga
cp -rf build/ks-mp3 $(PREFIX)/bin/ks-mp3
chmod +x $(PREFIX)/bin/ks-mp3
cp -rf build/ks-oga-album $(PREFIX)/bin/ks-oga-album
chmod +x $(PREFIX)/bin/ks-oga-album
cp -rf build/ks-mp3-album $(PREFIX)/bin/ks-mp3-album
chmod +x $(PREFIX)/bin/ks-mp3-album
cp -rf build/ks-mix $(PREFIX)/bin/ks-mix
chmod +x $(PREFIX)/bin/ks-mix
cp -rf build/ks-crop $(PREFIX)/bin/ks-crop
chmod +x $(PREFIX)/bin/ks-crop
cp -rf build/ks-conf $(PREFIX)/bin/ks-conf
chmod +x $(PREFIX)/bin/ks-conf
cp -rf build/ks-mp4-wrapper $(PREFIX)/bin/ks-mp4-wrapper
chmod +x $(PREFIX)/bin/ks-mp4-wrapper
cp -rf build/ks-mp4k-wrapper $(PREFIX)/bin/ks-mp4k-wrapper
chmod +x $(PREFIX)/bin/ks-mp4k-wrapper
cp -rf build/ks-mp4s-wrapper $(PREFIX)/bin/ks-mp4s-wrapper
chmod +x $(PREFIX)/bin/ks-mp4s-wrapper
cp -rf build/ks-avi-wrapper $(PREFIX)/bin/ks-avi-wrapper
chmod +x $(PREFIX)/bin/ks-avi-wrapper
cp -rf build/ks-vob-wrapper $(PREFIX)/bin/ks-vob-wrapper
chmod +x $(PREFIX)/bin/ks-vob-wrapper
cp -rf build/ks-av1-wrapper $(PREFIX)/bin/ks-av1-wrapper
chmod +x $(PREFIX)/bin/ks-av1-wrapper
cp -rf build/ks-av1s-wrapper $(PREFIX)/bin/ks-av1s-wrapper
chmod +x $(PREFIX)/bin/ks-av1s-wrapper
cp -rf cygwin/cygwin-path $(PREFIX)/bin/cygwin-path
chmod +x $(PREFIX)/bin/cygwin-path
compile-clean:
rm -rf build/ks-avi
rm -rf build/ks-crop
rm -rf build/ks-mix
rm -rf build/ks-mp3
rm -rf build/ks-mp3-album
rm -rf build/ks-mp4
rm -rf build/ks-mp4k
rm -rf build/ks-mp4s
rm -rf build/ks-mp4s-folder
rm -rf build/ks-av1s-folder
rm -rf build/ks-oga
rm -rf build/ks-oga-album
rm -rf build/ks-upa
rm -rf build/ks-upf
rm -rf build/ks-upr
rm -rf build/ks-upv
rm -rf build/ks-vob
rm -rf build/ks-av1
rm -rf build/ks-av1s
rm -rf build/ks-conf
rm -rf build/ks-avi-wrapper
rm -rf build/ks-mp4k-wrapper
rm -rf build/ks-mp4s-wrapper
rm -rf build/ks-mp4-wrapper
rm -rf build/ks-vob-wrapper
rm -rf build/ks-av1-wrapper
rm -rf build/ks-av1s-wrapper
uninstall:
rm -rf $(PREFIX)/bin/ks-upv
rm -rf $(PREFIX)/bin/ks-upa
rm -rf $(PREFIX)/bin/ks-upf
rm -rf $(PREFIX)/bin/ks-upr
rm -rf $(PREFIX)/bin/ks-avi
rm -rf $(PREFIX)/bin/ks-mp4
rm -rf $(PREFIX)/bin/ks-mp4k
rm -rf $(PREFIX)/bin/ks-mp4s
rm -rf $(PREFIX)/bin/ks-mp4s-folder
rm -rf $(PREFIX)/bin/ks-av1s-folder
rm -rf $(PREFIX)/bin/ks-vob
rm -rf $(PREFIX)/bin/ks-av1
rm -rf $(PREFIX)/bin/ks-av1s
rm -rf $(PREFIX)/bin/ks-oga
rm -rf $(PREFIX)/bin/ks-oga-album
rm -rf $(PREFIX)/bin/ks-mp3
rm -rf $(PREFIX)/bin/ks-mp3-album
rm -rf $(PREFIX)/bin/ks-mix
rm -rf $(PREFIX)/bin/ks-crop
rm -rf $(PREFIX)/bin/ks-conf
rm -rf $(PREFIX)/bin/ks-mp4-wrapper
rm -rf $(PREFIX)/bin/ks-mp4k-wrapper
rm -rf $(PREFIX)/bin/ks-mp4s-wrapper
rm -rf $(PREFIX)/bin/ks-avi-wrapper
rm -rf $(PREFIX)/bin/ks-vob-wrapper
rm -rf $(PREFIX)/bin/ks-av1-wrapper
rm -rf $(PREFIX)/bin/ks-av1s-wrapper
rm -rf $(PREFIX)/bin/cygwin-path

93
Makefile.macbrew Executable file
View File

@ -0,0 +1,93 @@
#################################################
# Installing ks-tools (Linux Homebrew) #
#################################################
PREFIX=/usr/local
install:
cp -rf src/ks-upv $(PREFIX)/bin/ks-upv
chmod +x $(PREFIX)/bin/ks-upv
cp -rf src/ks-upa $(PREFIX)/bin/ks-upa
chmod +x $(PREFIX)/bin/ks-upa
cp -rf src/ks-upf $(PREFIX)/bin/ks-upf
chmod +x $(PREFIX)/bin/ks-upf
cp -rf src/ks-upr $(PREFIX)/bin/ks-upr
chmod +x $(PREFIX)/bin/ks-upr
cp -rf src/ks-avi $(PREFIX)/bin/ks-avi
chmod +x $(PREFIX)/bin/ks-avi
cp -rf src/ks-mp4 $(PREFIX)/bin/ks-mp4
chmod +x $(PREFIX)/bin/ks-mp4
cp -rf src/ks-mp4k $(PREFIX)/bin/ks-mp4k
chmod +x $(PREFIX)/bin/ks-mp4k
cp -rf src/ks-mp4s $(PREFIX)/bin/ks-mp4s
chmod +x $(PREFIX)/bin/ks-mp4s
cp -rf src/ks-mp4s-folder $(PREFIX)/bin/ks-mp4s-folder
chmod +x $(PREFIX)/bin/ks-mp4s-folder
cp -rf src/ks-av1s-folder $(PREFIX)/bin/ks-av1s-folder
chmod +x $(PREFIX)/bin/ks-av1s-folder
cp -rf src/ks-vob $(PREFIX)/bin/ks-vob
chmod +x $(PREFIX)/bin/ks-vob
cp -rf src/ks-av1 $(PREFIX)/bin/ks-av1
chmod +x $(PREFIX)/bin/ks-av1
cp -rf src/ks-av1s $(PREFIX)/bin/ks-av1s
chmod +x $(PREFIX)/bin/ks-av1s
cp -rf src/ks-oga $(PREFIX)/bin/ks-oga
chmod +x $(PREFIX)/bin/ks-oga
cp -rf src/ks-mp3 $(PREFIX)/bin/ks-mp3
chmod +x $(PREFIX)/bin/ks-mp3
cp -rf src/ks-oga-album $(PREFIX)/bin/ks-oga-album
chmod +x $(PREFIX)/bin/ks-oga-album
cp -rf src/ks-mp3-album $(PREFIX)/bin/ks-mp3-album
chmod +x $(PREFIX)/bin/ks-mp3-album
cp -rf src/ks-mix $(PREFIX)/bin/ks-mix
chmod +x $(PREFIX)/bin/ks-mix
cp -rf src/ks-crop $(PREFIX)/bin/ks-crop
chmod +x $(PREFIX)/bin/ks-crop
cp -rf src/ks-conf $(PREFIX)/bin/ks-conf
chmod +x $(PREFIX)/bin/ks-conf
cp -rf wrapper/ks-mp4-wrapper $(PREFIX)/bin/ks-mp4-wrapper
chmod +x $(PREFIX)/bin/ks-mp4-wrapper
cp -rf wrapper/ks-mp4k-wrapper $(PREFIX)/bin/ks-mp4k-wrapper
chmod +x $(PREFIX)/bin/ks-mp4k-wrapper
cp -rf wrapper/ks-mp4s-wrapper $(PREFIX)/bin/ks-mp4s-wrapper
chmod +x $(PREFIX)/bin/ks-mp4s-wrapper
cp -rf wrapper/ks-avi-wrapper $(PREFIX)/bin/ks-avi-wrapper
chmod +x $(PREFIX)/bin/ks-avi-wrapper
cp -rf wrapper/ks-vob-wrapper $(PREFIX)/bin/ks-vob-wrapper
chmod +x $(PREFIX)/bin/ks-vob-wrapper
cp -rf wrapper/ks-av1-wrapper $(PREFIX)/bin/ks-av1-wrapper
chmod +x $(PREFIX)/bin/ks-av1-wrapper
cp -rf wrapper/ks-av1s-wrapper $(PREFIX)/bin/ks-av1s-wrapper
chmod +x $(PREFIX)/bin/ks-av1s-wrapper
cp -rf cygwin/cygwin-path $(PREFIX)/bin/cygwin-path
chmod +x $(PREFIX)/bin/cygwin-path
uninstall:
rm -rf $(PREFIX)/bin/ks-upv
rm -rf $(PREFIX)/bin/ks-upa
rm -rf $(PREFIX)/bin/ks-upf
rm -rf $(PREFIX)/bin/ks-upr
rm -rf $(PREFIX)/bin/ks-avi
rm -rf $(PREFIX)/bin/ks-mp4
rm -rf $(PREFIX)/bin/ks-mp4k
rm -rf $(PREFIX)/bin/ks-mp4s
rm -rf $(PREFIX)/bin/ks-mp4s-folder
rm -rf $(PREFIX)/bin/ks-av1s-folder
rm -rf $(PREFIX)/bin/ks-vob
rm -rf $(PREFIX)/bin/ks-av1
rm -rf $(PREFIX)/bin/ks-av1s
rm -rf $(PREFIX)/bin/ks-oga
rm -rf $(PREFIX)/bin/ks-oga-album
rm -rf $(PREFIX)/bin/ks-mp3
rm -rf $(PREFIX)/bin/ks-mp3-album
rm -rf $(PREFIX)/bin/ks-mix
rm -rf $(PREFIX)/bin/ks-crop
rm -rf $(PREFIX)/bin/ks-conf
rm -rf $(PREFIX)/bin/ks-mp4-wrapper
rm -rf $(PREFIX)/bin/ks-mp4k-wrapper
rm -rf $(PREFIX)/bin/ks-mp4s-wrapper
rm -rf $(PREFIX)/bin/ks-avi-wrapper
rm -rf $(PREFIX)/bin/ks-vob-wrapper
rm -rf $(PREFIX)/bin/ks-av1-wrapper
rm -rf $(PREFIX)/bin/ks-av1s-wrapper
rm -rf $(PREFIX)/bin/cygwin-path

93
Makefile.macbrew.arm Executable file
View File

@ -0,0 +1,93 @@
#################################################
# Installing ks-tools (Linux Homebrew) #
#################################################
PREFIX=/opt/homebrew
install:
cp -rf src/ks-upv $(PREFIX)/bin/ks-upv
chmod +x $(PREFIX)/bin/ks-upv
cp -rf src/ks-upa $(PREFIX)/bin/ks-upa
chmod +x $(PREFIX)/bin/ks-upa
cp -rf src/ks-upf $(PREFIX)/bin/ks-upf
chmod +x $(PREFIX)/bin/ks-upf
cp -rf src/ks-upr $(PREFIX)/bin/ks-upr
chmod +x $(PREFIX)/bin/ks-upr
cp -rf src/ks-avi $(PREFIX)/bin/ks-avi
chmod +x $(PREFIX)/bin/ks-avi
cp -rf src/ks-mp4 $(PREFIX)/bin/ks-mp4
chmod +x $(PREFIX)/bin/ks-mp4
cp -rf src/ks-mp4k $(PREFIX)/bin/ks-mp4k
chmod +x $(PREFIX)/bin/ks-mp4k
cp -rf src/ks-mp4s $(PREFIX)/bin/ks-mp4s
chmod +x $(PREFIX)/bin/ks-mp4s
cp -rf src/ks-mp4s-folder $(PREFIX)/bin/ks-mp4s-folder
chmod +x $(PREFIX)/bin/ks-mp4s-folder
cp -rf src/ks-av1s-folder $(PREFIX)/bin/ks-av1s-folder
chmod +x $(PREFIX)/bin/ks-av1s-folder
cp -rf src/ks-vob $(PREFIX)/bin/ks-vob
chmod +x $(PREFIX)/bin/ks-vob
cp -rf src/ks-av1 $(PREFIX)/bin/ks-av1
chmod +x $(PREFIX)/bin/ks-av1
cp -rf src/ks-av1s $(PREFIX)/bin/ks-av1s
chmod +x $(PREFIX)/bin/ks-av1s
cp -rf src/ks-oga $(PREFIX)/bin/ks-oga
chmod +x $(PREFIX)/bin/ks-oga
cp -rf src/ks-mp3 $(PREFIX)/bin/ks-mp3
chmod +x $(PREFIX)/bin/ks-mp3
cp -rf src/ks-oga-album $(PREFIX)/bin/ks-oga-album
chmod +x $(PREFIX)/bin/ks-oga-album
cp -rf src/ks-mp3-album $(PREFIX)/bin/ks-mp3-album
chmod +x $(PREFIX)/bin/ks-mp3-album
cp -rf src/ks-mix $(PREFIX)/bin/ks-mix
chmod +x $(PREFIX)/bin/ks-mix
cp -rf src/ks-crop $(PREFIX)/bin/ks-crop
chmod +x $(PREFIX)/bin/ks-crop
cp -rf src/ks-conf $(PREFIX)/bin/ks-conf
chmod +x $(PREFIX)/bin/ks-conf
cp -rf wrapper/ks-mp4-wrapper $(PREFIX)/bin/ks-mp4-wrapper
chmod +x $(PREFIX)/bin/ks-mp4-wrapper
cp -rf wrapper/ks-mp4k-wrapper $(PREFIX)/bin/ks-mp4k-wrapper
chmod +x $(PREFIX)/bin/ks-mp4k-wrapper
cp -rf wrapper/ks-mp4s-wrapper $(PREFIX)/bin/ks-mp4s-wrapper
chmod +x $(PREFIX)/bin/ks-mp4s-wrapper
cp -rf wrapper/ks-avi-wrapper $(PREFIX)/bin/ks-avi-wrapper
chmod +x $(PREFIX)/bin/ks-avi-wrapper
cp -rf wrapper/ks-vob-wrapper $(PREFIX)/bin/ks-vob-wrapper
chmod +x $(PREFIX)/bin/ks-vob-wrapper
cp -rf wrapper/ks-av1-wrapper $(PREFIX)/bin/ks-av1-wrapper
chmod +x $(PREFIX)/bin/ks-av1-wrapper
cp -rf wrapper/ks-av1s-wrapper $(PREFIX)/bin/ks-av1s-wrapper
chmod +x $(PREFIX)/bin/ks-av1s-wrapper
cp -rf cygwin/cygwin-path $(PREFIX)/bin/cygwin-path
chmod +x $(PREFIX)/bin/cygwin-path
uninstall:
rm -rf $(PREFIX)/bin/ks-upv
rm -rf $(PREFIX)/bin/ks-upa
rm -rf $(PREFIX)/bin/ks-upf
rm -rf $(PREFIX)/bin/ks-upr
rm -rf $(PREFIX)/bin/ks-avi
rm -rf $(PREFIX)/bin/ks-mp4
rm -rf $(PREFIX)/bin/ks-mp4k
rm -rf $(PREFIX)/bin/ks-mp4s
rm -rf $(PREFIX)/bin/ks-mp4s-folder
rm -rf $(PREFIX)/bin/ks-av1s-folder
rm -rf $(PREFIX)/bin/ks-vob
rm -rf $(PREFIX)/bin/ks-av1
rm -rf $(PREFIX)/bin/ks-av1s
rm -rf $(PREFIX)/bin/ks-oga
rm -rf $(PREFIX)/bin/ks-oga-album
rm -rf $(PREFIX)/bin/ks-mp3
rm -rf $(PREFIX)/bin/ks-mp3-album
rm -rf $(PREFIX)/bin/ks-mix
rm -rf $(PREFIX)/bin/ks-crop
rm -rf $(PREFIX)/bin/ks-conf
rm -rf $(PREFIX)/bin/ks-mp4-wrapper
rm -rf $(PREFIX)/bin/ks-mp4k-wrapper
rm -rf $(PREFIX)/bin/ks-mp4s-wrapper
rm -rf $(PREFIX)/bin/ks-avi-wrapper
rm -rf $(PREFIX)/bin/ks-vob-wrapper
rm -rf $(PREFIX)/bin/ks-av1-wrapper
rm -rf $(PREFIX)/bin/ks-av1s-wrapper
rm -rf $(PREFIX)/bin/cygwin-path

173
README.md
View File

@ -1,63 +1,146 @@
ks-tools - Tools for upload, convert and mix video/audio files.
===============================================================
ks-tools - Tools for upload, convert and crop/mix video/audio files.
====================================================================
### Documentation:
* *Tools for upload:*
* `Tools for upload:`
* [ks-upv](https://github.com/q3aql/ks-tools/blob/master/doc/ks-upv.md) - Upload video file(s) to server with rsync+ssh.
* [ks-upa](https://github.com/q3aql/ks-tools/blob/master/doc/ks-upa.md) - Upload audio file(s) to server with rsync+ssh
* [ks-upf](https://github.com/q3aql/ks-tools/blob/master/doc/ks-upf.md) - Upload common file(s) to server with rsync+ssh.
* [ks-upr](https://github.com/q3aql/ks-tools/blob/master/doc/ks-upr.md) - Upload recursively file(s) to server with rsync+ssh.
* [ks-upv](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-upv.md) - Upload video file(s) to server with scp or rsync.
* [ks-upa](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-upa.md) - Upload audio file(s) to server with scp or rsync.
* [ks-upf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-upf.md) - Upload common file(s) to server with scp or rsync.
* [ks-upr](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-upr.md) - Upload recursively file(s) to server with scp or rsync.
* *Tools for convert video:*
* `Tools for convert video:`
* [ks-mp4](https://github.com/q3aql/ks-tools/blob/master/doc/ks-mp4.md) - Convert video file(s) to compact and efficient MP4 (libx264 + aac).
* [ks-mp4k](https://github.com/q3aql/ks-tools/blob/master/doc/ks-mp4k.md) - Convert video file(s) to compact and efficient MP4 (4K).
* [ks-mp4s](https://github.com/q3aql/ks-tools/blob/master/doc/ks-mp4s.md) - Convert video file(s) to compact and efficient MP4 (Series).
* [ks-mp4s-folder](https://github.com/q3aql/ks-tools/blob/master/doc/ks-mp4s-folder.md) - Convert videos from folder to MP4 format (Series).
* [ks-avi](https://github.com/q3aql/ks-tools/blob/master/doc/ks-avi.md) - Convert video file(s) to compact and efficient AVI (libxvid + mp3).
* [ks-vob](https://github.com/q3aql/ks-tools/blob/master/doc/ks-vob.md) - Convert videos to VOB (DVD splitet) format.
* [ks-mp4](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-mp4.md) - Convert video file to compact and efficient MP4 (libx264 + aac).
* [ks-mp4k](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-mp4k.md) - Convert video file to compact and efficient MP4 (4K).
* [ks-mp4s](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-mp4s.md) - Convert video file to compact and efficient MP4 (Series).
* [ks-mp4s-folder](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-mp4s-folder.md) - Convert videos from folder to MP4 format (Series).
* [ks-avi](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-avi.md) - Convert video file to compact and efficient AVI (libxvid + mp3).
* [ks-vob](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-vob.md) - Convert video file to VOB (DVD splitet) format.
* [ks-av1](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-av1.md) - Convert video file to compact and efficient AV1 codec (libsvtav1 + libvorbis).
* [ks-av1s](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-av1s.md) - Convert video file to compact and efficient AV1 codec (Series).
* [ks-av1s-folder](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-av1s-folder.md) - Convert videos from folder to AV1 codec (Series).
* *Tools for convert audio:*
* `Tools for convert audio:`
* [ks-oga](https://github.com/q3aql/ks-tools/blob/master/doc/ks-oga.md) - Convert video/audio file(s) to OGA (OGG Audio) Format.
* [ks-oga-album](https://github.com/q3aql/ks-tools/blob/master/doc/ks-oga-album.md) - Convert folder album to OGA (OGG Audio) Format.
* [ks-mp3](https://github.com/q3aql/ks-tools/blob/master/doc/ks-mp3.md) - Convert video/audio file(s) to MP3 Audio Format.
* [ks-mp3-album](https://github.com/q3aql/ks-tools/blob/master/doc/ks-mp3-album.md) - Convert folder album to MP3 Audio Format.
* [ks-oga](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-oga.md) - Convert video/audio file to OGA (OGG Audio) Format.
* [ks-oga-album](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-oga-album.md) - Convert folder album to OGA (OGG Audio) Format.
* [ks-mp3](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-mp3.md) - Convert video/audio file to MP3 Audio Format.
* [ks-mp3-album](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-mp3-album.md) - Convert folder album to MP3 Audio Format.
* *Tool for mix video/audio:*
* `Tools for crop/mix video/audio:`
* [ks-mix](https://github.com/q3aql/ks-tools/blob/master/doc/ks-mix.md) - Extract video/audio and mix video/audio files.
* [ks-mix](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-mix.md) - Extract video/audio and mix video/audio files.
* [ks-crop](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-crop.md) - Crop or change aspect ratio of a video.
* *Wrappers:*
* `Wrappers/Configuration:`
* [ks-mp4-wrapper](https://github.com/q3aql/ks-tools/blob/master/doc/ks-mp4-wrapper.md) - Wrapper for ks-mp4 to create graphical interfaces.
* [ks-mp4k-wrapper](https://github.com/q3aql/ks-tools/blob/master/doc/ks-mp4k-wrapper.md) - Wrapper for ks-mp4k to create graphical interfaces.
* [ks-mp4s-wrapper](https://github.com/q3aql/ks-tools/blob/master/doc/ks-mp4s-wrapper.md) - Wrapper for ks-mp4s to create graphical interfaces.
* [ks-avi-wrapper](https://github.com/q3aql/ks-tools/blob/master/doc/ks-avi-wrapper.md) - Wrapper for ks-avi to create graphical interfaces.
* [ks-vob-wrapper](https://github.com/q3aql/ks-tools/blob/master/doc/ks-vob-wrapper.md) - Wrapper for ks-vob to create graphical interfaces.
### Downloads:
* [ks-tools-6.6-100221-Linux-en.tar.gz](https://github.com/q3aql/ks-tools/releases/download/v6.6/ks-tools-6.6-100221-Linux-en.tar.gz) - Unix/Linux package.
* [ks-tools-6.6-100221-Windows-en.zip](https://github.com/q3aql/ks-tools/releases/download/v6.6/ks-tools-6.6-100221-Windows-en.zip) - Windows package (with cygwin)
* [ks-tools-6.6-100221-en-all.deb](https://github.com/q3aql/ks-tools/releases/download/v6.6/ks-tools-6.6-100221-en-all.deb) - Debian based package.
_Dependences: bash, coreutils, xterm, openssh-server, openssh-client, sshpass, rsync, ffmpeg, grep_
* [ks-mp4-wrapper](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-mp4-wrapper.md) - Wrapper for ks-mp4 to create graphical interfaces.
* [ks-mp4k-wrapper](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-mp4k-wrapper.md) - Wrapper for ks-mp4k to create graphical interfaces.
* [ks-mp4s-wrapper](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-mp4s-wrapper.md) - Wrapper for ks-mp4s to create graphical interfaces.
* [ks-avi-wrapper](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-avi-wrapper.md) - Wrapper for ks-avi to create graphical interfaces.
* [ks-vob-wrapper](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-vob-wrapper.md) - Wrapper for ks-vob to create graphical interfaces.
* [ks-av1-wrapper](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-av1-wrapper.md) - Wrapper for ks-av1 to create graphical interfaces.
* [ks-av1s-wrapper](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-av1s-wrapper.md) - Wrapper for ks-av1s to create graphical interfaces.
* [ks-conf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-conf.md) - Tool for create and modify all configuration files.
### Installation:
* **Unix/Linux instructions:**
* Open the terminal.
* Type the command: `tar zxvf ks-tools-6.6-100221-Linux-en.tar.gz`
* Change the directory: `cd ks-tools`
* Finally, install the scripts (as root): `make install`
* **Windows instruccions:**
* Unzip the package with [7-zip](http://www.7-zip.org/) or [Winrar](http://www.rarlab.com/).
* Copy folder `ks-tools` on `C:\Program Files`.
* Enter to folder with name `ks-tools` and execute `Install.cmd`.
* Finally, you will see a Shortcut on your Desktop.
* **GNU/Linux:**
* Install dependencies **(for Arch Linux)**:
sudo pacman -Syu git make expect rsync openssh sshpass grep coreutils binutils bc
* Install dependencies **(for Ubuntu/Debian)**:
sudo apt install git make expect rsync openssh-client openssh-server sshpass grep binutils bc
* Install dependencies **(for Fedora)**:
sudo dnf install git make expect rsync openssh sshpass grep coreutils binutils bc
* Install dependencies **(for Linux Homebrew)**:
brew install git make expect rsync openssh grep binutils ffmpeg bc
curl -L https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb > sshpass.rb
brew install sshpass.rb
* Install `ffmpeg` from repository or use the package [ffmpeg-7.0.2-linux-gnu-64bit-build.tar.bz2](https://q3aql.dev/ffmpeg-builds/ffmpeg-7.0.2-linux-gnu-64bit-build.tar.bz2):
sudo tar jxvf ffmpeg-7.0.2-linux-gnu-64bit-build.tar.bz2 -C /
* Install ks-tools cloning the repository:
git clone https://git.q3aql.dev/q3aql/ks-tools
cd ks-tools
sudo make install
* For Linux Homebrew, install with:
make -f Makefile.linuxbrew
* **Windows ([Cygwin](https://www.cygwin.com/)):**
* Install dependencies:
lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin
apt-cyg install git make expect rsync openssh sshpass grep coreutils binutils bc
* Download package [ffmpeg-7.0.2-cygwin-64bit-build.tar.gz](https://q3aql.dev/ffmpeg-builds/ffmpeg-7.0.2-cygwin-64bit-build.tar.gz) and install it:
tar zxvf ffmpeg-7.0-cygwin-64bit-build.tar.gz -C /
* If you prefer your own ffmpeg build, use this script for build it:
git clone https://git.q3aql.dev/q3aql/ks-tools
cd ks-tools/cygwin
chmod +x ffmpeg-build-cygwin64.sh
./ffmpeg-build-cygwin64.sh
* Install ks-tools cloning the repository:
git clone https://git.q3aql.dev/q3aql/ks-tools
cd ks-tools
make -f Makefile.Cygwin
* **Windows ([WSL](https://learn.microsoft.com/en-us/windows/wsl/install)):**
* Install dependencies:
sudo apt install git make expect rsync openssh-client openssh-server sshpass grep binutils bc
* Install `ffmpeg` from the package [ffmpeg-7.0.2-linux-gnu-64bit-build.tar.bz2](https://q3aql.dev/ffmpeg-builds/ffmpeg-7.0.2-linux-gnu-64bit-build.tar.bz2) or from repository:
sudo apt install ffmpeg
* Install ks-tools cloning the repository:
git clone https://git.q3aql.dev/q3aql/ks-tools
cd ks-tools
sudo make install
* **MacOS ([HomeBrew](https://brew.sh/)):**
* Install dependencies:
brew install git make expect rsync openssh grep binutils ffmpeg bc
curl -L https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb > sshpass.rb
brew install sshpass.rb
* Install ks-tools cloning the repository **(for MacOS Intel)**:
git clone https://git.q3aql.dev/q3aql/ks-tools
cd ks-tools
sudo make -f Makefile.macbrew
* Install ks-tools cloning the repository **(for MacOS ARM)**:
git clone https://git.q3aql.dev/q3aql/ks-tools
cd ks-tools
sudo make -f Makefile.macbrew.arm
### External links:
* [ffmpeg homepage](http://ffmpeg.org/)

73
cygwin/cygwin-alias.sh Executable file
View File

@ -0,0 +1,73 @@
#!/bin/bash
# Cygwin alias (for Windows)
# shopt -s expand_aliases
alias cat="/usr/bin/cat"
alias clear="/usr/bin/clear"
alias cut="/usr/bin/cut"
alias date="/usr/bin/date"
alias echo="/usr/bin/echo"
alias expr="/usr/bin/expr"
alias ffmpeg="/usr/bin/ffmpeg"
alias ffplay="/usr/bin/ffplay"
alias ffprobe="/usr/bin/ffprobe"
alias file="/usr/bin/file"
alias find="/usr/bin/find"
alias ftp="/usr/bin/ftp"
alias grep="/usr/bin/grep"
alias head="/usr/bin/head"
alias ldd="/usr/bin/ldd"
alias ls="/usr/bin/ls"
alias md5sum="/usr/bin/md5sum"
alias mintty="/usr/bin/mintty"
alias mkdir="/usr/bin/mkdir"
alias mv="/usr/bin/mv"
alias pwd="/usr/bin/pwd"
alias rm="/usr/bin/rm"
alias rsync="/usr/bin/rsync"
alias scp="/usr/bin/scp"
alias sed="/usr/bin/sed"
alias sleep="/usr/bin/sleep"
alias ssh-add="/usr/bin/ssh-add"
alias ssh-agent="/usr/bin/ssh-agent"
alias ssh-keygen="/usr/bin/ssh-keygen"
alias ssh-keyscan="/usr/bin/ssh-keyscan"
alias ssh="/usr/bin/ssh"
alias sshpass="/usr/bin/sshpass"
alias expect="/usr/bin/expect"
alias tail="/usr/bin/tail"
alias touch="/usr/bin/touch"
alias tr="/usr/bin/tr"
alias wc="/usr/bin/wc"
alias x264="/usr/bin/x264"
alias zenity="/usr/bin/zenity"
alias bc="/usr/bin/bc"
alias all-commands='ls /bin | grep ".exe" | cut -d "." -f 1'
# List of alias for drives:
alias A:="/cygdrive/a"
alias B:="/cygdrive/b"
alias C:="/cygdrive/c"
alias D:="/cygdrive/d"
alias E:="/cygdrive/e"
alias F:="/cygdrive/f"
alias G:="/cygdrive/g"
alias H:="/cygdrive/h"
alias I:="/cygdrive/i"
alias J:="/cygdrive/j"
alias K:="/cygdrive/k"
alias L:="/cygdrive/l"
alias M:="/cygdrive/m"
alias N:="/cygdrive/n"
alias O:="/cygdrive/o"
alias P:="/cygdrive/p"
alias Q:="/cygdrive/q"
alias R:="/cygdrive/r"
alias S:="/cygdrive/s"
alias T:="/cygdrive/t"
alias U:="/cygdrive/u"
alias V:="/cygdrive/v"
alias W:="/cygdrive/w"
alias X:="/cygdrive/x"
alias Y:="/cygdrive/y"
alias Z:="/cygdrive/z"

View File

@ -4,7 +4,7 @@
# cygwin-path - Convert Windows paths in Cywin paths & vice versa #
# Date: 28-03-2020 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
####################################################################
VERSION="1.0"
M_DATE="280320"
@ -22,33 +22,33 @@ function convertCygwin() {
echo "${wordToConvert}" > ${CygPathSedFile}
# Apply changes
sed -i 's/\\/\//g' "${CygPathSedFile}" &> /dev/null
sed -i 's/A:/\/cygdrive\/a/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/B:/\/cygdrive\/b/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/A:/\/cygdrive\/a/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/B:/\/cygdrive\/b/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/C:/\/cygdrive\/c/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/D:/\/cygdrive\/d/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/E:/\/cygdrive\/e/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/F:/\/cygdrive\/f/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/G:/\/cygdrive\/g/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/H:/\/cygdrive\/h/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/I:/\/cygdrive\/i/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/J:/\/cygdrive\/j/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/K:/\/cygdrive\/k/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/L:/\/cygdrive\/l/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/M:/\/cygdrive\/m/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/N:/\/cygdrive\/n/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/O:/\/cygdrive\/o/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/P:/\/cygdrive\/p/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/Q:/\/cygdrive\/q/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/R:/\/cygdrive\/r/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/S:/\/cygdrive\/s/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/T:/\/cygdrive\/t/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/U:/\/cygdrive\/u/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/V:/\/cygdrive\/v/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/W:/\/cygdrive\/w/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/X:/\/cygdrive\/x/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/Y:/\/cygdrive\/y/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/Z:/\/cygdrive\/z/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/ / /g' "${CygPathSedFile}" &> /dev/null
sed -i 's/D:/\/cygdrive\/d/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/E:/\/cygdrive\/e/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/F:/\/cygdrive\/f/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/G:/\/cygdrive\/g/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/H:/\/cygdrive\/h/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/I:/\/cygdrive\/i/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/J:/\/cygdrive\/j/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/K:/\/cygdrive\/k/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/L:/\/cygdrive\/l/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/M:/\/cygdrive\/m/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/N:/\/cygdrive\/n/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/O:/\/cygdrive\/o/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/P:/\/cygdrive\/p/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/Q:/\/cygdrive\/q/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/R:/\/cygdrive\/r/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/S:/\/cygdrive\/s/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/T:/\/cygdrive\/t/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/U:/\/cygdrive\/u/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/V:/\/cygdrive\/v/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/W:/\/cygdrive\/w/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/X:/\/cygdrive\/x/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/Y:/\/cygdrive\/y/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/Z:/\/cygdrive\/z/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/ / /g' "${CygPathSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${CygPathSedFile})
echo "\"${wordToConvert}\""
@ -62,33 +62,33 @@ function convertWindows() {
mkdir -p ${CygPathTempFolder} && chmod 777 -R ${CygPathTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${CygPathSedFile}
# Apply changes
sed -i 's/\/cygdrive\/a/A:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/b/B:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/c/C:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/d/D:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/e/E:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/f/F:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/g/G:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/h/H:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/i/I:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/j/J:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/k/K:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/l/L:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/m/M:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/n/N:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/o/O:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/p/P:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/q/Q:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/r/R:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/s/S:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/t/T:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/u/U:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/v/V:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/w/W:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/y/Y:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/z/Z:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\//\\/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\\ / /g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/a/A:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/b/B:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/c/C:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/d/D:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/e/E:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/f/F:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/g/G:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/h/H:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/i/I:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/j/J:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/k/K:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/l/L:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/m/M:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/n/N:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/o/O:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/p/P:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/q/Q:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/r/R:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/s/S:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/t/T:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/u/U:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/v/V:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/w/W:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/y/Y:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\/cygdrive\/z/Z:/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\//\\/g' "${CygPathSedFile}" &> /dev/null
sed -i 's/\\ / /g' "${CygPathSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${CygPathSedFile})
echo "\"${wordToConvert}\""
@ -100,40 +100,40 @@ if [ -z "${1}" ] ; then
echo "* cygwin-path v${VERSION} (${M_DATE})"
echo ""
echo "* Convert Windows paths in Cywin paths & vice versa"
echo ""
echo ""
echo "+ Sintax: "
echo ""
echo " $ cygwin-path -c \"<Windows path>\" --> Convert Windows path to Cygwin path"
echo " $ cygwin-path -w \"<Cygwin path>\" --> Convert Cygwin path to Windows path"
echo " $ cygwin-path -w \"<Cygwin path>\" --> Convert Cygwin path to Windows path"
echo ""
echo "+ Examples: "
echo ""
echo " $ cygwin-path -c \"C:\\Users\\test\Desktop\\my-notes.txt\""
echo " $ cygwin-path -w \"/cygdrive/c/Users/test/Desktop/my-notes.txt\""
echo ""
echo " $ cygwin-path -c \"C:\\Users\\test\Desktop\\my-notes.txt\""
echo " $ cygwin-path -w \"/cygdrive/c/Users/test/Desktop/my-notes.txt\""
echo ""
exit
else
if [ "${1}" == "-c" ] ; then
convertCygwin "${2}"
elif [ "${1}" == "-w" ] ; then
convertWindows "${2}"
else
# Show help if sintax is wrong
echo ""
echo "* cygwin-path v${VERSION} (${M_DATE})"
echo ""
echo "* Convert Windows paths in Cywin paths & vice versa"
echo ""
echo "+ Sintax: "
echo ""
echo " $ cygwin-path -c \"<Windows path>\" --> Convert Windows path to Cygwin path"
echo " $ cygwin-path -w \"<Cygwin path>\" --> Convert Cygwin path to Windows path"
echo ""
echo "+ Examples: "
echo ""
echo " $ cygwin-path -c \"C:\\Users\\test\Desktop\\my-notes.txt\""
echo " $ cygwin-path -w \"/cygdrive/c/Users/test/Desktop/my-notes.txt\""
echo ""
exit
fi
if [ "${1}" == "-c" ] ; then
convertCygwin "${2}"
elif [ "${1}" == "-w" ] ; then
convertWindows "${2}"
else
# Show help if sintax is wrong
echo ""
echo "* cygwin-path v${VERSION} (${M_DATE})"
echo ""
echo "* Convert Windows paths in Cywin paths & vice versa"
echo ""
echo "+ Sintax: "
echo ""
echo " $ cygwin-path -c \"<Windows path>\" --> Convert Windows path to Cygwin path"
echo " $ cygwin-path -w \"<Cygwin path>\" --> Convert Cygwin path to Windows path"
echo ""
echo "+ Examples: "
echo ""
echo " $ cygwin-path -c \"C:\\Users\\test\Desktop\\my-notes.txt\""
echo " $ cygwin-path -w \"/cygdrive/c/Users/test/Desktop/my-notes.txt\""
echo ""
exit
fi
fi

302
cygwin/ffmpeg-build-cywin64.sh Executable file
View File

@ -0,0 +1,302 @@
#!/bin/bash
############################################
# Script for build FFmpeg on Cygwin x86_64 #
# Author: q3aql #
# Contact: q3aql@duck.com #
############################################
# IMPORTANT
# YOU NEED INSTALL:
# - wget
# - git
# Build variables
dir_build="/opt/ffmpeg-builds/build/cygwin64-shared"
dir_build_libs="/opt/ffmpeg-builds/lib/cygwin64-shared"
dir_build_packages="/opt/ffmpeg-builds/packages"
# FFmpeg version
ffmpeg_package="https://ffmpeg.org/releases/ffmpeg-6.0.tar.bz2"
ffmpeg_package_name="ffmpeg-6.0.tar.bz2@ffmpeg-6.0"
# COMPILER VARIABLES
C_COMPILER="gcc"
CXX_COMPILER="g++"
# URL Libraries Variables
lib_x264="https://code.videolan.org/videolan/x264"
lib_x264_name="x264"
lib_x265="https://bitbucket.org/multicoreware/x265_git/downloads/x265_3.5.tar.gz"
lib_x265_name="x265_3.5.tar.gz@x265_3.5"
lib_xvid="https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz"
lib_xvid_name="xvidcore-1.3.7.tar.gz@xvidcore"
lib_aom_msys="https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-aom-3.6.0-1-any.pkg.tar.zst"
lib_aom_msys_name="mingw-w64-x86_64-aom-3.6.0-1-any.pkg.tar.zst@mingw64"
#https://packages.msys2.org/package/mingw-w64-i686-aom
lib_svtav1_msys="https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-svt-av1-1.4.1-1-any.pkg.tar.zst"
lib_svtav1_msys_name="mingw-w64-x86_64-svt-av1-1.4.1-1-any.pkg.tar.zst@mingw64"
# Dependencies for aom
dep_one="https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-libs-12.2.0-6-any.pkg.tar.zst"
dep_one_name="mingw-w64-x86_64-gcc-libs-12.2.0-6-any.pkg.tar.zst"
dep_two="https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-libwinpthread-git-10.0.0.r0.gaa08f56da-1-any.pkg.tar.zst"
dep_two_name="mingw-w64-x86_64-libwinpthread-git-10.0.0.r0.gaa08f56da-1-any.pkg.tar.zst"
dep_three="https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-gmp-6.2.1-5-any.pkg.tar.zst"
dep_three_name="mingw-w64-x86_64-gmp-6.2.1-5-any.pkg.tar.zst"
dep_four="https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-mpc-1.3.1-1-any.pkg.tar.zst"
dep_four_name="mingw-w64-x86_64-mpc-1.3.1-1-any.pkg.tar.zst"
dep_five="https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-mpfr-4.2.0-1-any.pkg.tar.zst"
dep_five_name="mingw-w64-x86_64-mpfr-4.2.0-1-any.pkg.tar.zst"
# Check root permission
mkdir -p /etc/root &> /dev/null
administrador=$?
if [ ${administrador} -eq 0 ] ; then
rm -rf /etc/root
else
echo ""
echo "* ${0}"
echo ""
echo "* Administrator permissions are required."
echo ""
exit
fi
# Create directories
mkdir -p ${dir_build}
mkdir -p ${dir_build_libs}
mkdir -p ${dir_build_packages}
# Install apt-cyg
if [ -f "/usr/bin/apt-cyg" ] ; then
echo "* apt-cyg manager is ready"
sleep 1
else
cd /tmp
git clone "https://github.com/q3aql/ffmpeg-builds"
cd ffmpeg-builds
cp -rfv apt-cyg /usr/bin
echo "* apt-cyg installed"
fi
# Fix strafe.sh
if [ -f /usr/include/w32api/strsafe.h_fix ] ; then
echo "* strsafe.h was fixed previously"
else
cd /tmp
git clone "https://github.com/q3aql/ffmpeg-builds"
cd ffmpeg-builds
cp -rfv /usr/include/w32api/strsafe.h /usr/include/w32api/strsafe.h.bck
cp -rfv cygwin_fix_strsafe.h /usr/include/w32api/strsafe.h
cp -rfv cygwin_fix_strsafe.h /usr/include/w32api/strsafe.h_fix
echo "* strsafe.sh fixed"
fi
# Install dependencies
apt-cyg update
apt-cyg install wget
apt-cyg install curl
apt-cyg install nasm
apt-cyg install yasm
apt-cyg install zip
apt-cyg install perl
apt-cyg install sed
apt-cyg install fontconfig
apt-cyg install libass-devel
apt-cyg install libfreetype-devel
apt-cyg install libfontconfig-devel
apt-cyg install libbs2b-devel
apt-cyg install meson
apt-cyg install make
apt-cyg install gcc
apt-cyg install gcc-core
apt-cyg install gcc-g++
apt-cyg install zstd
apt-cyg install libfribidi-devel
apt-cyg install libgme-devel
apt-cyg install libcaca++-devel
apt-cyg install libcaca-devel
apt-cyg install libtwolame-devel
apt-cyg install libmp3lame-devel
apt-cyg install libwebp-devel
apt-cyg install libsoxr-devel
apt-cyg install libvpx-devel
apt-cyg install libtheora-devel
apt-cyg install libxml2-devel
apt-cyg install libopenjpeg-devel
apt-cyg install libgnutls-devel
apt-cyg install libvorbis-devel
apt-cyg install libogg-devel
apt-cyg install libopus-devel
apt-cyg install openssl-devel
apt-cyg install libopusfile-devel
apt-cyg install libopenjp2-devel
apt-cyg install libtheora-devel
apt-cyg install speex-devel
apt-cyg install speexdsp-devel
apt-cyg install cmake
apt-cyg install libgc-devel
apt-cyg install autoconf
apt-cyg install libtool
apt-cyg install ninja
apt-cyg install libiconv-devel
apt-cyg install clang
apt-cyg install compiler-rt
apt-cyg install libjson-c-common
apt-cyg install libc++abi-devel
apt-cyg install libc++-devel
# Build x264
if [ -f /usr/lib/pkgconfig/x264.pc ] ; then
echo "* x264 was compiled previously"
sleep 1
else
cd ${dir_build_libs}
rm -rfv ${name_package}
rm -rfv ${name_folder}
name_folder=$(echo ${lib_x264_name})
name_package=$(echo ${lib_x264_name})
git clone ${lib_x264}
cd "${name_folder}"
./configure --prefix=/usr --enable-static --disable-opencl --disable-cli
make
make install
fi
# Build x265
if [ -f /usr/lib/pkgconfig/x265.pc ] ; then
echo "* x265 was compiled previously"
sleep 1
else
cd ${dir_build_libs}
rm -rfv ${name_package}
rm -rfv ${name_folder}
name_package=$(echo ${lib_x265_name} | cut -d "@" -f 1)
name_folder=$(echo ${lib_x265_name} | cut -d "@" -f 2)
wget -c "${lib_x265}"
tar zxvf ${name_package}
cd "${name_folder}"
cd build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr -DSTATIC_LINK_CRT:BOOL=ON -DENABLE_CLI:BOOL=OFF ../../source
sed -i 's/-lgcc_s/-lgcc_eh/g' x265.pc
make
make install
fi
# Build xvid
if [ -f /usr/lib/xvidcore.a ] ; then
echo "* Xvid was compiled previously"
sleep 1
else
cd ${dir_build_libs}
rm -rfv ${name_package}
rm -rfv ${name_folder}
name_package=$(echo ${lib_xvid_name} | cut -d "@" -f 1)
name_folder=$(echo ${lib_xvid_name} | cut -d "@" -f 2)
wget -c "${lib_xvid}"
tar zxvf ${name_package}
cd "${name_folder}"/build/generic
./configure --prefix=/usr
make
make install
fi
# Build aom
if [ -f /usr/lib/pkgconfig/aom.pc ] ; then
echo "* Aom was compiled previously"
sleep 1
else
cd ${dir_build_libs}
rm -rfv ${name_package}
name_package=$(echo ${lib_aom_msys_name} | cut -d "@" -f 1)
name_folder=$(echo ${lib_aom_msys_name} | cut -d "@" -f 2)
cd /tmp
wget ${lib_aom_msys}
tar --use-compress-program=unzstd -xvf ${name_package}
cd ${name_folder}
cp -rfv * /usr/
cd ..
rm -rfv ${name_package}
rm -rfv ${name_folder}
# Install binary dependencies
cd /tmp
wget -c ${dep_one}
wget -c ${dep_two}
wget -c ${dep_three}
wget -c ${dep_four}
wget -c ${dep_five}
tar --use-compress-program=unzstd -xvf ${dep_one_name}
tar --use-compress-program=unzstd -xvf ${dep_two_name}
tar --use-compress-program=unzstd -xvf ${dep_three_name}
tar --use-compress-program=unzstd -xvf ${dep_four_name}
tar --use-compress-program=unzstd -xvf ${dep_five_name}
cd ${name_folder}
cp -rfv bin/* /usr/bin/
cd ..
rm -rfv ${name_package}
rm -rfv ${name_folder}
fi
# Build SVT-AV1
if [ -f /usr/lib/pkgconfig/SvtAv1Dec.pc ] ; then
echo "* SVT-AV1 was compiled previously"
rm -rfv ${name_package}
rm -rfv ${name_folder}
sleep 1
else
cd ${dir_build_libs}
rm -rfv ${name_package}
name_package=$(echo ${lib_svtav1_msys_name} | cut -d "@" -f 1)
name_folder=$(echo ${lib_svtav1_msys_name} | cut -d "@" -f 2)
cd /tmp
wget ${lib_svtav1_msys}
tar --use-compress-program=unzstd -xvf ${name_package}
cd ${name_folder}
cp -rfv * /usr/
cd ..
rm -rfv ${name_package}
rm -rfv ${name_folder}
fi
# Download FFmpeg
cd / && ln -s usr mingw64
unlink /mingw64/usr 2> /dev/null
echo "* Building FFmpeg using system libraries"
cd ${dir_build_libs}
name_package=$(echo ${ffmpeg_package_name} | cut -d "@" -f 1)
name_folder=$(echo ${ffmpeg_package_name} | cut -d "@" -f 2)
curl "${ffmpeg_package}" > ${name_package}
wget -c ${ffmpeg_package}
tar jxvf ${name_package}
cd ${name_folder}
chmod +x configure
./configure --prefix=/usr --enable-gpl --enable-nonfree --disable-ffplay --disable-w32threads --enable-openssl --enable-libass --enable-libbs2b --enable-libcaca --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libxvid --enable-libspeex --enable-libx264 --enable-libx265 --enable-static --enable-version3 --enable-doc --disable-indev=dshow --disable-indev=gdigrab --enable-libsvtav1 --enable-libaom
build_error=$?
if [ ${build_error} -eq 0 ] ; then
echo ""
echo "* Build configuration ready"
sleep 5
else
echo ""
echo "* Build configuration failed"
echo "* Trying with build config without errors."
echo "* Disabling the following libraries:"
echo " - aom"
echo ""
sleep 5
./configure --prefix=/usr --enable-gpl --enable-nonfree --disable-ffplay --disable-w32threads --enable-openssl --enable-libass --enable-libbs2b --enable-libcaca --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libxvid --enable-libspeex --enable-libx264 --enable-libx265 --enable-static --enable-version3 --enable-doc --disable-indev=dshow --disable-indev=gdigrab --enable-libsvtav1 --disable-libaom
fi
make
rm -rf ${dir_build}/*
make install
# Remove packages
echo "* Remove temporal files"
cd ..
rm -rfv ${name_package}
rm -rf ${name_folder}

View File

@ -1,377 +0,0 @@
#!/bin/bash
#################################################################
# ks-zui (ks-tools) - Simple zenity user interface for ks-tools #
# Date: 10-02-2021 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
#################################################################
VERSION="6.5 (BETA)"
M_DATE="100221"
# Function to show about
function showAbout() {
zenity --title "About" --info --width=330 \
--text "Software: ks-zui (ks-tools) ${VERSION} \
(${M_DATE})\nAuthor: q3aql\nContact: q3aql@protonmail.ch\nLicense: GPL v2.0"
}
# Function to show information of video file
# Sintax: showVideoInfo
function showVideoInfo() {
videoFile=$(zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE}) \
| Select the video file" --file-selection)
# Enable in Cygwin
#videoFile=$(cygwin-path -c "${videoFile}")
ks-mp4-wrapper --show-info "${videoFile}"
echo -n "Press ENTER to continue " ; read null
}
# Function to convert MP4 with subs
# Sintax: convertMP4WithSub
function convertMP4WithSub() {
videoFile=$(zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE}) \
| Select the video file" --file-selection)
# Enable in Cygwin
#videoFile=$(cygwin-path -c "${videoFile}")
# Detect configuration
if [ -z "${videoFile}" ] ; then
echo null > /dev/null
else
videoTrackDefault=$(ks-mp4-wrapper --show-video-default "${videoFile}")
audioTrackDefault=$(ks-mp4-wrapper --show-audio-default "${videoFile}")
subtitleTrackDefault=$(ks-mp4-wrapper --show-subtitle-default "${videoFile}")
resolutionDefault=$(ks-mp4-wrapper --show-resolution-default)
nameDefault=$(ks-mp4-wrapper --show-name-title-default "${videoFile}")
yearDefault=$(ks-mp4-wrapper --show-year-default)
genreDefault=$(ks-mp4-wrapper --show-genre-default)
# Ask the configuration
videoTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the video track to map: " --entry-text "${videoTrackDefault}")
audioTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the audio track to map: " --entry-text "${audioTrackDefault}")
subtitleTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the subtitle track to map: " --entry-text "${subtitleTrackDefault}")
resolution=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the resolution: " --entry-text "${resolutionDefault}")
nameVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the name title: " --entry-text "${nameDefault}")
yearVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the year: " --entry-text "${yearDefault}")
genreVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the genre: " --entry-text "${genreDefault}")
# Disable on Cygwin
mkdir -p ${HOME}/Conv
outputFile=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the path of ouput file prefix: " --entry-text "${HOME}/Conv/Default")
# Enable on Cygwin
#mkdir -p /cygdrive/c/Conv
#outputFile=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
# --text "Enter the ouput file prefix:" --entry-text "/cygdrive/c/Conv/Default")
zenity --question --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --cancel-label="No" \
--ok-label="Yes" --width=320 --text "Do you want apply '-thread_queue_size 2048' patch?"
outputPath=$?
if [ ${outputPath} -eq 0 ] ; then
ks-mp4-wrapper --conv-with-sub "${videoFile}" "${outputFile}" ${videoTrack} ${audioTrack} \
${subtitleTrack} ${resolution} "${nameVideo}" ${yearVideo} ${genreVideo} patch
else
ks-mp4-wrapper --conv-with-sub "${videoFile}" "${outputFile}" ${videoTrack} ${audioTrack} \
${subtitleTrack} ${resolution} "${nameVideo}" ${yearVideo} ${genreVideo}
fi
echo ""
echo -n "Press ENTER to continue " ; read null
fi
}
# Function to convert MP4
# Sintax: convertMP4
function convertMP4() {
videoFile=$(zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE}) \
| Select the video file" --file-selection)
# Enable in Cygwin
#videoFile=$(cygwin-path -c "${videoFile}")
# Detect configuration
if [ -z "${videoFile}" ] ; then
echo null > /dev/null
else
videoTrackDefault=$(ks-mp4-wrapper --show-video-default "${videoFile}")
audioTrackDefault=$(ks-mp4-wrapper --show-audio-default "${videoFile}")
resolutionDefault=$(ks-mp4-wrapper --show-resolution-default)
nameDefault=$(ks-mp4-wrapper --show-name-title-default "${videoFile}")
yearDefault=$(ks-mp4-wrapper --show-year-default)
genreDefault=$(ks-mp4-wrapper --show-genre-default)
# Ask the configuration
videoTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the video track to map: " --entry-text "${videoTrackDefault}")
audioTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the audio track to map: " --entry-text "${audioTrackDefault}")
resolution=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the resolution: " --entry-text "${resolutionDefault}")
nameVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the name title: " --entry-text "${nameDefault}")
yearVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the year: " --entry-text "${yearDefault}")
genreVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the genre: " --entry-text "${genreDefault}")
# Disable on Cygwin
mkdir -p ${HOME}/Conv
outputFile=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the path of ouput file prefix: " --entry-text "${HOME}/Conv/Default")
# Enable on Cygwin
#mkdir -p /cygdrive/c/Conv
#outputFile=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
# --text "Enter the ouput file prefix:" --entry-text "/cygdrive/c/Conv/Default")
zenity --question --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --cancel-label="No" \
--ok-label="Yes" --width=320 --text "Do you want apply '-thread_queue_size 2048' patch?"
outputPath=$?
if [ ${outputPath} -eq 0 ] ; then
ks-mp4-wrapper --conv "${videoFile}" "${outputFile}" ${videoTrack} \
${audioTrack} ${resolution} "${nameVideo}" ${yearVideo} ${genreVideo} patch
else
ks-mp4-wrapper --conv "${videoFile}" "${outputFile}" ${videoTrack} \
${audioTrack} ${resolution} "${nameVideo}" ${yearVideo} ${genreVideo}
fi
echo ""
echo -n "Press ENTER to continue " ; read null
fi
}
# Function to convert AVI with subs
# Sintax: convertAVIWithSub
function convertAVIWithSub() {
videoFile=$(zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE}) \
| Select the video file" --file-selection)
# Enable in Cygwin
#videoFile=$(cygwin-path -c "${videoFile}")
# Detect configuration
if [ -z "${videoFile}" ] ; then
echo null > /dev/null
else
videoTrackDefault=$(ks-avi-wrapper --show-video-default "${videoFile}")
audioTrackDefault=$(ks-avi-wrapper --show-audio-default "${videoFile}")
subtitleTrackDefault=$(ks-avi-wrapper --show-subtitle-default "${videoFile}")
resolutionDefault=$(ks-avi-wrapper --show-resolution-default)
nameDefault=$(ks-avi-wrapper --show-name-title-default "${videoFile}")
yearDefault=$(ks-avi-wrapper --show-year-default)
genreDefault=$(ks-avi-wrapper --show-genre-default)
# Ask the configuration
videoTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the video track to map: " --entry-text "${videoTrackDefault}")
audioTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the audio track to map: " --entry-text "${audioTrackDefault}")
subtitleTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the subtitle track to map: " --entry-text "${subtitleTrackDefault}")
resolution=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the resolution: " --entry-text "${resolutionDefault}")
nameVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the name title: " --entry-text "${nameDefault}")
yearVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the year: " --entry-text "${yearDefault}")
genreVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the genre: " --entry-text "${genreDefault}")
# Disable on Cygwin
mkdir -p ${HOME}/Conv
outputFile=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the path of ouput file prefix: " --entry-text "${HOME}/Conv/Default")
# Enable on Cygwin
#mkdir -p /cygdrive/c/Conv
#outputFile=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
# --text "Enter the ouput file prefix:" --entry-text "/cygdrive/c/Conv/Default")
zenity --question --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --cancel-label="No" \
--ok-label="Yes" --width=320 --text "Do you want apply '-thread_queue_size 2048' patch?"
outputPath=$?
if [ ${outputPath} -eq 0 ] ; then
ks-avi-wrapper --conv-with-sub "${videoFile}" "${outputFile}" ${videoTrack} ${audioTrack} \
${subtitleTrack} ${resolution} "${nameVideo}" ${yearVideo} ${genreVideo} patch
else
ks-avi-wrapper --conv-with-sub "${videoFile}" "${outputFile}" ${videoTrack} ${audioTrack} \
${subtitleTrack} ${resolution} "${nameVideo}" ${yearVideo} ${genreVideo}
fi
echo ""
echo -n "Press ENTER to continue " ; read null
fi
}
# Function to convert AVI
# Sintax: convertAVIW
function convertAVI() {
videoFile=$(zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE}) \
| Select the video file" --file-selection)
# Enable in Cygwin
#videoFile=$(cygwin-path -c "${videoFile}")
# Detect configuration
if [ -z "${videoFile}" ] ; then
echo null > /dev/null
else
videoTrackDefault=$(ks-avi-wrapper --show-video-default "${videoFile}")
audioTrackDefault=$(ks-avi-wrapper --show-audio-default "${videoFile}")
resolutionDefault=$(ks-avi-wrapper --show-resolution-default)
nameDefault=$(ks-avi-wrapper --show-name-title-default "${videoFile}")
yearDefault=$(ks-avi-wrapper --show-year-default)
genreDefault=$(ks-avi-wrapper --show-genre-default)
# Ask the configuration
videoTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the video track to map: " --entry-text "${videoTrackDefault}")
audioTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the audio track to map: " --entry-text "${audioTrackDefault}")
resolution=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the resolution: " --entry-text "${resolutionDefault}")
nameVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the name title: " --entry-text "${nameDefault}")
yearVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the year: " --entry-text "${yearDefault}")
genreVideo=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "[METADATA] Enter the genre: " --entry-text "${genreDefault}")
# Disable on Cygwin
mkdir -p ${HOME}/Conv
outputFile=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the path of ouput file prefix: " --entry-text "${HOME}/Conv/Default")
# Enable on Cygwin
#mkdir -p /cygdrive/c/Conv
#outputFile=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
# --text "Enter the ouput file prefix:" --entry-text "/cygdrive/c/Conv/Default")
zenity --question --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --cancel-label="No" \
--ok-label="Yes" --width=320 --text "Do you want apply '-thread_queue_size 2048' patch?"
outputPath=$?
if [ ${outputPath} -eq 0 ] ; then
ks-avi-wrapper --conv "${videoFile}" "${outputFile}" ${videoTrack} \
${audioTrack} ${resolution} "${nameVideo}" ${yearVideo} ${genreVideo} patch
else
ks-avi-wrapper --conv "${videoFile}" "${outputFile}" ${videoTrack} \
${audioTrack} ${resolution} "${nameVideo}" ${yearVideo} ${genreVideo}
fi
echo ""
echo -n "Press ENTER to continue " ; read null
fi
}
# Function to convert VOB
# Sintax: convertVOB
function convertVOB() {
videoFile=$(zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE}) \
| Select the video file" --file-selection)
# Enable in Cygwin
#videoFile=$(cygwin-path -c "${videoFile}")
# Detect configuration
if [ -z "${videoFile}" ] ; then
echo null > /dev/null
else
videoTrackDefault=$(ks-vob-wrapper --show-video-default "${videoFile}")
audioTrackDefault=$(ks-vob-wrapper --show-audio-default "${videoFile}")
resolutionDefault=$(ks-vob-wrapper --show-resolution-default)
# Ask the configuration
videoTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the video track to map: " --entry-text "${videoTrackDefault}")
audioTrack=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the audio track to map: " --entry-text "${audioTrackDefault}")
resolution=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the resolution: " --entry-text "${resolutionDefault}")
# Disable on Cygwin
mkdir -p ${HOME}/Conv
outputFile=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
--text "Enter the path of ouput file prefix: " --entry-text "${HOME}/Conv/Default")
# Enable on Cygwin
#mkdir -p /cygdrive/c/Conv
#outputFile=$(zenity --entry --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" \
# --text "Enter the ouput file prefix:" --entry-text "/cygdrive/c/Conv/Default")
zenity --question --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --cancel-label="No" \
--ok-label="Yes" --width=320 --text "Do you want apply '-thread_queue_size 2048' patch?"
outputPath=$?
if [ ${outputPath} -eq 0 ] ; then
ks-vob-wrapper --conv "${videoFile}" "${outputFile}" ${videoTrack} \
${audioTrack} ${resolution} patch
else
ks-vob-wrapper --conv "${videoFile}" "${outputFile}" ${videoTrack} \
${audioTrack} ${resolution} "${nameVideo}" ${yearVideo} ${genreVideo}
fi
echo ""
echo -n "Press ENTER to continue " ; read null
fi
}
# Choose subtitles in MP4 convert
function subtitlesMP4() {
zenity --question --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --cancel-label="No" \
--ok-label="Yes" --width=320 --text "Do you want enable subtitles?"
outputPath=$?
if [ ${outputPath} -eq 0 ] ; then
convertMP4WithSub
else
convertMP4
fi
}
# Choose subtitles in AVI convert
function subtitlesAVI() {
zenity --question --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --cancel-label="No" \
--ok-label="Yes" --width=320 --text "Do you want enable subtitles?"
outputPath=$?
if [ ${outputPath} -eq 0 ] ; then
convertAVIWithSub
else
convertAVI
fi
}
# Show main menu
echo ""
echo "* Starting ks-zui (ks-tools) ${VERSION} (${M_DATE})"
echo ""
showMenu=0
while [ ${showMenu} -eq 0 ] ; do
clear
opcion=$(zenity --width=420 --height=560 --list --title "ks-zui (ks-tools) ${VERSION} ($M_DATE)" \
--column "Available options:" "### CONVERSION OPTIONS ###" "Show video file information" \
"Convert video file to MP4" "Convert video file to AVI" "Convert video file to VOB" \
"########################" "### UPLOAD OPTIONS ###" "Upload videos file(s) to server" \
"Upload audio file(s) to server" "Upload common file(s) to server" "Upload recursively file(s) to server"\
"Remove configuration" "Show configuration" "Edit configuration" \
"About" "Exit")
if [ "${opcion}" == "### CONVERSION OPTIONS ###" ] ; then
echo null > /dev/null
elif [ "${opcion}" == "Show video file information" ] ; then
showVideoInfo
elif [ "${opcion}" == "Convert video file to MP4" ] ; then
subtitlesMP4
elif [ "${opcion}" == "Convert video file to AVI" ] ; then
subtitlesAVI
elif [ "${opcion}" == "Convert video file to VOB" ] ; then
convertVOB
elif [ "${opcion}" == "########################" ] ; then
echo null > /dev/null
elif [ "${opcion}" == "### UPLOAD OPTIONS ###" ] ; then
echo null > /dev/null
elif [ "${opcion}" == "Upload videos file(s) to server" ] ; then
ks-upv -i
zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --info --width=300 \
--text "File(s) upload is complete!"
elif [ "${opcion}" == "Upload audio file(s) to server" ] ; then
ks-upa -i
zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --info --width=300 \
--text "File(s) upload is complete!"
elif [ "${opcion}" == "Upload common file(s) to server" ] ; then
ks-upf -i
zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --info --width=300 \
--text "File(s) upload is complete!"
elif [ "${opcion}" == "Upload recursively file(s) to server" ] ; then
ks-upr -i
zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --info --width=300 \
--text "File(s) upload is complete!"
elif [ "${opcion}" == "Remove configuration" ] ; then
ks-upf -r
zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --info --width=300 \
--text "The configuration has been removed!"
elif [ "${opcion}" == "Show configuration" ] ; then
ks-upf -c
echo -n "Press ENTER to continue " ; read null
elif [ "${opcion}" == "Edit configuration" ] ; then
ks-upf -e
elif [ "${opcion}" == "About" ] ; then
showAbout
elif [ "${opcion}" == "Exit" ] ; then
showMenu=1
else
zenity --title "ks-zui (ks-tools) ${VERSION} (${M_DATE})" --warning --width=300 \
--text "Choose one of the menu options"
fi
done

52
doc/ks-av1-wrapper.md Normal file
View File

@ -0,0 +1,52 @@
ks-av1-wrapper - Wrapper for ks-av1 to create graphical interfaces.
===================================================================
### TRACKS/CONFIG DETECT:
```shell
$ ks-av1-wrapper --show-info <video_file>
$ ks-av1-wrapper --show-video-default <video_file>
$ ks-av1-wrapper --show-audio-default <video_file>
$ ks-av1-wrapper --show-subtitle-default <video_file>
$ ks-av1-wrapper --show-resolution-default
```
### METADATA DETECT:
```shell
$ ks-av1-wrapper --show-name-title-default <video_file>
$ ks-av1-wrapper --show-year-default
$ ks-av1-wrapper --show-genre-default
```
### CONVERT:
```shell
$ ks-av1-wrapper --conv </path/video_file> </path/output_prefix> <video-track> <audio-track> <resolution> "<name-title>" <year> "<genre>" [patch]
$ ks-av1-wrapper --conv-with-sub </path/video_file> </path/output_prefix> <video-track> <audio-track> <subs-track> <resolution> "<name-title>" <year> "<genre>" [patch]
```
### CONVERT WITH DEFAULT DETECTION (NOT RECOMMENDED):
```shell
$ ks-av1-wrapper --conv </path/video_file> </path/output_prefix>
$ ks-av1-wrapper --conv-with-sub </path/video_file> </path/output_prefix>
```
### EXAMPLES:
```shell
$ ks-av1-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 1280x534 "My video" 2018 "Comedy"
$ ks-av1-wrapper --conv-with-sub /tmp/video.mkv /tmp/output 0:0 0:1 0:3 1280x720 "My video" 2018 "Comedy"
$ ks-av1-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 1280x720 "My video" 2018 "Comedy" patch
```
### Notes:
* The option `patch` apply the `-max_muxing_queue_size 9999` patch to ffmpeg.
* If you specify a path or file with spaces, you must use quotes.
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

97
doc/ks-av1.md Normal file
View File

@ -0,0 +1,97 @@
ks-av1 - Convert video file to compact and efficient AV1 Codec.
===============================================================
### Syntax:
```shell
$ ks-av1 </absolute/path/video.mkv> </path/prefix_name>
```
### Default configuration:
* The script `ks-av1` use by default the following configuration:
```shell
- Resolution: 1280x534
- Video codec: libsvtav1
- Bitrate video: 2000k
- Audio codec: libvorbis (stereo)
- Bitrate audio: 160k
- Default Audio: spa
- Default Subtitle: spa (forced)
- Container: webm
````
* If you want to change the settings, you need to edit the `~/.ks-tools/ks-av1` file and change the following variables:
```shell
rel_size="1280x534"
vcodec="libsvtav1"
b_vcodec="2000k"
acodec="libvorbis"
b_acodec="160k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="webm"
````
* RECOMMENDED: You can use the [ks-conf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-conf.md) tool to edit the configuration.
### Example of use:
* An example of use would be the following:
```shell
$ ks-av1 /data/movies/Example.mkv /data/converted/Example
````
* Executing the command, the file will be analyzed and a wizard will be shown to select the tracks, choose the settings and define the metadata:
```shell
* Information of Example.mkv:
+ Video Tracks:
Stream #0:0: Video: h264 (High)
+ Audio Tracks:
Stream #0:1(spa): Audio: ac3
Stream #0:2(eng): Audio: ac3
+ Subtitle Tracks:
Stream #0:3(spa): Subtitle: subrip (default) (forced)
Stream #0:4(spa): Subtitle: hdmv_pgs_subtitle
Stream #0:5(spa): Subtitle: subrip (forced)
Stream #0:6(eng): Subtitle: subrip
* (Default: 0:0) Type the number of video track:
* (Default: 0:1) Type the number of audio track:
* (Default: n) Do you want include subtitles? (y/n): y
* (Default: 0:3) Type the number of subtitle track: 0:5
* (Default: 1280x534) Type the resolution:
* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): n
* METADATA configuration:
* (Default: Example) Type name of title:
* (Default: 2021) Type the year: 2016
* (Default: Unknown) Type the genre: Thriller
* COMMANDS THAT WILL BE EXECUTED:
# Extract subtitles from file Example.mkv
ffmpeg -i "Example.mkv" -map 0:5 "Example.srt"
# Convert the file 'Example.mkv' to MP4
ffmpeg -i "Example.mkv" -fps_mode cfr -af aresample=async=1 -map 0:0 -map 0:1
-vf subtitles="Example.srt" -s 1280x534 -c:v libsvtav1 -profile:v main -b:v 2000k
-c:a libvorbis -b:a 160k -ac 2 -clev 3dB -slev -6dB -metadata title="Example (2016)"
-metadata date="2016" -metadata genre="Thriller" -metadata:s:v:0 title="Example (2016)"
-metadata:s:a:0 title="aac Stereo Audio (256k)" "Example.webm"
* (Default: y) Do you want run the conversion? (y/n): n
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

55
doc/ks-av1s-folder.md Normal file
View File

@ -0,0 +1,55 @@
ks-av1s-folder - Convert videos from folder to AV1 Codec (Series).
==================================================================
### Syntax:
```shell
$ ks-av1s-folder </path/folder> [subs]
```
### Examples:
* Convert without subtitles:
```shell
$ ks-av1s-folder /data/Westworld
````
* Convert with subtitles:
```shell
$ ks-av1s-folder /data/Daredevil subs
````
* When executing the command you will see the following wizard:
```shell
* Scanning /data/Westworld
+ Video file(s) in .mkv found!
* Files to convert (/data/Westworld):
+ Westworld-1x01.mkv (without subtitles)
+ Westworld-1x02.mkv (without subtitles)
+ Westworld-1x03.mkv (without subtitles)
+ Westworld-1x04.mkv (without subtitles)
+ Westworld-1x05.mkv (without subtitles)
+ Westworld-1x06.mkv (without subtitles)
+ Westworld-1x07.mkv (without subtitles)
+ Westworld-1x08.mkv (without subtitles)
+ Westworld-1x09.mkv (without subtitles)
+ Westworld-1x10.mkv (without subtitles)
* The output folder will be '/data/Westworld/to-mp4'
* (Default: y) Do you want run the conversion? (y/n): n
````
### Notes:
* The option `subs` apply detection & rendering the forced subtitles.
* You must not use spaces in folders and video files.
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

52
doc/ks-av1s-wrapper.md Normal file
View File

@ -0,0 +1,52 @@
ks-av1s-wrapper - Wrapper for ks-av1s to create graphical interfaces.
=====================================================================
### TRACKS/CONFIG DETECT:
```shell
$ ks-av1s-wrapper --show-info <video_file>
$ ks-av1s-wrapper --show-video-default <video_file>
$ ks-av1s-wrapper --show-audio-default <video_file>
$ ks-av1s-wrapper --show-subtitle-default <video_file>
$ ks-av1s-wrapper --show-resolution-default
```
### METADATA DETECT:
```shell
$ ks-av1s-wrapper --show-name-title-default <video_file>
$ ks-av1s-wrapper --show-year-default
$ ks-av1s-wrapper --show-genre-default
```
### CONVERT:
```shell
$ ks-av1s-wrapper --conv </path/video_file> </path/output_prefix> <video-track> <audio-track> <resolution> "<name-title>" <year> "<genre>" [patch]
$ ks-av1s-wrapper --conv-with-sub </path/video_file> </path/output_prefix> <video-track> <audio-track> <subs-track> <resolution> "<name-title>" <year> "<genre>" [patch]
```
### CONVERT WITH DEFAULT DETECTION (NOT RECOMMENDED):
```shell
$ ks-av1s-wrapper --conv </path/video_file> </path/output_prefix>
$ ks-av1s-wrapper --conv-with-sub </path/video_file> </path/output_prefix>
```
### EXAMPLES:
```shell
$ ks-av1s-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 720x404 "My video" 2018 "Comedy"
$ ks-av1s-wrapper --conv-with-sub /tmp/video.mkv /tmp/output 0:0 0:1 0:3 1280x720 "My video" 2018 "Comedy"
$ ks-av1s-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 720x480 "My video" 2018 "Comedy" patch
```
### Notes:
* The option `patch` apply the `-max_muxing_queue_size 9999` patch to ffmpeg.
* If you specify a path or file with spaces, you must use quotes.
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

97
doc/ks-av1s.md Normal file
View File

@ -0,0 +1,97 @@
ks-av1s - Convert video file to compact and efficient AV1 Codec (Series).
=========================================================================
### Syntax:
```shell
$ ks-av1s </absolute/path/video.mkv> </path/prefix_name>
```
### Default configuration:
* The script `ks-av1s` use by default the following configuration:
```shell
- Resolution: 720x480
- Video codec: libsvtav1
- Bitrate video: 850k
- Audio codec: libvorbis (stereo)
- Bitrate audio: 128k
- Default Audio: spa
- Default Subtitle: spa (forced)
- Container: webm
````
* If you want to change the settings, you need to edit the `~/.ks-tools/ks-av1s` file and change the following variables:
```shell
rel_size="720x480"
vcodec="libsvtav1"
b_vcodec="850k"
acodec="libvorbis"
b_acodec="128k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="webm"
````
* RECOMMENDED: You can use the [ks-conf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-conf.md) tool to edit the configuration.
### Example of use:
* An example of use would be the following:
```shell
$ ks-av1s /data/movies/Example.mkv /data/converted/Example
````
* Executing the command, the file will be analyzed and a wizard will be shown to select the tracks, choose the settings and define the metadata:
```shell
* Information of Example.mkv:
+ Video Tracks:
Stream #0:0: Video: h264 (High)
+ Audio Tracks:
Stream #0:1(spa): Audio: ac3
Stream #0:2(eng): Audio: ac3
+ Subtitle Tracks:
Stream #0:3(spa): Subtitle: subrip (default) (forced)
Stream #0:4(spa): Subtitle: hdmv_pgs_subtitle
Stream #0:5(spa): Subtitle: subrip (forced)
Stream #0:6(eng): Subtitle: subrip
* (Default: 0:0) Type the number of video track:
* (Default: 0:1) Type the number of audio track:
* (Default: n) Do you want include subtitles? (y/n): y
* (Default: 0:3) Type the number of subtitle track: 0:5
* (Default: 720x480) Type the resolution:
* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): n
* METADATA configuration:
* (Default: Example) Type name of title:
* (Default: 2021) Type the year: 2016
* (Default: Unknown) Type the genre: Thriller
* COMMANDS THAT WILL BE EXECUTED:
# Extract subtitles from file Example.mkv
ffmpeg -i "Example.mkv" -map 0:5 "Example.srt"
# Convert the file 'Example.mkv' to MP4
ffmpeg -i "Example.mkv" -fps_mode cfr -af aresample=async=1 -map 0:0 -map 0:1
-vf subtitles="Example.srt" -s 720x480 -c:v libsvtav1 -profile:v main -b:v 850k
-c:a libvorbis -b:a 128k -ac 2 -clev 3dB -slev -6dB -metadata title="Example"
-metadata date="2016" -metadata genre="Thriller" -metadata:s:v:0 title="Example"
-metadata:s:a:0 title="aac Stereo Audio (128k)" "Example.webm"
* (Default: y) Do you want run the conversion? (y/n): n
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

52
doc/ks-avi-wrapper.md Normal file
View File

@ -0,0 +1,52 @@
ks-avi-wrapper - Wrapper for ks-avi to create graphical interfaces.
===================================================================
### TRACKS/CONFIG DETECT:
```shell
$ ks-avi-wrapper --show-info <video_file>
$ ks-avi-wrapper --show-video-default <video_file>
$ ks-avi-wrapper --show-audio-default <video_file>
$ ks-avi-wrapper --show-subtitle-default <video_file>
$ ks-avi-wrapper --show-resolution-default
````
### METADATA DETECT:
```shell
$ ks-avi-wrapper --show-name-title-default <video_file>
$ ks-avi-wrapper --show-year-default
$ ks-avi-wrapper --show-genre-default
```
### CONVERT:
```shell
$ ks-avi-wrapper --conv </path/video_file> </path/output_prefix> <video-track> <audio-track> <resolution> "<name-title>" <year> "<genre>" [patch]
$ ks-avi-wrapper --conv-with-sub </path/video_file> </path/output_prefix> <video-track> <audio-track> <subs-track> <resolution> "<name-title>" <year> "<genre>" [patch]
```
### CONVERT WITH DEFAULT DETECTION (NOT RECOMMENDED):
```shell
$ ks-avi-wrapper --conv </path/video_file> </path/output_prefix>
$ ks-avi-wrapper --conv-with-sub </path/video_file> </path/output_prefix>
```
### EXAMPLES:
```shell
$ ks-avi-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 720x480 "My video" 2018 "Comedy"
$ ks-avi-wrapper --conv-with-sub /tmp/video.mkv /tmp/output 0:0 0:1 0:3 1280x720 "My video" 2018 "Comedy"
$ ks-avi-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 720x404 "My video" 2018 "Comedy" patch
```
### Notes:
* The option `patch` apply the `-max_muxing_queue_size 9999` patch to ffmpeg.
* If you specify a path or file with spaces, you must use quotes.
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

99
doc/ks-avi.md Normal file
View File

@ -0,0 +1,99 @@
ks-avi - Convert video file to compact and efficient AVI.
=========================================================
### Syntax:
```shell
$ ks-avi </absolute/path/video.mkv> </path/prefix_name>
```
### Default configuration:
* The script `ks-avi` use by default the following configuration:
```shell
- Resolution: 720x480
- Video codec: libxvid
- Bitrate video: 3000k
- Preset: slow
- Audio codec: libmp3lame (stereo)
- Bitrate audio: 192k
- Default Audio: spa
- Default Subtitle: spa (forced)
- Container: avi
````
* If you want to change the settings, you need to edit the `~/.ks-tools/ks-avi` file and change the following variables:
```shell
rel_size="720x480"
vcodec="libxvid"
b_vcodec="3000k"
v_preset="slow"
acodec="libmp3lame"
b_acodec="192k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="avi"
````
* RECOMMENDED: You can use the [ks-conf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-conf.md) tool to edit the configuration.
### Example of use:
* An example of use would be the following:
```shell
$ ks-avi /data/movies/Example.mkv /data/converted/Example
````
* Executing the command, the file will be analyzed and a wizard will be shown to select the tracks, choose the settings and define the metadata:
```shell
* Information of Example.mkv:
+ Video Tracks:
Stream #0:0: Video: h264 (High)
+ Audio Tracks:
Stream #0:1(spa): Audio: ac3
Stream #0:2(eng): Audio: ac3
+ Subtitle Tracks:
Stream #0:3(spa): Subtitle: subrip (default) (forced)
Stream #0:4(spa): Subtitle: hdmv_pgs_subtitle
Stream #0:5(spa): Subtitle: subrip (forced)
Stream #0:6(eng): Subtitle: subrip
* (Default: 0:0) Type the number of video track:
* (Default: 0:1) Type the number of audio track:
* (Default: n) Do you want include subtitles? (y/n): y
* (Default: 0:3) Type the number of subtitle track: 0:5
* (Default: 720x480) Type the resolution:
* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): n
* METADATA configuration:
* (Default: Example) Type name of title:
* (Default: 2021) Type the year: 2016
* (Default: Unknown) Type the genre: Thriller
* COMMANDS THAT WILL BE EXECUTED:
# Extract subtitles from file Example.mkv
ffmpeg -i "Example.mkv" -map 0:5 "Example.srt"
# Convert the file 'Example.mkv' to AVI
ffmpeg -i "Example.mkv" -fps_mode cfr -af aresample=async=1 -map 0:0 -map 0:1
-vf subtitles="Example.srt" -s 720x480 -c:v libxvid -b:v 3000k -preset slow
-c:a libmp3lame -b:a 192k -ac 2 -clev 3dB -slev -6dB -metadata title="Example (2016)"
-metadata date="2016" -metadata genre="Thriller" -metadata:s:v:0 title="Example (2016)"
-metadata:s:a:0 title="libmp3lame Stereo Audio (192k)" "Example.avi"
* (Default: y) Do you want run the conversion? (y/n): n
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

71
doc/ks-conf.md Normal file
View File

@ -0,0 +1,71 @@
ks-conf - Tool for create and modify configuration files
========================================================
### Syntax:
```shell
$ ks-conf
```
### Main menu
* If you run the command `ks-conf` will see the following menu for editing the diferent configuration files:
```shell
m - Edit ks-mp4 config (1280x534/libx264/2400k/aac/256k/spa)
k - Edit ks-mp4k config (3840x2160/libx264/6000k/aac/320k/spa)
s - Edit ks-mp4s config (720x480/libx264/950k/aac/128k/spa)
a - Edit ks-avi config (720x480/libxvid/3000k/libmp3lame/192k/spa)
p - Edit ks-mp3/ks-mp3-album config (libmp3lame/128k/spa)
o - Edit ks-oga/ks-oga-album config (libvorbis/130k/spa)
u - Edit ks-upv/ks-upa/ks-upf/ks-upr config (myuser/qmyserver.com)
q - Exit
* Choose an option (m/k/s/a/p/o/q):
````
### Editing config of video tools:
* If you select option `m`,`k`,`s` or `a` will see the following menu:
```shell
* Editing /home/q3aql/.ks-tools/ks-mp4
r - Edit resolution (1280x534)
v - Edit video codec (libx264)
b - Edit video bitrate (2400k)
p - Edit video preset (medium)
a - Edit audio codec (aac)
i - Edit audio bitrate (256k)
l - Edit preferred language (spa)
s - Edit preferred subtitles (spa)
c - Reset configuration file
q - Exit to main menu
* Choose an option (r/v/b/p/a/i/l/s/q):
````
### Editing config of audio tools:
* If you select option `p` or `o` will see the following menu:
```shell
* Editing /home/q3aql/.ks-tools/ks-mp3
a - Edit audio bitrate (128k)
l - Edit preferred language (spa)
c - Reset configuration file
q - Exit to main menu
* Choose an option (a/l/c/q):
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

124
doc/ks-crop.md Normal file
View File

@ -0,0 +1,124 @@
ks-crop - Crop or change aspect ratio of a video.
=================================================
### Syntax:
```shell
$ ks-crop -16:9-crop <video-file> --> Crop from 4:3/IMAX to 16:9 (1.77:1)
$ ks-crop -4:3-crop <video-file> --> Crop from 16:9 to 4:3 (1.33:1)
$ ks-crop -5:4-crop <video-file> --> Crop from 16:9 to 5:4 (1.25:1)
$ ks-crop -imax-crop <video-file> --> Crop from 16:9 to IMAX (1.43:1)
$ ks-crop -16:9-aspect <video-file> --> Change aspect to 16:9 (stretched)
$ ks-crop -4:3-aspect <video-file> --> Change aspect to 4:3 (stretched)
$ ks-crop -5:4-aspect <video-file> --> Change aspect to 5:4 (stretched)
```
### Default configuration:
* The script `ks-crop` use by default the following configuration:
```shell
- Video codec: libx264
- Bitrate video: 5000k
- Preset: medium
- Audio codec: copy
- Default Audio: spa
- Container: mkv
````
* If you want to change the settings, you need to edit the `ks-crop` file and change the following variables:
```shell
v_preset="medium"
vcodec="libx264"
b_vcodec="5000k"
acodec="copy"
v_ext="mkv"
default_lang_audio="spa"
````
### Examples (Crop):
* Crop from 4:3/IMAX to 16:9 (1.77:1):
```shell
$ ks-crop -16:9-crop /data/movies/Example.mkv
````
* Crop from 16:9 to 4:3 (1.33:1):
```shell
$ ks-crop -4:3-crop /data/movies/Example.mkv
````
* Crop from 16:9 to 5:4 (1.25:1):
```shell
$ ks-crop -5:4-crop /data/movies/Example.mkv
````
* Crop from 16:9 to IMAX (1.43:1):
```shell
$ ks-crop -imax-crop /data/movies/Example.mkv
````
_Note: Output file name will be `Example-crop.mkv`._
### Examples (Change aspect):
* Change aspect to 16:9 (stretched):
```shell
$ ks-crop -16:9-aspect /data/movies/Example.mkv
````
* Change aspect to 4:3 (stretched):
```shell
$ ks-crop -4:3-aspect /data/movies/Example.mkv
````
* Change aspect to 5:4 (stretched):
```shell
$ ks-crop -5:4-aspect /data/movies/Example.mkv
````
_Note: Output file name will be `Example-aspect.mkv`_
### Execution:
* After executing one of the mentioned commands, a wizard will be displayed to choose the video/audio tracks and define some parameters:
```shell
* Information of Example.mkv:
+ Video Tracks:
Stream #0:0(eng): Video: h264 (High)
+ Audio Tracks:
Stream #0:1(spa): Audio: dts (DTS)
Stream #0:2(spa): Audio: ac3
Stream #0:3(eng): Audio: ac3
* (Default: 0:0) Type the number of video track:
* (Default: 0:1) Type the number of audio track:
* (Default: 5000k) Type the bitrate (libx264):
* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): n
* COMMAND THAT WILL BE EXECUTED:
# Crop 'Example.mkv' from 16:9 to 4:3 (1.33:1)
ffmpeg -i Example.mkv -fps_mode cfr -af aresample=async=1 -map 0:0 -map 0:1
-filter:v "crop=ih/3*4:ih" -s 1920x1440 -c:v libx264 -profile:v high
-b:v 5000k -preset medium -c:a copy Example-crop.mkv
* (Default: y) Do you want run the conversion? (y/n): n
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

109
doc/ks-mix.md Normal file
View File

@ -0,0 +1,109 @@
ks-mix - Extract video/audio and mix video/audio files.
=======================================================
### Syntax:
```shell
$ ks-mix -evid <video-file> --> Extract video track
$ ks-mix -ev25 <video-file> --> Extract video track to 25 fps (H264/5 & MPEG4)
$ ks-mix -evpf <video-file> --> Extract video track & set fps (H264/5 & MPEG4)
$ ks-mix -eaud <video-file> --> Extract audio track
$ ks-mix -esub <video-file> --> Extract subtitle track (only for subrip/srt)
$ ks-mix -evti <video-file> --> Extract video from a specific hour/minute/second
$ ks-mix -eati <video-file> --> Extract audio from a specific hour/minute/second
$ ks-mix -evat <video-file> --> Extract video + audio from specific time
$ ks-mix -chec <video-file> --> Analyze tracks of video file
$ ks-mix -mixf --> Mix video and audio file
$ ks-mix -mixs --> Mix video, audio and subtitle file
```
### Examples (Extract video/audio):
* Extract video from video file:
```shell
$ ks-mix -evid /data/movies/Example.mkv
````
* Extract audio from video file:
```shell
$ ks-mix -eaud /data/movies/Example.avi
````
* Extract subtitles from video file:
```shell
$ ks-mix -esub /data/movies/Example.mkv
````
* Extract video from video file and change FPS to 25:
```shell
$ ks-mix -ev25 /data/movies/Example.mkv
````
* Extract video from video file and change to custom FPS:
```shell
$ ks-mix -evpf /data/movies/Example.mkv
````
_Note: Extracted video will be named `video.mkv` and extracted audio will be named `audio.mka`_
### Examples (Extract video/audio by cutting time):
* Extract video from a specific hour/minute/second:
```shell
$ ks-mix -evti /data/movies/Example.mkv
````
* Extract audio from a specific hour/minute/second:
```shell
$ ks-mix -eati /data/movies/Example.avi
````
* Extract video + audio from a hour/minute/second:
```shell
$ ks-mix -evat /data/movies/Example.mkv
````
_Note: After executing the command, an assistant will ask us from what hour, minute and second we want to cut the video. We can cut it to the end or the specified time._
### Examples (Mix video/audio):
* If you have extracted video and audio from different files, when you run the `ks-mix` command you will see the following:
```shell
+ Video file: /current/dir/video.mkv (FOUND)
+ Audio file: /current/dir/audio.mka (FOUND)
+ Subs file: /current/dir/subs.srt (NOT FOUND)
````
* Next, run the following command to merge the video and audio:
```shell
$ ks-mix -mixf
````
* Finally, you will see a wizard that will allow you to crop seconds of video or audio to synchronize them:
```shell
* [Default: 0] Set the seconds to cut in the video (0-59): 3
* [Default: 0] Set the seconds to cut in the audio (0-59): 1
* [Default: n] Finish the mix when one of the two (video or audio) finishes first? (y/n): y
* Starting mix of:`
- Video: /home/q3aql/.torrent/Conv/video.mkv
- Audio: /home/q3aql/.torrent/Conv/audio.mka
Output file: /home/q3aql/.torrent/Conv/output.mkv
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

65
doc/ks-mp3-album.md Normal file
View File

@ -0,0 +1,65 @@
ks-mp3-album - Convert folder album to MP3 Audio Format.
========================================================
### Syntax:
```shell
$ ks-mp3-album </absolute/path/album>
```
### Default configuration:
* The script `ks-mp3-album` use by default the following configuration:
```shell
- Audio codec: libmp3lame
- Bitrate audio: 128k
- Container: oga
````
* If you want to change the settings, you need to edit the `~/.ks-tools/ks-mp3` file and change the following variables:
```shell
acodec="libmp3lame"
b_acodec="128k"
v_ext="mp3"
default_lang_audio="spa"
````
* RECOMMENDED: You can use the [ks-conf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-conf.md) tool to edit the configuration.
### Example of use:
* An example of use would be the following:
```shell
$ ks-mp3-album /data/albums/matrix-soundtrack
````
* Executing the command, the folder will be analized and you can see the following wizard:
```shell
* Scanning /data/albums/matrix-soundtrack
+ Video file(s) in .mp4 found!
* Common METADATA configuration:
* (Default: Album-Disc) Type name of album: Matrix Soundtrack
* (Default: 2021) Type the year of album: 1999
* (Default: Pop) Type the genre of album: Original Motion Picture Soundtrack
* List of files:
+ track01.mp4
+ track02.mp4
+ track03.mp4
* The output folder will be '/data/albums/matrix-soundtrack/to-mp3'
* (Default: y) Do you want run the conversion? (y/n): y
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

73
doc/ks-mp3.md Normal file
View File

@ -0,0 +1,73 @@
ks-mp3 - Convert video/audio file to MP3 (Audio) Format.
========================================================
### Syntax:
```shell
$ ks-mp3 </absolute/path/song.ogg> </path/prefix_name>
```
### Default configuration:
* The script `ks-mp3` use by default the following configuration:
```shell
- Audio codec: libmp3lame
- Bitrate audio: 128k
- Container: mp3
````
* If you want to change the settings, you need to edit the `~/.ks-tools/ks-mp3` file and change the following variables:
```shell
acodec="libmp3lame"
b_acodec="128k"
v_ext="mp3"
default_lang_audio="spa"
````
* RECOMMENDED: You can use the [ks-conf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-conf.md) tool to edit the configuration.
### Example of use:
* An example of use would be the following:
```shell
$ ks-mp3 /data/video/Example.mkv /data/audio/Example
````
* Executing the command, the file will be analyzed and a wizard will be shown to select the tracks, choose the settings and define the metadata:
```shell
* Information of Example.mkv:
+ Audio Tracks:
Stream #0:1(spa): Audio: ac3
Stream #0:2(eng): Audio: ac3
* (Default: 0:1) Type the number of audio track:
* METADATA configuration:
* (Default: Example) Type name of title: My song
* (Default: Album-Disc) Type name of album: My personal album
* (Default: 01) Type number of track: 2
* (Default: Artist) Type name of artist: q3aql
* (Default: 2021) Type the year: 2016
* (Default: Pop) Type the genre: Rap
* COMMANDS THAT WILL BE EXECUTED:
# Convert the file 'Example.mkv' to MP3 Audio
ffmpeg -i "Example.mkv" -map 0:1 -c:a libmp3lame -b:a 128k
-metadata title="My song" -metadata date="2016" -metadata genre="Rap"
-metadata album="My personal album" -metadata artist="q3aql"
-metadata track="2" "Example.mp3"
* (Default: y) Do you want run the conversion? (y/n): n
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

52
doc/ks-mp4-wrapper.md Normal file
View File

@ -0,0 +1,52 @@
ks-mp4-wrapper - Wrapper for ks-mp4 to create graphical interfaces.
===================================================================
### TRACKS/CONFIG DETECT:
```shell
$ ks-mp4-wrapper --show-info <video_file>
$ ks-mp4-wrapper --show-video-default <video_file>
$ ks-mp4-wrapper --show-audio-default <video_file>
$ ks-mp4-wrapper --show-subtitle-default <video_file>
$ ks-mp4-wrapper --show-resolution-default
```
### METADATA DETECT:
```shell
$ ks-mp4-wrapper --show-name-title-default <video_file>
$ ks-mp4-wrapper --show-year-default
$ ks-mp4-wrapper --show-genre-default
```
### CONVERT:
```shell
$ ks-mp4-wrapper --conv </path/video_file> </path/output_prefix> <video-track> <audio-track> <resolution> "<name-title>" <year> "<genre>" [patch]
$ ks-mp4-wrapper --conv-with-sub </path/video_file> </path/output_prefix> <video-track> <audio-track> <subs-track> <resolution> "<name-title>" <year> "<genre>" [patch]
```
### CONVERT WITH DEFAULT DETECTION (NOT RECOMMENDED):
```shell
$ ks-mp4-wrapper --conv </path/video_file> </path/output_prefix>
$ ks-mp4-wrapper --conv-with-sub </path/video_file> </path/output_prefix>
```
### EXAMPLES:
```shell
$ ks-mp4-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 1280x534 "My video" 2018 "Comedy"
$ ks-mp4-wrapper --conv-with-sub /tmp/video.mkv /tmp/output 0:0 0:1 0:3 1280x720 "My video" 2018 "Comedy"
$ ks-mp4-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 1280x720 "My video" 2018 "Comedy" patch
```
### Notes:
* The option `patch` apply the `-max_muxing_queue_size 9999` patch to ffmpeg.
* If you specify a path or file with spaces, you must use quotes.
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

View File

@ -0,0 +1,100 @@
ks-mp4 - Convert video file to compact and efficient MP4.
=========================================================
### Syntax:
```shell
$ ks-mp4 </absolute/path/video.mkv> </path/prefix_name>
```
### Default configuration:
* The script `ks-mp4` use by default the following configuration:
```shell
- Resolution: 1280x534
- Video codec: libx264
- Bitrate video: 2200k
- Preset: slow
- Audio codec: aac (stereo)
- Bitrate audio: 192k
- Default Audio: spa
- Default Subtitle: spa (forced)
- Container: mp4
````
* If you want to change the settings, you need to edit the `~/.ks-tools/ks-mp4` file and change the following variables:
```shell
rel_size="1280x534"
vcodec="libx264"
b_vcodec="2200k"
v_preset="slow"
acodec="aac"
b_acodec="192k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="mp4"
````
* RECOMMENDED: You can use the [ks-conf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-conf.md) tool to edit the configuration.
### Example of use:
* An example of use would be the following:
```shell
$ ks-mp4 /data/movies/Example.mkv /data/converted/Example
````
* Executing the command, the file will be analyzed and a wizard will be shown to select the tracks, choose the settings and define the metadata:
```shell
* Information of Example.mkv:
+ Video Tracks:
Stream #0:0: Video: h264 (High)
+ Audio Tracks:
Stream #0:1(spa): Audio: ac3
Stream #0:2(eng): Audio: ac3
+ Subtitle Tracks:
Stream #0:3(spa): Subtitle: subrip (default) (forced)
Stream #0:4(spa): Subtitle: hdmv_pgs_subtitle
Stream #0:5(spa): Subtitle: subrip (forced)
Stream #0:6(eng): Subtitle: subrip
* (Default: 0:0) Type the number of video track:
* (Default: 0:1) Type the number of audio track:
* (Default: n) Do you want include subtitles? (y/n): y
* (Default: 0:3) Type the number of subtitle track: 0:5
* (Default: 1280x534) Type the resolution:
* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): n
* METADATA configuration:
* (Default: Example) Type name of title:
* (Default: 2021) Type the year: 2016
* (Default: Unknown) Type the genre: Thriller
* COMMANDS THAT WILL BE EXECUTED:
# Extract subtitles from file Example.mkv
ffmpeg -i "Example.mkv" -map 0:5 "Example.srt"
# Convert the file 'Example.mkv' to MP4
ffmpeg -i "Example.mkv" -fps_mode cfr -af aresample=async=1 -map 0:0 -map 0:1
-vf subtitles="Example.srt" -s 1280x534 -c:v libx264 -profile:v high
-b:v 2400k -preset medium -c:a aac -b:a 256k -ac 2 -clev 3dB -slev -6dB
-metadata title="Example (2016)" -metadata date="2016" -metadata genre="Thriller"
-metadata:s:v:0 title="Example (2016)"
-metadata:s:a:0 title="aac Stereo Audio (256k)" "Example.mp4"
* (Default: y) Do you want run the conversion? (y/n): n
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

52
doc/ks-mp4k-wrapper.md Normal file
View File

@ -0,0 +1,52 @@
ks-mp4k-wrapper - Wrapper for ks-mp4k to create graphical interfaces.
=====================================================================
### TRACKS/CONFIG DETECT:
```shell
$ ks-mp4k-wrapper --show-info <video_file>
$ ks-mp4k-wrapper --show-video-default <video_file>
$ ks-mp4k-wrapper --show-audio-default <video_file>
$ ks-mp4k-wrapper --show-subtitle-default <video_file>
$ ks-mp4k-wrapper --show-resolution-default
```
### METADATA DETECT:
```shell
$ ks-mp4k-wrapper --show-name-title-default <video_file>
$ ks-mp4k-wrapper --show-year-default
$ ks-mp4k-wrapper --show-genre-default
```
### CONVERT:
```shell
$ ks-mp4k-wrapper --conv </path/video_file> </path/output_prefix> <video-track> <audio-track> <resolution> "<name-title>" <year> "<genre>" [patch]
$ ks-mp4k-wrapper --conv-with-sub </path/video_file> </path/output_prefix> <video-track> <audio-track> <subs-track> <resolution> "<name-title>" <year> "<genre>" [patch]
```
### CONVERT WITH DEFAULT DETECTION (NOT RECOMMENDED):
```shell
$ ks-mp4k-wrapper --conv </path/video_file> </path/output_prefix>
$ ks-mp4k-wrapper --conv-with-sub </path/video_file> </path/output_prefix>
```
### EXAMPLES:
```shell
$ ks-mp4k-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 3840x2160 "My video" 2018 "Comedy"
$ ks-mp4k-wrapper --conv-with-sub /tmp/video.mkv /tmp/output 0:0 0:1 0:3 1280x720 "My video" 2018 "Comedy"
$ ks-mp4k-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 3840x2160 "My video" 2018 "Comedy" patch
```
### Notes:
* The option `patch` apply the `-max_muxing_queue_size 9999` patch to ffmpeg.
* If you specify a path or file with spaces, you must use quotes.
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

100
doc/ks-mp4k.md Normal file
View File

@ -0,0 +1,100 @@
ks-mp4k - Convert video file to compact and efficient MP4 (4K).
===============================================================
### Syntax:
```shell
$ ks-mp4k </absolute/path/video.mkv> </path/prefix_name>
```
### Default configuration:
* The script `ks-mp4k` use by default the following configuration:
```shell
- Resolution: 3840x2160
- Video codec: libx264
- Bitrate video: 6000k
- Preset: medium
- Audio codec: aac (stereo)
- Bitrate audio: 320k
- Default Audio: spa
- Default Subtitle: spa (forced)
- Container: mp4
````
* If you want to change the settings, you need to edit the `~/.ks-tools/ks-mp4k` file and change the following variables:
```shell
rel_size="3840x2160"
vcodec="libx264"
b_vcodec="6000k"
v_preset="medium"
acodec="aac"
b_acodec="320k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="mp4"
````
* RECOMMENDED: You can use the [ks-conf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-conf.md) tool to edit the configuration.
### Example of use:
* An example of use would be the following:
```shell
$ ks-mp4k /data/movies/Example.mkv /data/converted/Example
````
* Executing the command, the file will be analyzed and a wizard will be shown to select the tracks, choose the settings and define the metadata:
```shell
* Information of Example.mkv:
+ Video Tracks:
Stream #0:0: Video: h264 (High)
+ Audio Tracks:
Stream #0:1(spa): Audio: ac3
Stream #0:2(eng): Audio: ac3
+ Subtitle Tracks:
Stream #0:3(spa): Subtitle: subrip (default) (forced)
Stream #0:4(spa): Subtitle: hdmv_pgs_subtitle
Stream #0:5(spa): Subtitle: subrip (forced)
Stream #0:6(eng): Subtitle: subrip
* (Default: 0:0) Type the number of video track:
* (Default: 0:1) Type the number of audio track:
* (Default: n) Do you want include subtitles? (y/n): y
* (Default: 0:3) Type the number of subtitle track: 0:5
* (Default: 3840x2160) Type the resolution:
* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): n
* METADATA configuration:
* (Default: Example) Type name of title:
* (Default: 2021) Type the year: 2016
* (Default: Unknown) Type the genre: Thriller
* COMMANDS THAT WILL BE EXECUTED:
# Extract subtitles from file Example.mkv
ffmpeg -i "Example.mkv" -map 0:5 "Example.srt"
# Convert the file 'Example.mkv' to MP4
ffmpeg -i "Example.mkv" -fps_mode cfr -af aresample=async=1 -map 0:0 -map 0:1
-vf subtitles="Example.srt" -s 3840x2160 -c:v libx264 -profile:v high
-b:v 6000k -preset medium -c:a aac -b:a 320k -ac 2 -clev 3dB -slev -6dB
-metadata title="Example (2016)" -metadata date="2016" -metadata genre="Thriller"
-metadata:s:v:0 title="Example (2016)"
-metadata:s:a:0 title="aac Stereo Audio (320k)" "Example.mp4"
* (Default: y) Do you want run the conversion? (y/n): n
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

55
doc/ks-mp4s-folder.md Normal file
View File

@ -0,0 +1,55 @@
ks-mp4s-folder - Convert videos from folder to MP4 format (Series).
===================================================================
### Syntax:
```shell
$ ks-mp4s-folder </path/folder> [subs]
```
### Examples:
* Convert without subtitles:
```shell
$ ks-mp4s-folder /data/Westworld
````
* Convert with subtitles:
```shell
$ ks-mp4s-folder /data/Daredevil subs
````
* When executing the command you will see the following wizard:
```shell
* Scanning /data/Westworld
+ Video file(s) in .mkv found!
* Files to convert (/data/Westworld):
+ Westworld-1x01.mkv (without subtitles)
+ Westworld-1x02.mkv (without subtitles)
+ Westworld-1x03.mkv (without subtitles)
+ Westworld-1x04.mkv (without subtitles)
+ Westworld-1x05.mkv (without subtitles)
+ Westworld-1x06.mkv (without subtitles)
+ Westworld-1x07.mkv (without subtitles)
+ Westworld-1x08.mkv (without subtitles)
+ Westworld-1x09.mkv (without subtitles)
+ Westworld-1x10.mkv (without subtitles)
* The output folder will be '/data/Westworld/to-mp4'
* (Default: y) Do you want run the conversion? (y/n): n
````
### Notes:
* The option `subs` apply detection & rendering the forced subtitles.
* You must not use spaces in folders and video files.
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

52
doc/ks-mp4s-wrapper.md Normal file
View File

@ -0,0 +1,52 @@
ks-mp4s-wrapper - Wrapper for ks-mp4s to create graphical interfaces.
===================================================================
### TRACKS/CONFIG DETECT:
```shell
$ ks-mp4s-wrapper --show-info <video_file>
$ ks-mp4s-wrapper --show-video-default <video_file>
$ ks-mp4s-wrapper --show-audio-default <video_file>
$ ks-mp4s-wrapper --show-subtitle-default <video_file>
$ ks-mp4s-wrapper --show-resolution-default
```
### METADATA DETECT:
```shell
$ ks-mp4s-wrapper --show-name-title-default <video_file>
$ ks-mp4s-wrapper --show-year-default
$ ks-mp4s-wrapper --show-genre-default
```
### CONVERT:
```shell
$ ks-mp4s-wrapper --conv </path/video_file> </path/output_prefix> <video-track> <audio-track> <resolution> "<name-title>" <year> "<genre>" [patch]
$ ks-mp4s-wrapper --conv-with-sub </path/video_file> </path/output_prefix> <video-track> <audio-track> <subs-track> <resolution> "<name-title>" <year> "<genre>" [patch]
```
### CONVERT WITH DEFAULT DETECTION (NOT RECOMMENDED):
```shell
$ ks-mp4s-wrapper --conv </path/video_file> </path/output_prefix>
$ ks-mp4s-wrapper --conv-with-sub </path/video_file> </path/output_prefix>
```
### EXAMPLES:
```shell
$ ks-mp4s-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 720x404 "My video" 2018 "Comedy"
$ ks-mp4s-wrapper --conv-with-sub /tmp/video.mkv /tmp/output 0:0 0:1 0:3 1280x720 "My video" 2018 "Comedy"
$ ks-mp4s-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 720x480 "My video" 2018 "Comedy" patch
```
### Notes:
* The option `patch` apply the `-max_muxing_queue_size 9999` patch to ffmpeg.
* If you specify a path or file with spaces, you must use quotes.
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

100
doc/ks-mp4s.md Normal file
View File

@ -0,0 +1,100 @@
ks-mp4s - Convert video file to compact and efficient MP4 (Series).
===================================================================
### Syntax:
```shell
$ ks-mp4s </absolute/path/video.mkv> </path/prefix_name>
```
### Default configuration:
* The script `ks-mp4s` use by default the following configuration:
```shell
- Resolution: 720x480
- Video codec: libx264
- Bitrate video: 950k
- Preset: slow
- Audio codec: aac (stereo)
- Bitrate audio: 128k
- Default Audio: spa
- Default Subtitle: spa (forced)
- Container: mp4
````
* If you want to change the settings, you need to edit the `~/.ks-tools/ks-mp4s` file and change the following variables:
```shell
rel_size="720x480"
vcodec="libx264"
b_vcodec="950k"
v_preset="slow"
acodec="aac"
b_acodec="128k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="mp4"
````
* RECOMMENDED: You can use the [ks-conf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-conf.md) tool to edit the configuration.
### Example of use:
* An example of use would be the following:
```shell
$ ks-mp4s /data/movies/Example.mkv /data/converted/Example
````
* Executing the command, the file will be analyzed and a wizard will be shown to select the tracks, choose the settings and define the metadata:
```shell
* Information of Example.mkv:
+ Video Tracks:
Stream #0:0: Video: h264 (High)
+ Audio Tracks:
Stream #0:1(spa): Audio: ac3
Stream #0:2(eng): Audio: ac3
+ Subtitle Tracks:
Stream #0:3(spa): Subtitle: subrip (default) (forced)
Stream #0:4(spa): Subtitle: hdmv_pgs_subtitle
Stream #0:5(spa): Subtitle: subrip (forced)
Stream #0:6(eng): Subtitle: subrip
* (Default: 0:0) Type the number of video track:
* (Default: 0:1) Type the number of audio track:
* (Default: n) Do you want include subtitles? (y/n): y
* (Default: 0:3) Type the number of subtitle track: 0:5
* (Default: 720x480) Type the resolution:
* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): n
* METADATA configuration:
* (Default: Example) Type name of title:
* (Default: 2021) Type the year: 2016
* (Default: Unknown) Type the genre: Thriller
* COMMANDS THAT WILL BE EXECUTED:
# Extract subtitles from file Example.mkv
ffmpeg -i "Example.mkv" -map 0:5 "Example.srt"
# Convert the file 'Example.mkv' to MP4
ffmpeg -i "Example.mkv" -fps_mode cfr -af aresample=async=1 -map 0:0 -map 0:1
-vf subtitles="Example.srt" -s 720x480 -c:v libx264 -profile:v high
-b:v 950k -preset medium -c:a aac -b:a 128k -ac 2 -clev 3dB -slev -6dB
-metadata title="Example" -metadata date="2016" -metadata genre="Thriller"
-metadata:s:v:0 title="Example"
-metadata:s:a:0 title="aac Stereo Audio (128k)" "Example.mp4"
* (Default: y) Do you want run the conversion? (y/n): n
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

65
doc/ks-oga-album.md Normal file
View File

@ -0,0 +1,65 @@
ks-oga-album - Convert folder album to OGA (OGG Audio) Format.
==============================================================
### Syntax:
```shell
$ ks-oga-album </absolute/path/album>
```
### Default configuration:
* The script `ks-oga-album` use by default the following configuration:
```shell
- Audio codec: libvorbis
- Bitrate audio: 130k
- Container: oga
````
* If you want to change the settings, you need to edit the `~/.ks-tools/ks-oga` file and change the following variables:
```shell
acodec="libvorbis"`
b_acodec="130k"`
v_ext="oga"`
default_lang_audio="spa"`
````
* RECOMMENDED: You can use the [ks-conf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-conf.md) tool to edit the configuration.
### Example of use:
* An example of use would be the following:
```shell
$ ks-oga-album /data/albums/matrix-soundtrack
````
* Executing the command, the folder will be analized and you can see the following wizard:
```shell
* Scanning /data/albums/matrix-soundtrack
+ Video file(s) in .mp4 found!
* Common METADATA configuration:
* (Default: Album-Disc) Type name of album: Matrix Soundtrack
* (Default: 2021) Type the year of album: 1999
* (Default: Pop) Type the genre of album: Original Motion Picture Soundtrack
* List of files:
+ track01.mp4
+ track02.mp4
+ track03.mp4
* The output folder will be '/data/albums/matrix-soundtrack/to-oga'
* (Default: y) Do you want run the conversion? (y/n): y
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

73
doc/ks-oga.md Normal file
View File

@ -0,0 +1,73 @@
ks-oga - Convert video/audio file to OGA (OGG Audio) Format.
============================================================
### Syntax:
```shell
$ ks-oga </absolute/path/song.mp3> </path/prefix_name>
```
### Default configuration:
* The script `ks-oga` use by default the following configuration:
```shell
- Audio codec: libvorbis
- Bitrate audio: 130k
- Container: oga
````
* If you want to change the settings, you need to edit the `~/.ks-tools/ks-oga` file and change the following variables:
```shell
acodec="libvorbis"
b_acodec="130k"
v_ext="oga"
default_lang_audio="spa"
````
* RECOMMENDED: You can use the [ks-conf](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/doc/ks-conf.md) tool to edit the configuration.
### Example of use:
* An example of use would be the following:
```shell
$ ks-oga /data/video/Example.mkv /data/audio/Example
````
* Executing the command, the file will be analyzed and a wizard will be shown to select the tracks, choose the settings and define the metadata:
```shell
* Information of Example.mkv:
+ Audio Tracks:
Stream #0:1(spa): Audio: ac3
Stream #0:2(eng): Audio: ac3
* (Default: 0:1) Type the number of audio track:
* METADATA configuration:
* (Default: Example) Type name of title: My song
* (Default: Album-Disc) Type name of album: My personal album
* (Default: 01) Type number of track: 2
* (Default: Artist) Type name of artist: q3aql
* (Default: 2021) Type the year: 2016
* (Default: Pop) Type the genre: Rap
* COMMANDS THAT WILL BE EXECUTED:
# Convert the file 'Example.mkv' to OGG Audio
ffmpeg -i "Example.mkv" -map 0:1 -c:a libvorbis -b:a 130k
-metadata title="My song" -metadata date="2016"
-metadata genre="Rap" -metadata album="My personal album"
-metadata artist="q3aql" -metadata track="2" "Example.oga"
* (Default: y) Do you want run the conversion? (y/n): n
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

112
doc/ks-upa.md Normal file
View File

@ -0,0 +1,112 @@
ks-upa - Upload audio file(s) to server with scp or rsync.
==========================================================
### Syntax:
```shell
$ ks-upa -i - Start upload
$ ks-upa -g - Create configuration
$ ks-upa -r - Remove configuration
$ ks-upa -c - Show configuration
$ ks-upa -e - Edit configuration
$ ks-upa -p - Generate certificate
$ ks-upa -v - Show version
$ ks-upa -h - Show help
```
### Initialize audio file(s) upload:
* For initialize audio file(s) upload only run the following command:
```shell
$ ks-upa -i
````
* The first time you run the command, you will be asked for the necessary connection information:
```shell
* Enter the server user: anonymous
* Enter the server password (type 'pem' for use pem certificate): *******
* Enter the server URL (or IP): mypersonaldomain.es
* Enter the path on the server: /home/anonymous
* Enter the local path to scan: /home/local/videos
* Setting 'scp' as the default tool
* Setting port 22 as the default port
````
* Once the connection data has been entered, the local directory will be scanned to detect the audios and upload them to the server directory.
### Remove configuration:
* If you want to clear the connection settings, you just need to run the following command:
```shell
$ ks-upa -r
````
### Show configuration:
* You can check the configuration with the following command:
```shell
$ ks-upa -c
````
* When consulting the configuration, we will see something like this:
```shell
* Server User: anonymous
* Server Password/PEM: *******
* URL (or IP) Server: mypersonaldomain.es
* Destination Path (Server): /home/anonymous
* Scan Path (Local): /home/local/videos
* Upload Tool: scp
* Port Connection: 22
````
### Edit configuration:
* To edit any section of the configuration, the following command would be executed:
```shell
$ ks-upa -e
````
* After its execution, we will see a menu like the following one to be able to edit the desired section:
```shell
1 - Edit User (anonymous)
2 - Edit Password/PEM (*******)
3 - Edit Server (mypersonaldomain.es)
4 - Edit Dest. Path (/home/anonymous)
5 - Edit Local Path (/home/local/videos)
6 - Edit Upload Tool (scp)
7 - Edit Port Connection (22)
8 - Exit
* Choose an option:
````
### Generate certificate (on remote machine):
* To generate certificate for connect to remote machine, run the following command:
```shell
$ ks-upa -p
````
* Copy the file [user]-[hostname].pem to your machine.
### Show version:
* You can check the version with the command:
```shell
$ ks-upa -v
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

112
doc/ks-upf.md Normal file
View File

@ -0,0 +1,112 @@
ks-upf - Upload common file(s) to server with scp or rsync.
===========================================================
### Syntax:
```shell
$ ks-upf -i - Start upload
$ ks-upf -g - Create configuration
$ ks-upf -r - Remove configuration
$ ks-upf -c - Show configuration
$ ks-upf -e - Edit configuration
$ ks-upf -p - Generate certificate
$ ks-upf -v - Show version
$ ks-upf -h - Show help
```
### Initialize common file(s) upload:
* For initialize file(s) upload only run the following command:
```shell
$ ks-upf -i
````
* The first time you run the command, you will be asked for the necessary connection information:
```shell
* Enter the server user: anonymous
* Enter the server password (type 'pem' for use pem certificate): *******
* Enter the server URL (or IP): mypersonaldomain.es
* Enter the path on the server: /home/anonymous
* Enter the local path to scan: /home/local/videos
* Setting 'scp' as the default tool
* Setting port 22 as the default port
````
* Once the connection data has been entered, the local directory will be scanned to detect file(s) and upload them to the server directory.
### Remove configuration:
* If you want to clear the connection settings, you just need to run the following command:
```shell
$ ks-upf -r
````
### Show configuration:
* You can check the configuration with the following command:
```shell
$ ks-upf -c
````
* When consulting the configuration, we will see something like this:
```shell
* Server User: anonymous
* Server Password/PEM: *******
* URL (or IP) Server: mypersonaldomain.es
* Destination Path (Server): /home/anonymous
* Scan Path (Local): /home/local/videos
* Upload Tool: scp
* Port Connection: 22
````
### Edit configuration:
* To edit any section of the configuration, the following command would be executed:
```shell
$ ks-upf -e
````
* After its execution, we will see a menu like the following one to be able to edit the desired section:
```shell
1 - Edit User (anonymous)
2 - Edit Password/PEM (*******)
3 - Edit Server (mypersonaldomain.es)
4 - Edit Dest. Path (/home/anonymous)
5 - Edit Local Path (/home/local/videos)
6 - Edit Upload Tool (scp)
7 - Edit Port Connection (22)
8 - Exit
* Choose an option:
````
### Generate certificate (on remote machine):
* To generate certificate for connect to remote machine, run the following command:
```shell
$ ks-upf -p
````
* Copy the file [user]-[hostname].pem to your machine.
### Show version:
* You can check the version with the command:
```shell
$ ks-upf -v
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

112
doc/ks-upr.md Normal file
View File

@ -0,0 +1,112 @@
ks-upr - Upload recursively file(s) to server with scp or rsync.
================================================================
### Syntax:
```shell
$ ks-upr -i - Start upload
$ ks-upr -g - Create configuration
$ ks-upr -r - Remove configuration
$ ks-upr -c - Show configuration
$ ks-upr -e - Edit configuration
$ ks-upr -p - Generate certificate
$ ks-upr -v - Show version
$ ks-upr -h - Show help
```
### Initialize common file(s) upload:
* For initialize recursively upload only run the following command:
```shell
$ ks-upr -i
````
* The first time you run the command, you will be asked for the necessary connection information:
```shell
* Enter the server user: anonymous
* Enter the server password (type 'pem' for use pem certificate): *******
* Enter the server URL (or IP): mypersonaldomain.es
* Enter the path on the server: /home/anonymous
* Enter the local path to scan: /home/local/videos
* Setting 'scp' as the default tool
* Setting port 22 as the default port
````
* Once the connection data has been entered, the local directory will be scanned to upload recursively them to the server directory.
### Remove configuration:
* If you want to clear the connection settings, you just need to run the following command:
```shell
$ ks-upr -r
````
### Show configuration:
* You can check the configuration with the following command:
```shell
$ ks-upr -c
````
* When consulting the configuration, we will see something like this:
```shell
* Server User: anonymous
* Server Password/PEM: *******
* URL (or IP) Server: mypersonaldomain.es
* Destination Path (Server): /home/anonymous
* Scan Path (Local): /home/local/videos
* Upload Tool: scp
* Port Connection: 22
````
### Edit configuration:
* To edit any section of the configuration, the following command would be executed:
```shell
$ ks-upr -e
````
* After its execution, we will see a menu like the following one to be able to edit the desired section:
```shell
1 - Edit User (anonymous)
2 - Edit Password/PEM (*******)
3 - Edit Server (mypersonaldomain.es)
4 - Edit Dest. Path (/home/anonymous)
5 - Edit Local Path (/home/local/videos)
6 - Edit Upload Tool (scp)
7 - Edit Port Connection (22))
8 - Exit
* Choose an option:
````
### Generate certificate (on remote machine):
* To generate certificate for connect to remote machine, run the following command:
```shell
$ ks-upr -p
````
* Copy the file [user]-[hostname].pem to your machine.
### Show version:
* You can check the version with the command:
```shell
$ ks-upr -v
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

112
doc/ks-upv.md Normal file
View File

@ -0,0 +1,112 @@
ks-upv - Upload videos file(s) to server with scp or rsync.
===========================================================
### Syntax:
```shell
$ ks-upv -i - Start upload
$ ks-upv -g - Create configuration
$ ks-upv -r - Remove configuration
$ ks-upv -c - Show configuration
$ ks-upv -e - Edit configuration
$ ks-upv -p - Generate certificate
$ ks-upv -v - Show version
$ ks-upv -h - Show help
```
### Initialize video file(s) upload:
* For initialize video file(s) upload only run the following command:
```shell
$ ks-upv -i
````
* The first time you run the command, you will be asked for the necessary connection information:
```shell
* Enter the server user: anonymous
* Enter the server password (type 'pem' for use pem certificate): *******
* Enter the server URL (or IP): mypersonaldomain.es
* Enter the path on the server: /home/anonymous
* Enter the local path to scan: /home/local/videos
* Setting 'scp' as the default tool
* Setting port 22 as the default port
````
* Once the connection data has been entered, the local directory will be scanned to detect the videos and upload them to the server directory.
### Remove configuration:
* If you want to clear the connection settings, you just need to run the following command:
```shell
$ ks-upv -r
````
### Show configuration:
* You can check the configuration with the following command:
```shell
$ ks-upv -c
````
* When consulting the configuration, we will see something like this:
```shell
* Server User: anonymous
* Server Password/PEM: *******
* URL (or IP) Server: mypersonaldomain.es
* Destination Path (Server): /home/anonymous
* Scan Path (Local): /home/local/videos
* Upload Tool: scp
* Port Connection: 22
````
### Edit configuration:
* To edit any section of the configuration, the following command would be executed:
```shell
$ ks-upv -e
````
* After its execution, we will see a menu like the following one to be able to edit the desired section:
```shell
1 - Edit User (anonymous)
2 - Edit Password/PEM (*******)
3 - Edit Server (mypersonaldomain.es)
4 - Edit Dest. Path (/home/anonymous)
5 - Edit Local Path (/home/local/videos)
6 - Edit Upload Tool (scp)
7 - Edit Port Connection (22)
8 - Exit
* Choose an option:
````
### Generate certificate (on remote machine):
* To generate certificate for connect to remote machine, run the following command:
```shell
$ ks-upv -p
````
* Copy the file [user]-[hostname].pem to your machine.
### Show version:
* You can check the version with the command:
```shell
$ ks-upv -v
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

47
doc/ks-vob-wrapper.md Normal file
View File

@ -0,0 +1,47 @@
ks-vob-wrapper - Wrapper for ks-vob to create graphical interfaces.
===================================================================
### TRACKS/CONFIG DETECT:
```shell
$ ks-vob-wrapper --show-info <video_file>
$ ks-vob-wrapper --show-video-default <video_file>
$ ks-vob-wrapper --show-audio-default <video_file>
$ ks-vob-wrapper --show-resolution-default
```
### CONVERT:
```shell
$ ks-vob-wrapper --conv </path/video_file> </path/output_prefix> <video-track> <audio-track> <resolution> [patch]
```
### CONVERT WITH DEFAULT DETECTION (NOT RECOMMENDED):
```shell
$ ks-vob-wrapper --conv </path/video_file> </path/output_prefix>
```
### CONVERT WITH DEFAULT DETECTION (NOT RECOMMENDED):
```shell
$ ks-vob-wrapper --conv </path/video_file> </path/output_prefix>
$ ks-vob-wrapper --conv-with-sub </path/video_file> </path/output_prefix>
```
### EXAMPLES:
```shell
$ ks-vob-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 720x480
$ ks-vob-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 720x576 patch
```
### Notes:
* The option `patch` apply the `-max_muxing_queue_size 9999` patch to ffmpeg.
* If you specify a path or file with spaces, you must use quotes.
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

75
doc/ks-vob.md Normal file
View File

@ -0,0 +1,75 @@
ks-vob - Convert video file to VOB (DVD splitet) format.
========================================================
### Syntax:
```shell
$ ks-vob </absolute/path/video.mkv> </path/prefix_name>
```
### Default configuration:
* The script `ks-vob` use by default the following configuration:
```shell
- Resolution: 720x480
- Video codec: mpeg2video
- Bitrate video: 3500k
- Audio codec: libtwolame (stereo)
- Bitrate audio: 192k
- Default Audio: spa
- Split: 30 minutes
- Container: vob
````
* If you want to change the settings, you need to edit the `ks-vob` file and change the following variables:
```shell
# Basic parameters
rel_size="720x480"
vcodec="mpeg2video"
b_vcodec="3500k"
acodec="libtwolame"
b_acodec="192k"
default_lang_audio="spa"
v_ext="avi"
````
### Example of use:
* An example of use would be the following:
```shell
$ ks-vob /data/movies/Example.mkv /data/converted/Example
````
* Executing the command, the file will be analyzed and a wizard will be shown to select the tracks and choose the settings:
```shell
* Information of Example.mkv:
+ Video Tracks:
Stream #0:0: Video: h264 (High)
+ Audio Tracks:
Stream #0:1(spa): Audio: ac3
Stream #0:2(eng): Audio: ac3
* (Default: 0:0) Type the number of video track:
* (Default: 0:1) Type the number of audio track:
* (Default: 720x480) Type the resolution:
* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): n
* CONFIGURATION THAT WILL BE APPLIED:
+ Source file: Example.mkv
+ Destination: Example/VTS_01_*
+ Parameters: -map 0:0 -map 0:1 -s 720x480 -c:v mpeg2video -b:v 3500k -c:a libtwolame -b:a 192k -ac 2 -clev 3dB -slev -6dB
* (Default: y) Do you want run the conversion? (y/n): n
````
### Back to README.md
* [Go back](https://git.q3aql.dev/q3aql/ks-tools/src/branch/main/README.md)

View File

@ -1,24 +0,0 @@
#!/bin/bash
###############################################################
# ks-tools - Initialize the ks-tools terminal (using xterm) #
# Date: 10-02-2021 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
###############################################################
VERSION="6.6"
M_DATE="100221"
# Variables
name_terminal="ks-tools v${VERSION} (${M_DATE})"
term="xterm"
font="Monospace"
size_font="11"
color_b="black"
color_f="white"
rcfile="/usr/share/ks-tools/ks-tools-rc"
command="bash --rcfile ${rcfile}"
# Command to run
${term} -T "${name_terminal}" -fa ${font} -fs ${size_font} -bg ${color_b} \
-fg ${color_f} -e ${command}

View File

@ -1,132 +0,0 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]ks-tools\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}ks-tools:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]ks-tools: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
#alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
echo ""
echo " #################################"
echo " # ks-tools 6.6 (for Unix/Linux) #"
echo " #################################"
echo ""
echo " * Available commands:"
echo ""
echo " - ks-upv - ks-vob"
echo " - ks-upa - ks-oga"
echo " - ks-upf - ks-oga-album"
echo " - ks-upr - ks-mp4-wrapper"
echo " - ks-mp4 - ks-avi-wrapper"
echo " - ks-mp4k - ks-vob-wrapper"
echo " - ks-mp4s - ks-mp4k-wrapper"
echo " - ks-mix - ks-mp4s-wrapper"
echo " - ks-avi - ks-mp4s-folder"
echo " - ks-mp3 - ks-mp3-album"
echo ""

View File

@ -1,24 +0,0 @@
#!/bin/bash
###############################################################
# ks-tools - Initialize the ks-tools ZUI (using xterm) #
# Date: 10-02-2021 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
###############################################################
VERSION="6.6 (BETA)"
M_DATE="100221"
# Variables
name_terminal="ks-tools v${VERSION} (${M_DATE})"
term="xterm"
font="Monospace"
size_font="11"
color_b="black"
color_f="white"
rcfile="/usr/share/ks-tools/ks-tools-rc"
command="ks-zui"
# Command to run
${term} -T "${name_terminal}" -fa ${font} -fs ${size_font} -bg ${color_b} \
-fg ${color_f} -e ${command}

View File

@ -1,11 +0,0 @@
[Desktop Entry]
Name=ks-tools (ZUI)
GenericName=ks-tools (ZUI)
X-GNOME-FullName=ks-tools (ZUI)
Comment=Simple zenity user interface for ks-tools
Exec=/usr/share/ks-tools/ks-tools-zui
Icon=/usr/share/ks-tools/ks-tools.svg
Terminal=false
Type=Application
StartupNotify=true
Categories=Network;FileTransfer;Utility;

View File

@ -1,11 +0,0 @@
[Desktop Entry]
Name=ks-tools
GenericName=ks-tools
X-GNOME-FullName=ks-tools
Comment=Upload video/audio/common file(s) & convert videos to MP4/AVI/VOB.
Exec=/usr/share/ks-tools/ks-tools
Icon=/usr/share/ks-tools/ks-tools.svg
Terminal=false
Type=Application
StartupNotify=true
Categories=Network;FileTransfer;Utility;

View File

@ -1,9 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" version="1">
<rect style="opacity:.2" width="56" height="48" x="4" y="9" rx="3" ry="3"/>
<rect style="fill:#5d5544" width="56" height="48" x="4" y="8" rx="3" ry="3"/>
<path style="opacity:.1;fill:#ffffff" d="m7 8c-1.662 0-3 1.338-3 3v1c0-1.662 1.338-3 3-3h50c1.662 0 3 1.338 3 3v-1c0-1.662-1.338-3-3-3h-50z"/>
<path style="opacity:.2" d="m12 15v2h-1c-1.662 0-3 1.338-3 3s1.338 3 3 3h1v2h-3.8164c0.412 1.164 1.508 2 2.8164 2h1v2h2v-2h1c1.662 0 3-1.338 3-3s-1.338-3-3-3h-1v-2h3.8164c-0.412-1.164-1.508-2-2.816-2h-1v-2h-2zm-1 4h1v2h-1c-0.554 0-1-0.446-1-1s0.446-1 1-1zm3 4h1c0.554 0 1 0.446 1 1s-0.4466 1.0257-1 1h-1z"/>
<path style="fill:#ffbe23" d="m12 14v2h-1c-1.662 0-3 1.338-3 3s1.338 3 3 3h1v2h-3.8164c0.412 1.164 1.508 2 2.8164 2h1v2h2v-2h1c1.662 0 3-1.338 3-3s-1.338-3-3-3h-1v-2h3.8164c-0.412-1.164-1.508-2-2.816-2h-1v-2h-2zm-1 4h1v2h-1c-0.554 0-1-0.446-1-1s0.446-1 1-1zm3 4h1c0.554 0 1 0.446 1 1s-0.4466 1.0257-1 1h-1z"/>
<path style="opacity:.2" d="m22 28v1h10v-1z"/>
<rect style="opacity:.5;fill:#ffbe23" width="10" height="14" x="22" y="14"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

548
src/ks-av1 Executable file
View File

@ -0,0 +1,548 @@
#!/bin/bash
##################################################
# ks-av1 (ks-tools) - Convert video to AV1 codec #
# Date: 04-01-2025 #
# Author: q3aql #
# Contact: q3aql@duck.com #
##################################################
VERSION="8.5"
M_DATE="040125"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=$' \t\n'
unset IFS
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] 2> /dev/null ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-av1
# Basic parameters creating config file.
rel_size="1280x534"
vcodec="libsvtav1"
b_vcodec="2000k"
acodec="libvorbis"
b_acodec="160k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="webm"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Setting the correct resolution for the video file
# Sintaxis: set_resolution <resolution> <file>
function set_resolution() {
check_bc_app_directories="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
set_rel="${1}"
input_video_file="${2}"
bc_found="1"
for file in ${check_bc_app_directories} ; do
if [ -f ${file}/bc ] ; then
bc_found=0
fi
done
if [ ${bc_found} -eq 0 ] ; then
file_rel=$(ffmpeg -i "${2}" 2>&1 | grep Stream | grep Video: | grep -Po '\d{3,5}x\d{3,5}' 2> /dev/null | head -1)
if [ -z "${file_rel}" ] ; then
echo ${set_rel}
else
file_rel_width=$(echo ${file_rel} | cut -d "x" -f 1)
file_rel_height=$(echo ${file_rel} | cut -d "x" -f 2)
set_rel_width=$(echo ${set_rel} | cut -d "x" -f 1)
aspect_rel=$(echo ${file_rel_width} / ${file_rel_height} | bc -l)
new_rel_height=$(echo ${set_rel_width} / ${aspect_rel} | bc)
even_number=$(echo ${new_rel_height} % 2 | bc)
if [ ${even_number} -ne 0 ] ; then
new_rel_height=$(expr ${new_rel_height} + 1)
fi
echo ${set_rel_width}x${new_rel_height}
fi
else
echo ${set_rel}
fi
}
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
fi
# Check if ffmpeg is installed
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep sed grep cut head tail tr cat bc"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-av1 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Function to remove extension from file
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Function to show files with spaces.
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp &> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Syntax: ks-av1 </absolute/path/video.mkv> </path/prefix_name>
if [ -z "${1}" ] ; then
echo ""
echo "* ks-av1 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient AV1 codec"
echo ""
echo "+ Config: ${configFile}"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-av1 </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-av1 /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
fi
if [ -f "${1}" ] ; then
echo "detected" > /dev/null
else
echo ""
echo "* ks-av1 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
fi
# Load profile for codecs
profile_codec=" "
selected_codec="${vcodec}"
if [ "${selected_codec}" == "libx264" ] ; then
profile_codec=" -profile:v high "
elif [ "${selected_codec}" == "libx265" ] ; then
profile_codec=" -profile:v main "
elif [ "${selected_codec}" == "libaom-av1" ] ; then
profile_codec=" -profile:v main "
elif [ "${selected_codec}" == "libsvtav1" ] ; then
profile_codec=" -profile:v main "
else
profile_codec=" "
fi
# Conversion parameters
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
f_conversion="-${video_sync} cfr -af aresample=async=1"
# Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")
yuv420p10le=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "yuv420p10le")
hevc_main10=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "Main 10")
hevc_hdr_bt=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "bt2020")
hevc_hdr_smp=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "smpte2084")
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}${hevc_main10}"
hevc_hdr="${hevc_hdr_bt}${hevc_hdr_smp}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
else
if [ -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
# Init conversion file
current_date=$(date +%Y)
if [ -z "${2}" ] ; then
echo ""
echo "* ks-av1 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient AV1 codec"
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-av1 </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-av1 /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
else
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Video Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo "+ Subtitle Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d "," -f 1
echo ""
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
video_default_patch=$(echo ${video_default} | cut -c4)
if [ "${video_default_patch}" == ":" ] ; then
video_default=$(echo ${video_default} | cut -c1-3)
else
video_default="${video_default}"
fi
fi
# Ask for video
echo -n "* (Default: ${video_default}) Type the number of video track: " ; read video_track
if [ -z "${video_track}" ] ; then
video_track="${video_default}"
else
video_track="${video_track}"
fi
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
# Ask for subtitle
echo -n "* (Default: n) Do you want include subtitles? (y/n): " ; read subtitles_y_n
if [ "${subtitles_y_n}" == "y" ] ; then
echo -n "* (Default: ${subtitle_default}) Type the number of subtitle track: " ; read subtitle_track
if [ -z "${subtitle_track}" ] ; then
subtitle_track="${subtitle_default}"
else
subtitle_track="${subtitle_track}"
fi
fi
echo -n "* (Default: ${rel_size}) Type the resolution: " ; read resolution
if [ -z "${resolution}" ] ; then
resolution="${rel_size}"
else
rel_size="${resolution}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
else
if [ -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
fi
echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread
if [ "${patch_thread}" == "y" ] ; then
patch_thread="y"
else
patch_thread="n"
fi
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_file="${current_date}"
else
year_file="${year_file}"
fi
echo -n "* (Default: Unknown) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Unknown"
else
genre_file="${genre_file}"
fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
if [ "${subtitles_y_n}" == "y" ] ; then
echo " # Extract subtitles from file ${1}"
echo " ${p_ffmpeg} \"${1}\" -map ${subtitle_track} \"${2}.srt\""
echo ""
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to AV1 codec"
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
fi
else
echo " # Convert the file '${1}' to AV1 codec"
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to AV1 codec"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to AV1 codec"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${subtitles_y_n}" == "y" ] ; then
${p_ffmpeg} "${1}" -map ${subtitle_track} "${2}.srt"
if [ "${patch_thread}" == "y" ] ; then
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
fi
else
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
fi
fi

548
src/ks-av1s Executable file
View File

@ -0,0 +1,548 @@
#!/bin/bash
############################################################
# ks-av1s (ks-tools) - Convert video to AV1 codec (Series) #
# Date: 04-01-2025 #
# Author: q3aql #
# Contact: q3aql@duck.com #
############################################################
VERSION="8.5"
M_DATE="040125"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=$' \t\n'
unset IFS
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] 2> /dev/null ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-av1s
# Basic parameters
rel_size="720x480"
vcodec="libsvtav1"
b_vcodec="850k"
acodec="libvorbis"
b_acodec="128k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="webm"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Setting the correct resolution for the video file
# Sintaxis: set_resolution <resolution> <file>
function set_resolution() {
check_bc_app_directories="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
set_rel="${1}"
input_video_file="${2}"
bc_found="1"
for file in ${check_bc_app_directories} ; do
if [ -f ${file}/bc ] ; then
bc_found=0
fi
done
if [ ${bc_found} -eq 0 ] ; then
file_rel=$(ffmpeg -i "${2}" 2>&1 | grep Stream | grep Video: | grep -Po '\d{3,5}x\d{3,5}' 2> /dev/null | head -1)
if [ -z "${file_rel}" ] ; then
echo ${set_rel}
else
file_rel_width=$(echo ${file_rel} | cut -d "x" -f 1)
file_rel_height=$(echo ${file_rel} | cut -d "x" -f 2)
set_rel_width=$(echo ${set_rel} | cut -d "x" -f 1)
aspect_rel=$(echo ${file_rel_width} / ${file_rel_height} | bc -l)
new_rel_height=$(echo ${set_rel_width} / ${aspect_rel} | bc)
even_number=$(echo ${new_rel_height} % 2 | bc)
if [ ${even_number} -ne 0 ] ; then
new_rel_height=$(expr ${new_rel_height} + 1)
fi
echo ${set_rel_width}x${new_rel_height}
fi
else
echo ${set_rel}
fi
}
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
fi
# Check if ffmpeg is installed
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep sed grep cut head tail tr cat bc"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-av1s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Function to remove extension from file
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Function to show files with spaces.
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Syntax: ks-av1s </absolute/path/video.mkv> </path/prefix_name>
if [ -z "${1}" ] ; then
echo ""
echo "* ks-av1s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient AV1 codec (Series)"
echo ""
echo "+ Config: ${configFile}"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-av1s </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-av1s /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
fi
if [ -f "${1}" ] ; then
echo "detected" > /dev/null
else
echo ""
echo "* ks-av1s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
fi
# Load profile for codecs
profile_codec=" "
selected_codec="${vcodec}"
if [ "${selected_codec}" == "libx264" ] ; then
profile_codec=" -profile:v high "
elif [ "${selected_codec}" == "libx265" ] ; then
profile_codec=" -profile:v main "
elif [ "${selected_codec}" == "libaom-av1" ] ; then
profile_codec=" -profile:v main "
elif [ "${selected_codec}" == "libsvtav1" ] ; then
profile_codec=" -profile:v main "
else
profile_codec=" "
fi
# Conversion parameters
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
f_conversion="-${video_sync} cfr -af aresample=async=1"
# Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")
yuv420p10le=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "yuv420p10le")
hevc_main10=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "Main 10")
hevc_hdr_bt=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "bt2020")
hevc_hdr_smp=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "smpte2084")
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}${hevc_main10}"
hevc_hdr="${hevc_hdr_bt}${hevc_hdr_smp}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
else
if [ -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
# Init conversion file
current_date=$(date +%Y)
if [ -z "${2}" ] ; then
echo ""
echo "* ks-av1s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient AV1 codec (Series)"
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-av1s </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-av1s /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
else
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Video Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo "+ Subtitle Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d "," -f 1
echo ""
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
video_default_patch=$(echo ${video_default} | cut -c4)
if [ "${video_default_patch}" == ":" ] ; then
video_default=$(echo ${video_default} | cut -c1-3)
else
video_default="${video_default}"
fi
fi
# Ask for video
echo -n "* (Default: ${video_default}) Type the number of video track: " ; read video_track
if [ -z "${video_track}" ] ; then
video_track="${video_default}"
else
video_track="${video_track}"
fi
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
# Ask for subtitle
echo -n "* (Default: n) Do you want include subtitles? (y/n): " ; read subtitles_y_n
if [ "${subtitles_y_n}" == "y" ] ; then
echo -n "* (Default: ${subtitle_default}) Type the number of subtitle track: " ; read subtitle_track
if [ -z "${subtitle_track}" ] ; then
subtitle_track="${subtitle_default}"
else
subtitle_track="${subtitle_track}"
fi
fi
echo -n "* (Default: ${rel_size}) Type the resolution: " ; read resolution
if [ -z "${resolution}" ] ; then
resolution="${rel_size}"
else
rel_size="${resolution}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
else
if [ -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
fi
echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread
if [ "${patch_thread}" == "y" ] ; then
patch_thread="y"
else
patch_thread="n"
fi
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_file="${current_date}"
else
year_file="${year_file}"
fi
echo -n "* (Default: Unknown) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Unknown"
else
genre_file="${genre_file}"
fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
if [ "${subtitles_y_n}" == "y" ] ; then
echo " # Extract subtitles from file ${1}"
echo " ${p_ffmpeg} \"${1}\" -map ${subtitle_track} \"${2}.srt\""
echo ""
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to AV1 codec"
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
fi
else
echo " # Convert the file '${1}' to AV1 codec"
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to AV1 codec"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to AV1 codec"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${subtitles_y_n}" == "y" ] ; then
${p_ffmpeg} "${1}" -map ${subtitle_track} "${2}.srt"
if [ "${patch_thread}" == "y" ] ; then
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
fi
else
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
fi
fi

159
src/ks-av1s-folder Executable file
View File

@ -0,0 +1,159 @@
#!/bin/bash
##################################################################################
# ks-av1s-folder (ks-tools) - Convert videos from folder to AV1 (Codec) (Series) #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@duck.com #
##################################################################################
VERSION="8.5"
M_DATE="021123"
# Variables
tempFile="/tmp/ks-av1s-folder.txt"
tempFileTest="/tmp/ks-av1s-folder-test.txt"
formatFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ts"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check if ffmpeg is installed
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep find grep cut head tail cat"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-av1s-folder (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Show help when folder is empty
if [ -z "${1}" ] ; then
echo ""
echo "* ks-av1s-folder (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert videos from folder to AV1 codec (Series)"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-av1s-folder </path/folder> [subs]"
echo ""
echo " + Examples: "
echo " $ ks-av1s-folder /data/Westworld"
echo " $ ks-av1s-folder /data/Daredevil subs"
echo ""
echo "* Notes:"
echo ""
echo " + The option 'subs' apply detection & rendering the forced subtitles."
echo " + You must not use spaces in folders and video files."
echo ""
exit
fi
# Check if folder exist
if [ -d "${1}" ] ; then
echo null > /dev/null
else
echo ""
echo "* ks-av1s-folder (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The folder '${1}' does not exist!"
echo ""
exit
fi
# Scan videos files format
clear
echo ""
echo "* ks-av1s-folder (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert videos from folder to AV1 codec (Series)"
echo ""
echo -n "* Scanning ${1} "
echo ""
rm -rf ${tempFile} && touch ${tempFile}
for format in ${formatFiles} ; do
find "${1}"/*.${format} &> ${tempFileTest}
if [ $? -ne 0 ] ; then
echo "null" > /dev/null
else
echo "+ Video file(s) in .${format} found!"
cd "${1}" && ls -1 *.${format} &> /tmp/tempFile.txt
cat /tmp/tempFile.txt >> ${tempFile}
rm -rf /tmp/tempFile.txt 2> /dev/null
fail=0
fi
done
# Init the conversion files
num_files=$(cat ${tempFile} | wc -l)
if [ ${num_files} -eq 0 ] ; then
echo ""
echo "+ No video file(s) found in folder '${1}'"
echo ""
exit
else
echo ""
echo "* Files to convert (${1}):"
convert_files=1
if [ "${2}" == "subs" ] ; then
subtitles_enabled=1
subtitles_show="with subtitles"
else
subtitles_enabled=0
subtitles_show="without subtitles"
fi
while [ ${convert_files} -le ${num_files} ] ; do
show_file=$(cat ${tempFile} | head -${convert_files} | tail -1)
echo " + ${show_file} (${subtitles_show})"
convert_files=$(expr ${convert_files} + 1)
done
echo ""
echo "* The output folder will be '${1}/to-av1'"
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
convert_files=1
cd "${1}" && mkdir -p to-av1 && rm -rf to-av1/*
while [ ${convert_files} -le ${num_files} ] ; do
show_file=$(cat ${tempFile} | head -${convert_files} | tail -1)
if [ ${subtitles_enabled} -eq 1 ] ; then
fname=$(echo "${show_file}" | cut -d "." -f 1)
ks-av1s-wrapper --conv-with-sub "${show_file}" "to-av1/${fname}"
else
fname=$(echo "${show_file}" | cut -d "." -f 1)
ks-av1s-wrapper --conv "${show_file}" "to-av1/${fname}"
fi
convert_files=$(expr ${convert_files} + 1)
done
fi
fi

View File

@ -2,42 +2,180 @@
###############################################################
# ks-avi (ks-tools) - Convert video to AVI format #
# Date: 10-02-2021 #
# Date: 04-01-2025 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
###############################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="040125"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=$' \t\n'
unset IFS
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] 2> /dev/null ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-avi
# Basic parameters
rel_size="720x480"
vcodec="libxvid"
b_vcodec="3000k"
# Presets: ultrafast, superfast, veryfast, faster,
# fast, medium (default), slow, slower, veryslow
v_preset="slow"
acodec="libmp3lame"
b_acodec="192k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="avi"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Setting the correct resolution for the video file
# Sintaxis: set_resolution <resolution> <file>
function set_resolution() {
check_bc_app_directories="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
set_rel="${1}"
input_video_file="${2}"
bc_found="1"
for file in ${check_bc_app_directories} ; do
if [ -f ${file}/bc ] ; then
bc_found=0
fi
done
if [ ${bc_found} -eq 0 ] ; then
file_rel=$(ffmpeg -i "${2}" 2>&1 | grep Stream | grep Video: | grep -Po '\d{3,5}x\d{3,5}' 2> /dev/null | head -1)
if [ -z "${file_rel}" ] ; then
echo ${set_rel}
else
file_rel_width=$(echo ${file_rel} | cut -d "x" -f 1)
file_rel_height=$(echo ${file_rel} | cut -d "x" -f 2)
set_rel_width=$(echo ${set_rel} | cut -d "x" -f 1)
aspect_rel=$(echo ${file_rel_width} / ${file_rel_height} | bc -l)
new_rel_height=$(echo ${set_rel_width} / ${aspect_rel} | bc)
even_number=$(echo ${new_rel_height} % 2 | bc)
if [ ${even_number} -ne 0 ] ; then
new_rel_height=$(expr ${new_rel_height} + 1)
fi
echo ${set_rel_width}x${new_rel_height}
fi
else
echo ${set_rel}
fi
}
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
if [ ${error_ffmpeg} -ne 0 ] ; then
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep sed grep cut head tail tr cat bc"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-avi (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ffmpeg' tool is not installed!"
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
@ -57,7 +195,7 @@ function extractFolderOrFile() {
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
@ -81,34 +219,35 @@ function removeExtension() {
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Sintax: ks-avi </absolute/path/video.mkv> </path/prefix_name>
# Syntax: ks-avi </absolute/path/video.mkv> </path/prefix_name>
if [ -z "${1}" ] ; then
echo ""
echo "* ks-avi (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient AVI"
echo ""
echo "+ Config:"
echo "+ Config: ${configFile}"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo "+ Syntax: "
echo ""
echo " $ ks-avi </absolute/path/video.mkv> </path/prefix_name>"
echo ""
@ -130,8 +269,25 @@ fi
# Conversion parameters
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
f_conversion="-vsync 1 -async 1"
p_conversion="-s ${rel_size} -c:v ${vcodec} -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
f_conversion="-${video_sync} cfr -af aresample=async=1"
# Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")
yuv420p10le=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "yuv420p10le")
hevc_main10=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "Main 10")
hevc_hdr_bt=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "bt2020")
hevc_hdr_smp=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "smpte2084")
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}${hevc_main10}"
hevc_hdr="${hevc_hdr_bt}${hevc_hdr_smp}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
if [ -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
# Init conversion file
current_date=$(date +%Y)
@ -146,13 +302,14 @@ if [ -z "${2}" ] ; then
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo "+ Syntax: "
echo ""
echo " $ ks-avi </absolute/path/video.mkv> </path/prefix_name>"
echo ""
@ -267,7 +424,11 @@ else
resolution="${rel_size}"
else
rel_size="${resolution}"
p_conversion="-s ${rel_size} -c:v ${vcodec} -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread
if [ "${patch_thread}" == "y" ] ; then
@ -312,7 +473,6 @@ else
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
@ -323,18 +483,28 @@ else
echo ""
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to AVI"
echo " ${p_ffmpeg} \"${1}\" -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\" -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
fi
else
echo " # Convert the file '${1}' to AVI"
echo " ${p_ffmpeg} \"${1}\" -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\" -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to AVI"
echo " ${p_ffmpeg} \"${1}\" -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to AVI"
echo " ${p_ffmpeg} \"${1}\" -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
# Execute commands for conversion
@ -346,15 +516,23 @@ else
if [ "${subtitles_y_n}" == "y" ] ; then
${p_ffmpeg} "${1}" -map ${subtitle_track} "${2}.srt"
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt" -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
fi
else
${p_ffmpeg} "${1}" -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt" -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
fi

920
src/ks-conf Executable file
View File

@ -0,0 +1,920 @@
#!/bin/bash
#######################################################################
# ks-conf (ks-tools) - Tool for create and modify configuration files #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@duck.com #
#######################################################################
VERSION="8.5"
M_DATE="021123"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check and create configuration file for ks-mp4
function check_create_conf_ks_mp4() {
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4
rel_size="1280x534"
vcodec="libx264"
b_vcodec="2200k"
v_preset="slow"
acodec="aac"
b_acodec="192k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="mp4"
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
}
# Check and create configuration file for ks-mp4s
function check_create_conf_ks_mp4s() {
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4s
rel_size="720x480"
vcodec="libx264"
b_vcodec="950k"
v_preset="slow"
acodec="aac"
b_acodec="128k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="mp4"
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
}
# Check and create configuration file for ks-mp4k
function check_create_conf_ks_mp4k() {
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4k
rel_size="3840x2160"
vcodec="libx264"
b_vcodec="6000k"
v_preset="medium"
acodec="aac"
b_acodec="320k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="mp4"
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
}
# Check and create configuration file for ks-avi
function check_create_conf_ks_avi() {
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-avi
rel_size="720x480"
vcodec="libxvid"
b_vcodec="3000k"
v_preset="slow"
acodec="libmp3lame"
b_acodec="192k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="avi"
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
}
# Check and create configuration file for ks-av1
function check_create_conf_ks_av1() {
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-av1
rel_size="1280x534"
vcodec="libsvtav1"
b_vcodec="2000k"
v_preset="disabled"
acodec="libvorbis"
b_acodec="160k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="webm"
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
}
# Check and create configuration file for ks-av1s
function check_create_conf_ks_av1s() {
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-av1s
rel_size="720x480"
vcodec="libsvtav1"
b_vcodec="850k"
v_preset="disabled"
acodec="libvorbis"
b_acodec="128k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="webm"
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
}
# Check and create configuration file for ks-mp3/ks-mp3-album
function check_create_conf_ks_mp3() {
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp3
acodec="libmp3lame"
b_acodec="128k"
v_ext="mp3"
default_lang_audio="spa"
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
}
# Check and create configuration file for ks-oga/ks-oga-album
function check_create_conf_ks_oga() {
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-oga
acodec="libvorbis"
b_acodec="130k"
v_ext="oga"
default_lang_audio="spa"
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
}
# Function to reset config files
# Sintaxis: remove_video_audio_config <name config file>
remove_video_audio_config() {
name_file=${1}
echo "#!/bin/bash" > ${HOME}/.ks-tools/${name_file}
echo "" >> ${HOME}/.ks-tools/${name_file}
}
# Function to video configuration
# Sintaxis: edit_video_config <name config file>
edit_video_config() {
check_create_conf_ks_mp4
check_create_conf_ks_mp4s
check_create_conf_ks_mp4k
check_create_conf_ks_avi
check_create_conf_ks_av1
check_create_conf_ks_av1s
name_file=${1}
editing=0
while [ ${editing} -eq 0 ] ; do
source ${HOME}/.ks-tools/${name_file}
clear
echo ""
echo "* ks-conf (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Editing ${HOME}/.ks-tools/${name_file}"
echo ""
echo " r - Edit resolution (${rel_size})"
echo " v - Edit video codec (${vcodec})"
echo " b - Edit video bitrate (${b_vcodec})"
echo " p - Edit video preset (${v_preset})"
echo " a - Edit audio codec (${acodec})"
echo " i - Edit audio bitrate (${b_acodec})"
echo " l - Edit preferred language (${default_lang_audio})"
echo " s - Edit preferred subtitles (${default_lang_subt})"
echo ""
echo " c - Reset configuration file"
echo " q - Exit to main menu"
echo ""
echo -n "* Choose an option (r/v/b/p/a/i/l/s/c/q): " ; read option
if [ "${option}" == "r" ] ; then
# Set resolution
echo ""
echo "* Recommended: 720x480 / 1280x534 / 1280x720 / 1920x1080 / 3840x2160"
echo ""
echo -n "* [Current: ${rel_size}] Type the resolution: " ; read resolution
if [ -z ${resolution} ] ; then
echo > /dev/null
else
remove_video_audio_config ${name_file}
echo "rel_size=${resolution}" >> ${HOME}/.ks-tools/${name_file}
echo "vcodec=${vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_vcodec=${b_vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "v_preset=${v_preset}" >> ${HOME}/.ks-tools/${name_file}
echo "acodec=${acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_acodec=${b_acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_audio=${default_lang_audio}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_subt=${default_lang_subt}" >> ${HOME}/.ks-tools/${name_file}
echo "v_ext=${v_ext}" >> ${HOME}/.ks-tools/${name_file}
source ${HOME}/.ks-tools/${name_file}
fi
elif [ "${option}" == "v" ] ; then
# Set video codec
if [ "$v_ext" == "mp4" ] ; then
echo ""
echo "* Recommended: mpeg4 / libxvid / libx264 / libx265 / libaom-av1"
fi
if [ "$v_ext" == "avi" ] ; then
echo ""
echo "* Recommended: mpeg4 / libxvid"
fi
if [ "$v_ext" == "webm" ] ; then
echo ""
echo "* Recommended: libvpx-vp9 / libsvtav1 / libaom-av1"
fi
if [ "$v_ext" == "mkv" ] ; then
echo ""
echo "* Recommended: libx264 / libx265 / libsvtav1 / libaom-av1"
fi
echo ""
echo -n "* [Current: ${vcodec}] Type the video codec: " ; read videocodec
if [ -z ${videocodec} ] ; then
echo > /dev/null
else
remove_video_audio_config ${name_file}
echo "rel_size=${rel_size}" >> ${HOME}/.ks-tools/${name_file}
echo "vcodec=${videocodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_vcodec=${b_vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "v_preset=${v_preset}" >> ${HOME}/.ks-tools/${name_file}
echo "acodec=${acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_acodec=${b_acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_audio=${default_lang_audio}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_subt=${default_lang_subt}" >> ${HOME}/.ks-tools/${name_file}
echo "v_ext=${v_ext}" >> ${HOME}/.ks-tools/${name_file}
source ${HOME}/.ks-tools/${name_file}
fi
elif [ "${option}" == "b" ] ; then
# Set bitrate for video
echo ""
echo "* Recommended: 850k / 950k / 2000k / 2200k / 3000k / 6000k / 10000k"
echo ""
echo -n "* [Current: ${b_vcodec}] Type bitrate for video: " ; read videobitrate
if [ -z ${videobitrate} ] ; then
echo > /dev/null
else
remove_video_audio_config ${name_file}
echo "rel_size=${rel_size}" >> ${HOME}/.ks-tools/${name_file}
echo "vcodec=${vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_vcodec=${videobitrate}" >> ${HOME}/.ks-tools/${name_file}
echo "v_preset=${v_preset}" >> ${HOME}/.ks-tools/${name_file}
echo "acodec=${acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_acodec=${b_acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_audio=${default_lang_audio}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_subt=${default_lang_subt}" >> ${HOME}/.ks-tools/${name_file}
echo "v_ext=${v_ext}" >> ${HOME}/.ks-tools/${name_file}
source ${HOME}/.ks-tools/${name_file}
fi
elif [ "${option}" == "p" ] ; then
# Set video preset
echo ""
echo "* Presets: ultrafast / superfast / veryfast / faster / fast"
echo " medium / slow / slower / veryslow"
echo ""
echo -n "* [Current: ${v_preset}] Type the preset: " ; read videopreset
if [ -z ${videopreset} ] ; then
echo > /dev/null
else
remove_video_audio_config ${name_file}
echo "rel_size=${rel_size}" >> ${HOME}/.ks-tools/${name_file}
echo "vcodec=${vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_vcodec=${b_vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "v_preset=${videopreset}" >> ${HOME}/.ks-tools/${name_file}
echo "acodec=${acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_acodec=${b_acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_audio=${default_lang_audio}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_subt=${default_lang_subt}" >> ${HOME}/.ks-tools/${name_file}
echo "v_ext=${v_ext}" >> ${HOME}/.ks-tools/${name_file}
source ${HOME}/.ks-tools/${name_file}
fi
elif [ "${option}" == "a" ] ; then
# Set audio codec
if [ "$v_ext" == "mp4" ] ; then
echo ""
echo "* Recommended: aac / libmp3lame / ac3 / libopus / mp2"
fi
if [ "$v_ext" == "avi" ] ; then
echo ""
echo "* Recommended: ac3 / libmp3lame / mp2"
fi
if [ "$v_ext" == "webm" ] ; then
echo ""
echo "* Recommended: libvorbis / libopus"
fi
if [ "$v_ext" == "mkv" ] ; then
echo ""
echo "* Recommended: aac / libvorbis / libopus / ac3 / libmp3lame"
fi
echo ""
echo -n "* [Current: ${acodec}] Type the audio codec: " ; read audiocodec
if [ -z ${audiocodec} ] ; then
echo > /dev/null
else
remove_video_audio_config ${name_file}
echo "rel_size=${rel_size}" >> ${HOME}/.ks-tools/${name_file}
echo "vcodec=${vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_vcodec=${b_vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "v_preset=${v_preset}" >> ${HOME}/.ks-tools/${name_file}
echo "acodec=${audiocodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_acodec=${b_acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_audio=${default_lang_audio}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_subt=${default_lang_subt}" >> ${HOME}/.ks-tools/${name_file}
echo "v_ext=${v_ext}" >> ${HOME}/.ks-tools/${name_file}
source ${HOME}/.ks-tools/${name_file}
fi
elif [ "${option}" == "i" ] ; then
# Set bitrate for audio
echo ""
echo "* Recommended: 92k / 128k / 160k / 192k / 256k / 320k / 640k"
echo ""
echo -n "* [Current: ${b_acodec}] Type bitrate for audio: " ; read audiobitrate
if [ -z ${audiobitrate} ] ; then
echo > /dev/null
else
remove_video_audio_config ${name_file}
echo "rel_size=${rel_size}" >> ${HOME}/.ks-tools/${name_file}
echo "vcodec=${vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_vcodec=${b_vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "v_preset=${v_preset}" >> ${HOME}/.ks-tools/${name_file}
echo "acodec=${acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_acodec=${audiobitrate}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_audio=${default_lang_audio}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_subt=${default_lang_subt}" >> ${HOME}/.ks-tools/${name_file}
echo "v_ext=${v_ext}" >> ${HOME}/.ks-tools/${name_file}
source ${HOME}/.ks-tools/${name_file}
fi
elif [ "${option}" == "l" ] ; then
# Set default audio language
echo ""
echo "* Examples: "
echo " English --> eng"
echo " Spanish --> spa"
echo " Italian --> ita"
echo " French --> fra"
echo ""
echo "* Complete 639-2 codes: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes"
echo ""
echo -n "* [Current: ${default_lang_audio}] Type the preferred audio language: " ; read audiolanguage
if [ -z ${audiolanguage} ] ; then
echo > /dev/null
else
remove_video_audio_config ${name_file}
echo "rel_size=${rel_size}" >> ${HOME}/.ks-tools/${name_file}
echo "vcodec=${vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_vcodec=${b_vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "v_preset=${v_preset}" >> ${HOME}/.ks-tools/${name_file}
echo "acodec=${acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_acodec=${b_acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_audio=${audiolanguage}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_subt=${default_lang_subt}" >> ${HOME}/.ks-tools/${name_file}
echo "v_ext=${v_ext}" >> ${HOME}/.ks-tools/${name_file}
source ${HOME}/.ks-tools/${name_file}
fi
elif [ "${option}" == "s" ] ; then
# Set default audio language
echo ""
echo "* Examples: "
echo " English --> eng"
echo " Spanish --> spa"
echo " Italian --> ita"
echo " French --> fra"
echo ""
echo "* Complete 639-2 codes: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes"
echo ""
echo -n "* [Current: ${default_lang_subt}] Type the preferred subtitles language: " ; read subtitlelanguage
if [ -z ${subtitlelanguage} ] ; then
echo > /dev/null
else
remove_video_audio_config ${name_file}
echo "rel_size=${rel_size}" >> ${HOME}/.ks-tools/${name_file}
echo "vcodec=${vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_vcodec=${b_vcodec}" >> ${HOME}/.ks-tools/${name_file}
echo "v_preset=${v_preset}" >> ${HOME}/.ks-tools/${name_file}
echo "acodec=${acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_acodec=${b_acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_audio=${default_lang_audio}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_subt=${subtitlelanguage}" >> ${HOME}/.ks-tools/${name_file}
echo "v_ext=${v_ext}" >> ${HOME}/.ks-tools/${name_file}
source ${HOME}/.ks-tools/${name_file}
fi
elif [ "${option}" == "c" ] ; then
rm -rf ${HOME}/.ks-tools/${name_file}
check_create_conf_ks_mp4
check_create_conf_ks_mp4s
check_create_conf_ks_mp4k
check_create_conf_ks_avi
check_create_conf_ks_av1
check_create_conf_ks_av1s
elif [ "${option}" == "q" ] ; then
editing=1
else
echo ""
echo "+ Invalid option"
echo -n "* Press ENTER to return menu " ; read return
fi
done
}
# Function to audio configuration
# Sintaxis: edit_audio_config <name config file>
edit_audio_config() {
check_create_conf_ks_mp3
check_create_conf_ks_oga
name_file=${1}
editing=0
while [ ${editing} -eq 0 ] ; do
source ${HOME}/.ks-tools/${name_file}
clear
echo ""
echo "* ks-conf (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Editing ${HOME}/.ks-tools/${name_file}"
echo ""
echo " a - Edit audio bitrate (${b_acodec})"
echo " l - Edit preferred language (${default_lang_audio})"
echo ""
echo " c - Reset configuration file"
echo " q - Exit to main menu"
echo ""
echo -n "* Choose an option (a/l/c/q): " ; read option
if [ "${option}" == "a" ] ; then
# Set bitrate for audio
if [ "$v_ext" == "mp3" ] ; then
echo ""
echo "* Recommended: 92k / 128k / 192k / 256k / 320k / 640k"
fi
if [ "$v_ext" == "oga" ] ; then
echo ""
echo "* Recommended: 96k / 112k / 130k / 160k / 224k / 256k / 320k"
fi
echo ""
echo -n "* [Current: ${b_acodec}] Type bitrate for audio: " ; read audiobitrate
if [ -z ${audiobitrate} ] ; then
echo > /dev/null
else
remove_video_audio_config ${name_file}
echo "acodec=${acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_acodec=${audiobitrate}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_audio=${default_lang_audio}" >> ${HOME}/.ks-tools/${name_file}
echo "v_ext=${v_ext}" >> ${HOME}/.ks-tools/${name_file}
source ${HOME}/.ks-tools/${name_file}
fi
elif [ "${option}" == "l" ] ; then
# Set default audio language
echo ""
echo "* Examples: "
echo " English --> eng"
echo " Spanish --> spa"
echo " Italian --> ita"
echo " French --> fra"
echo ""
echo "* Complete 639-2 codes: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes"
echo ""
echo -n "* [Current: ${default_lang_audio}] Type the preferred audio language: " ; read audiolanguage
if [ -z ${audiolanguage} ] ; then
echo > /dev/null
else
remove_video_audio_config ${name_file}
echo "acodec=${acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "b_acodec=${b_acodec}" >> ${HOME}/.ks-tools/${name_file}
echo "default_lang_audio=${audiolanguage}" >> ${HOME}/.ks-tools/${name_file}
echo "v_ext=${v_ext}" >> ${HOME}/.ks-tools/${name_file}
source ${HOME}/.ks-tools/${name_file}
fi
elif [ "${option}" == "c" ] ; then
rm -rf ${HOME}/.ks-tools/${name_file}
check_create_conf_ks_mp3
check_create_conf_ks_oga
elif [ "${option}" == "q" ] ; then
editing=1
else
echo ""
echo "+ Invalid option"
echo -n "* Press ENTER to return menu " ; read return
fi
done
}
# Run all functions for check configuration files
check_create_conf_ks_mp4
check_create_conf_ks_mp4s
check_create_conf_ks_mp4k
check_create_conf_ks_avi
check_create_conf_ks_av1
check_create_conf_ks_av1s
check_create_conf_ks_mp3
check_create_conf_ks_oga
# Load all configurations and show main menu
show_menu=0
while [ ${show_menu} -eq 0 ] ; do
clear
echo ""
echo "* ks-conf (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Tool for create and modify all configuration files"
echo ""
source ${HOME}/.ks-tools/ks-mp4
echo " m - Edit ks-mp4 config (${rel_size}/${vcodec}/${b_vcodec}/${acodec}/${b_acodec}/${default_lang_audio})"
source ${HOME}/.ks-tools/ks-mp4k
echo " k - Edit ks-mp4k config (${rel_size}/${vcodec}/${b_vcodec}/${acodec}/${b_acodec}/${default_lang_audio})"
source ${HOME}/.ks-tools/ks-mp4s
echo " s - Edit ks-mp4s config (${rel_size}/${vcodec}/${b_vcodec}/${acodec}/${b_acodec}/${default_lang_audio})"
source ${HOME}/.ks-tools/ks-avi
echo " a - Edit ks-avi config (${rel_size}/${vcodec}/${b_vcodec}/${acodec}/${b_acodec}/${default_lang_audio})"
source ${HOME}/.ks-tools/ks-av1
echo " v - Edit ks-av1 config (${rel_size}/${vcodec}/${b_vcodec}/${acodec}/${b_acodec}/${default_lang_audio})"
source ${HOME}/.ks-tools/ks-av1s
echo " c - Edit ks-av1s config (${rel_size}/${vcodec}/${b_vcodec}/${acodec}/${b_acodec}/${default_lang_audio})"
echo ""
source ${HOME}/.ks-tools/ks-mp3
echo " p - Edit ks-mp3/ks-mp3-album config (${acodec}/${b_acodec}/${default_lang_audio})"
source ${HOME}/.ks-tools/ks-oga
echo " o - Edit ks-oga/ks-oga-album config (${acodec}/${b_acodec}/${default_lang_audio})"
echo ""
user_config=$(cat ${HOME}/.ks-tools/ks-upload-user 2> /dev/null)
server_config=$(cat ${HOME}/.ks-tools/ks-upload-server 2> /dev/null)
tool_config=$(cat ${HOME}/.ks-tools/ks-upload-tool 2> /dev/null)
echo " u - Edit ks-upv/ks-upa/ks-upf/ks-upr config (${user_config}/${server_config}/${tool_config})"
echo ""
echo " q - Exit"
echo ""
echo -n "* Choose an option (m/k/s/a/p/o/u/q): " ; read option
if [ "${option}" == "m" ] ; then
edit_video_config ks-mp4
elif [ "${option}" == "k" ] ; then
edit_video_config ks-mp4k
elif [ "${option}" == "s" ] ; then
edit_video_config ks-mp4s
elif [ "${option}" == "a" ] ; then
edit_video_config ks-avi
elif [ "${option}" == "v" ] ; then
edit_video_config ks-av1
elif [ "${option}" == "c" ] ; then
edit_video_config ks-av1s
elif [ "${option}" == "p" ] ; then
edit_audio_config ks-mp3
elif [ "${option}" == "o" ] ; then
edit_audio_config ks-oga
elif [ "${option}" == "u" ] ; then
ks-upv -e
elif [ "${option}" == "q" ] ; then
show_menu=1
exit
else
echo ""
echo "+ Invalid option"
echo -n "* Press ENTER to return menu " ; read return
fi
done

583
src/ks-crop Executable file
View File

@ -0,0 +1,583 @@
#!/bin/bash
###############################################################
# ks-crop (ks-tools) - Crop or change aspect ratio of a video #
# Date: 04-01-2025 #
# Author: q3aql #
# Contact: q3aql@duck.com #
###############################################################
VERSION="8.5"
M_DATE="040125"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=$' \t\n'
unset IFS
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] 2> /dev/null ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
# Resolution and parameters
to4_3="1920x1440"
to16_9="1920x1080"
to5_4="1920x1540"
toImax="1920x1346"
v_preset="medium"
vcodec="libx264"
b_vcodec="5000k"
acodec="copy"
v_ext="mkv"
default_lang_audio="spa"
# Empty variables
resolution=null
modeCrop=null
inputFile="${2}"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check if ffmpeg is installed
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep sed grep cut head tail tr cat"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-crop (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Function to remove extension from file
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Function to show files with spaces.
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Function to show menu again when syntax is wrong
function show_menu() {
echo ""
echo "* ks-crop (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Crop or change aspect ratio of a video"
echo ""
echo "+ Config:"
echo ""
echo " - Resolutions: "
echo " + ${to4_3} (4:3)"
echo " + ${to16_9} (16:9)"
echo " + ${to5_4} (5:4)"
echo " + ${toImax} (IMAX)"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-crop -16:9-crop <video-file> --> Crop from 4:3/IMAX to 16:9 (1.77:1)"
echo " $ ks-crop -4:3-crop <video-file> --> Crop from 16:9 to 4:3 (1.33:1)"
echo " $ ks-crop -5:4-crop <video-file> --> Crop from 16:9 to 5:4 (1.25:1)"
echo " $ ks-crop -imax-crop <video-file> --> Crop from 16:9 to IMAX (1.43:1)"
echo ""
echo " $ ks-crop -16:9-aspect <video-file> --> Change aspect to 16:9 (stretched)"
echo " $ ks-crop -4:3-aspect <video-file> --> Change aspect to 4:3 (stretched)"
echo " $ ks-crop -5:4-aspect <video-file> --> Change aspect to 5:4 (stretched)"
echo ""
echo " + Examples: "
echo " ks-crop -16:9-crop /data/movies/Example.mkv"
echo " ks-crop -4:3-aspect /data/movies/Video.avi"
echo ""
exit
}
# Function to show error reading file
# Syntax: errorReadingFile <file>
function errorReadingFile() {
echo ""
echo "* ks-crop (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
}
# Conversion parameters
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
# f_conversion="-vsync 1 -async 1" # Deprecated method
f_conversion="-${video_sync} cfr"
#f_conversion_crop="-${video_sync} cfr -async 1"
f_conversion_crop="-${video_sync} cfr"
# Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")
yuv420p10le=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "yuv420p10le")
hevc_main10=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "Main 10")
hevc_profile_10bit="${yuv420p10le}${hevc_main10}"
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}"
else
if [ -z "${hevc_profile_10bit}" ] ; then
p_conversion="-c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}"
else
#p_conversion="-c:v ${vcodec} -x264opts colorprim=bt2020:colormatrix=bt2020nc:transfer=smpte2084:chromaloc=2 -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}"
p_conversion="-c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}"
fi
fi
# Show menu with bad syntax
if [ "${1}" == "-16:9-crop" ] ; then
echo > /dev/null
elif [ "${1}" == "-4:3-crop" ] ; then
echo > /dev/null
elif [ "${1}" == "-5:4-crop" ] ; then
echo > /dev/null
elif [ "${1}" == "-imax-crop" ] ; then
echo > /dev/null
elif [ "${1}" == "-16:9-aspect" ] ; then
echo > /dev/null
elif [ "${1}" == "-4:3-aspect" ] ; then
echo > /dev/null
elif [ "${1}" == "-5:4-aspect" ] ; then
echo > /dev/null
else
show_menu
fi
if [ -f "${2}" ] ; then
echo "detected" > /dev/null
else
errorReadingFile "${2}"
fi
# Detect resolution of video file
detect_2=$(ffmpeg -i ${2} 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 2 | cut -d "[" -f 1 | tr -s " " | grep x)
detect_3=$(ffmpeg -i ${2} 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 3 | cut -d "[" -f 1 | tr -s " " | grep x)
detect_4=$(ffmpeg -i ${2} 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 4 | cut -d "[" -f 1 | tr -s " " | grep x)
detect_5=$(ffmpeg -i ${2} 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 5 | cut -d "[" -f 1 | tr -s " " | grep x)
resolution_detected="${detect_2}${detect_3}${detect_4}${detect_5}"
resolution_height=$(echo ${resolution_detected} | cut -d "x" -f 2)
# Set size crop to 16:9 (ih)
calculate_crop=$(expr ${resolution_height} / 4 2> /tmp/ks-tools.error)
# Check if number is correct
expr ${calculate_crop} + 1 &> /tmp/ks-tools.error
ih_error="$?"
if [ ${ih_error} -eq 0 ] ; then
ih_size="${calculate_crop}"
else
ih_size="0"
fi
# Function to crop videos
function crop_video() {
echo ""
echo "* Information of ${inputFile}:"
echo ""
echo "+ Video Tracks:"
${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
# Check de video track by default
video_default=$(${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
video_default_patch=$(echo ${video_default} | cut -c4)
if [ "${video_default_patch}" == ":" ] ; then
video_default=$(echo ${video_default} | cut -c1-3)
else
video_default="${video_default}"
fi
fi
# Ask for video
echo -n "* (Default: ${video_default}) Type the number of video track: " ; read video_track
if [ -z "${video_track}" ] ; then
video_track="${video_default}"
else
video_track="${video_track}"
fi
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Ask for bitrate video
bitrate_default="${b_vcodec}"
echo -n "* (Default: ${b_vcodec}) Type the bitrate (${vcodec}): " ; read bitrate_video
if [ -z "${bitrate_video}" ] ; then
b_vcodec="${bitrate_default}"
else
b_vcodec="${bitrate_video}"
fi
# Reload p_conversion variable
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}"
else
if [ -z "${hevc_profile_10bit}" ] ; then
p_conversion="-c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}"
else
#p_conversion="-c:v ${vcodec} -x264opts colorprim=bt2020:colormatrix=bt2020nc:transfer=smpte2084:chromaloc=2 -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}"
p_conversion="-c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}"
fi
fi
# Ask for patched
echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread
if [ "${patch_thread}" == "y" ] ; then
patch_thread="y"
else
patch_thread="n"
fi
# Check diferent modes
if [ "${modeCrop}" == "16:9-crop" ] ; then
inputFileOut=$(removeExtension ${inputFile})
# Show commands for conversion
echo ""
echo "* COMMAND THAT WILL BE EXECUTED:"
echo ""
inputFileSave="${inputFile}"
ih_sizeSave="${ih_size}"
if [ ${ih_size} -eq 0 ] ; then
if [ "${patch_thread}" == "y" ] ; then
echo " # Error detecting file resolution. The generic solution is applied (slower)"
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-resize.${v_ext}\""
echo ""
inputFile="${inputFileOut}-resize.${v_ext}"
ih_size="360"
else
echo " # Error detecting file resolution. The generic solution is applied (slower)"
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} \"${inputFileOut}-resize.${v_ext}\""
echo ""
inputFile="${inputFileOut}-resize.${v_ext}"
ih_size="360"
fi
else
echo " # File detected with resolution" ${resolution_detected} "(ih ${ih_size})"
fi
echo " # Crop '${inputFile}' from 4:3/IMAX to 16:9 (1.77:1)"
if [ "${patch_thread}" == "y" ] ; then
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v \"crop=iw:ih-${ih_size}\" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
else
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v \"crop=iw:ih-${ih_size}\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\""
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
inputFile="${inputFileSave}"
ih_size="${ih_sizeSave}"
inputFileOut=$(removeExtension ${inputFile})
if [ ${ih_size} -eq 0 ] ; then
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} ${p_ffmpeg_patched} "${inputFileOut}-resize.${v_ext}"
inputFile="${inputFileOut}-resize.${v_ext}"
ih_size="360"
else
${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} "${inputFileOut}-resize.${v_ext}"
inputFile="${inputFileOut}-resize.${v_ext}"
ih_size="360"
fi
fi
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${inputFile}" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v "crop=iw:ih-${ih_size}" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} "${inputFileOut}-crop.${v_ext}"
else
${p_ffmpeg} "${inputFile}" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v "crop=iw:ih-${ih_size}" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}"
fi
fi
elif [ "${modeCrop}" == "4:3-crop" ] ; then
inputFileOut=$(removeExtension ${inputFile})
# Show commands for conversion
echo ""
echo "* COMMAND THAT WILL BE EXECUTED:"
echo ""
echo " # File detected with resolution" ${resolution_detected}
echo " # Crop '${inputFile}' from 16:9 to 4:3 (1.33:1)"
if [ "${patch_thread}" == "y" ] ; then
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/3*4:ih\" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
else
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/3*4:ih\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\""
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${inputFile}" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/3*4:ih" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} "${inputFileOut}-crop.${v_ext}"
else
${p_ffmpeg} "${inputFile}" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/3*4:ih" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}"
fi
fi
elif [ "${modeCrop}" == "5:4-crop" ] ; then
inputFileOut=$(removeExtension ${inputFile})
# Show commands for conversion
echo ""
echo "* COMMAND THAT WILL BE EXECUTED:"
echo ""
echo " # File detected with resolution" ${resolution_detected}
echo " # Crop '${inputFile}' from 16:9 to 5:4 (1.25:1)"
if [ "${patch_thread}" == "y" ] ; then
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/4*5:ih\" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
else
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/4*5:ih\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\""
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${inputFile}" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/4*5:ih" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} "${inputFileOut}-crop.${v_ext}"
else
${p_ffmpeg} "${inputFile}" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/4*5:ih" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}"
fi
fi
elif [ "${modeCrop}" == "imax-crop" ] ; then
inputFileOut=$(removeExtension ${inputFile})
# Show commands for conversion
echo ""
echo "* COMMAND THAT WILL BE EXECUTED:"
echo ""
echo " # File detected with resolution" ${resolution_detected}
echo " # Crop '${inputFile}' from 16:9 to IMAX (1.43:1)"
if [ "${patch_thread}" == "y" ] ; then
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/2.79*4:ih\" -s ${resolution} ${f_conversion_crop} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
else
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/2.79*4:ih\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\""
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${inputFile}" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/2.79*4:ih" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} "${inputFileOut}-crop.${v_ext}"
else
${p_ffmpeg} "${inputFile}" ${f_conversion_crop} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/2.79*4:ih" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}"
fi
fi
elif [ "${modeCrop}" == "16:9-aspect" ] ; then
inputFileOut=$(removeExtension ${inputFile})
# Show commands for conversion
echo ""
echo "* COMMAND THAT WILL BE EXECUTED:"
echo ""
echo " # File detected with resolution" ${resolution_detected}
echo " # Change '${inputFile}' aspect to 16:9 (stretched)"
if [ "${patch_thread}" == "y" ] ; then
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 16:9 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-aspect.${v_ext}\""
else
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 16:9 -s ${resolution} ${p_conversion} \"${inputFileOut}-aspect.${v_ext}\""
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 16:9 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} "${inputFileOut}-aspect.${v_ext}"
else
${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 16:9 -s ${resolution} ${p_conversion} "${inputFileOut}-aspect.${v_ext}"
fi
fi
elif [ "${modeCrop}" == "4:3-aspect" ] ; then
inputFileOut=$(removeExtension ${inputFile})
# Show commands for conversion
echo ""
echo "* COMMAND THAT WILL BE EXECUTED:"
echo ""
echo " # File detected with resolution" ${resolution_detected}
echo " # Change '${inputFile}' aspect to 4:3 (stretched)"
if [ "${patch_thread}" == "y" ] ; then
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 4:3 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-aspect.${v_ext}\""
else
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 4:3 -s ${resolution} ${p_conversion} \"${inputFileOut}-aspect.${v_ext}\""
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 4:3 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} "${inputFileOut}-aspect.${v_ext}"
else
${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 4:3 -s ${resolution} ${p_conversion} "${inputFileOut}-aspect.${v_ext}"
fi
fi
elif [ "${modeCrop}" == "5:4-aspect" ] ; then
inputFileOut=$(removeExtension ${inputFile})
# Show commands for conversion
echo ""
echo "* COMMAND THAT WILL BE EXECUTED:"
echo ""
echo " # File detected with resolution" ${resolution_detected}
echo " # Change '${inputFile}' aspect to 5:4 (stretched)"
if [ "${patch_thread}" == "y" ] ; then
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 5:4 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-aspect.${v_ext}\""
else
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 5:4 -s ${resolution} ${p_conversion} \"${inputFileOut}-aspect.${v_ext}\""
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 5:4 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} "${inputFileOut}-aspect.${v_ext}"
else
${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 5:4 -s ${resolution} ${p_conversion} "${inputFileOut}-aspect.${v_ext}"
fi
fi
else
show_menu
fi
}
# Syntax: ks-crop <option> </absolute/path/video.mkv>
if [ -z "${1}" ] ; then
show_menu
exit
fi
if [ -f "${2}" ] ; then
echo "detected" > /dev/null
else
errorReadingFile "${2}"
fi
# Define variables for crop_video function
if [ "${1}" == "-16:9-crop" ] ; then
modeCrop="16:9-crop"
resolution="${to16_9}"
crop_video
elif [ "${1}" == "-4:3-crop" ] ; then
modeCrop="4:3-crop"
resolution="${to4_3}"
crop_video
elif [ "${1}" == "-5:4-crop" ] ; then
modeCrop="5:4-crop"
resolution="${to5_4}"
crop_video
elif [ "${1}" == "-imax-crop" ] ; then
modeCrop="imax-crop"
resolution="${toImax}"
crop_video
elif [ "${1}" == "-16:9-aspect" ] ; then
modeCrop="16:9-aspect"
resolution="${to16_9}"
crop_video
elif [ "${1}" == "-4:3-aspect" ] ; then
modeCrop="4:3-aspect"
resolution="${to4_3}"
crop_video
elif [ "${1}" == "-5:4-aspect" ] ; then
modeCrop="5:4-aspect"
resolution="${to5_4}"
crop_video
else
show_menu
fi

1963
src/ks-mix

File diff suppressed because it is too large Load Diff

View File

@ -2,17 +2,19 @@
#########################################################################
# ks-mp3 (ks-tools) - Convert video/audio file(s) to MP3 (Audio) Format #
# Date: 10-02-2021 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
#########################################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="021123"
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp3
# Basic parameters
acodec="libmp3lame"
@ -20,122 +22,182 @@ b_acodec="128k"
v_ext="mp3"
default_lang_audio="spa"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
if [ ${error_ffmpeg} -ne 0 ] ; then
echo ""
echo "* ks-mp3 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ffmpeg' tool is not installed!"
echo ""
exit
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep sed grep cut head tail tr cat"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-mp3 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp2//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.oga//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ac3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.aac//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp2//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.oga//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ac3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.aac//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flac//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wav//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.opus//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
cutDisplayName=$(echo ${DisplayName} | cut -c1)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c2-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c2)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c3-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c3)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c4-100)
fi
fi
fi
echo ${DisplayName}
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
cutDisplayName=$(echo ${DisplayName} | cut -c1)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c2-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c2)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c3-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c3)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c4-100)
fi
fi
fi
echo ${DisplayName}
}
# Sintax: ks-mp3 </absolute/path/song.ogg> </path/prefix_name>
# Syntax: ks-mp3 </absolute/path/song.ogg> </path/prefix_name>
if [ -z "${1}" ] ; then
echo ""
echo "* ks-mp3 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video/audio file(s) to MP3 (Audio) Format"
echo ""
echo "+ Config:"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-mp3 </absolute/path/song.ogg> </path/prefix_name>"
echo ""
echo " + Example: ks-mp3 /data/songs/Example.ogg /data/converted/Example"
echo ""
exit
echo ""
echo "* ks-mp3 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video/audio file(s) to MP3 (Audio) Format"
echo ""
echo "+ Config: ${configFile}"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-mp3 </absolute/path/song.ogg> </path/prefix_name>"
echo ""
echo " + Example: ks-mp3 /data/songs/Example.ogg /data/converted/Example"
echo ""
exit
fi
if [ -f "${1}" ] ; then
echo "detected" > /dev/null
echo "detected" > /dev/null
else
echo ""
echo "* ks-mp3 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
echo ""
echo "* ks-mp3 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
fi
# Conversion parameters
@ -144,122 +206,132 @@ p_ffmpeg="ffmpeg -i"
# Init conversion file
current_date=$(date +%Y)
if [ -z "${2}" ] ; then
echo ""
echo "* ks-mp3 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video/audio file(s) to MP3 (Audio) Format"
echo ""
echo "+ Config:"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-mp3 </absolute/path/song.ogg> </path/prefix_name>"
echo ""
echo " + Example: ks-mp3 /data/songs/Example.ogg /data/converted/Example"
echo ""
exit
echo ""
echo "* ks-mp3 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video/audio file(s) to MP3 (Audio) Format"
echo ""
echo "+ Config:"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-mp3 </absolute/path/song.ogg> </path/prefix_name>"
echo ""
echo " + Example: ks-mp3 /data/songs/Example.ogg /data/converted/Example"
echo ""
exit
else
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Ask for METADATA
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: Album-Disc) Type name of album: " ; read album_file
if [ -z "${album_file}" ] ; then
album_title="Album-Disc"
else
album_title="${album_file}"
fi
echo -n "* (Default: 01) Type number of track: " ; read track_file
if [ -z "${track_file}" ] ; then
track_num="01"
else
track_num="${track_file}"
fi
echo -n "* (Default: Artist) Type name of artist: " ; read artist_file
if [ -z "${artist_file}" ] ; then
artist_title="Artist"
else
artist_title="${artist_file}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_num="${current_date}"
else
year_num="${year_file}"
fi
echo -n "* (Default: Pop) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Pop"
else
genre_file="${genre_file}"
fi
# Ask for METADATA
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: Album-Disc) Type name of album: " ; read album_file
if [ -z "${album_file}" ] ; then
album_title="Album-Disc"
else
album_title="${album_file}"
fi
echo -n "* (Default: 01) Type number of track: " ; read track_file
if [ -z "${track_file}" ] ; then
track_num="01"
else
track_num="${track_file}"
fi
echo -n "* (Default: Artist) Type name of artist: " ; read artist_file
if [ -z "${artist_file}" ] ; then
artist_title="Artist"
else
artist_title="${artist_file}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_num="${current_date}"
else
year_num="${year_file}"
fi
echo -n "* (Default: Pop) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Pop"
else
genre_file="${genre_file}"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
echo " # Convert the file '${1}' to MP3 Audio"
echo " ${p_ffmpeg} \"${1}\" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} -metadata title=\"${name_title}\" -metadata date=\"${year_num}\" -metadata genre=\"${genre_file}\" -metadata album=\"${album_title}\" -metadata artist=\"${artist_title}\" -metadata track=\"${track_num}\" \"${2}.${v_ext}\""
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
${p_ffmpeg} "${1}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "${2}.${v_ext}"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
echo " # Convert the file '${1}' to MP3 Audio"
echo " ${p_ffmpeg} \"${1}\" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_num}\" -metadata genre=\"${genre_file}\" -metadata album=\"${album_title}\" -metadata artist=\"${artist_title}\" -metadata track=\"${track_num}\" \"${2}.${v_ext}\""
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
${p_ffmpeg} "${1}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "${2}.${v_ext}"
fi
fi

View File

@ -2,22 +2,24 @@
######################################################################
# ks-mp3-album (ks-tools) - Convert folder album to MP3 Audio Format #
# Date: 10-02-2021 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
######################################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="021123"
# Variables
tempFile="/tmp/ks-mp4s-folder.txt"
tempFileTest="/tmp/ks-mp4s-folder-test.txt"
formatFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ogg oga mp3 mp2 aac ac3"
formatFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ogg oga mp3 mp2 aac ac3 flac opus wav"
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp3
# Basic parameters
acodec="libmp3lame"
@ -27,112 +29,172 @@ track_init="1"
artist_init="Artist"
default_lang_audio="spa"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
if [ ${error_ffmpeg} -ne 0 ] ; then
echo ""
echo "* ks-mp3-album (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ffmpeg' tool is not installed!"
echo ""
exit
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep find grep cut head tail tr cat"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-mp3-album (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
cutDisplayName=$(echo ${DisplayName} | cut -c1)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c2-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c2)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c3-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c3)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c4-100)
fi
fi
fi
echo ${DisplayName}
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
cutDisplayName=$(echo ${DisplayName} | cut -c1)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c2-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c2)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c3-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c3)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c4-100)
fi
fi
fi
echo ${DisplayName}
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp2//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.oga//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ac3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.aac//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp2//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.oga//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ac3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.aac//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flac//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wav//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.opus//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Sintax: ks-mp3-album </absolute/path/album/
# Syntax: ks-mp3-album </absolute/path/album/
if [ -z "${1}" ] ; then
echo ""
echo "* ks-mp3-album (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert folder album to MP3 Audio Format"
echo ""
echo "+ Config:"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-mp3 </absolute/path/album>"
echo ""
echo " + Example: ks-mp3 /data/albums/matrix-soundtrack"
echo ""
exit
echo ""
echo "* ks-mp3-album (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert folder album to MP3 Audio Format"
echo ""
echo "+ Config: ${configFile}"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-mp3-album </absolute/path/album>"
echo ""
echo " + Example: ks-mp3-album /data/albums/matrix-soundtrack"
echo ""
exit
fi
# Check if folder exist
@ -154,7 +216,7 @@ echo "* ks-mp3-album (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert folder album to MP3 Audio Format"
echo ""
echo -n "* Scanning ${1} " && sleep 4
echo -n "* Scanning ${1} "
echo ""
rm -rf ${tempFile} && touch ${tempFile}
for format in ${formatFiles} ; do
@ -163,7 +225,9 @@ for format in ${formatFiles} ; do
echo "null" > /dev/null
else
echo "+ Video file(s) in .${format} found!"
cd "${1}" && ls -1 *.${format} &>> ${tempFile}
cd "${1}" && ls -1 *.${format} &> /tmp/tempFile.txt
cat /tmp/tempFile.txt >> ${tempFile}
rm -rf /tmp/tempFile.txt 2> /dev/null
fail=0
fi
done
@ -175,21 +239,21 @@ echo "* Common METADATA configuration:"
echo ""
echo -n "* (Default: Album-Disc) Type name of album: " ; read album_file
if [ -z "${album_file}" ] ; then
album_title="Album-Disc"
album_title="Album-Disc"
else
album_title="${album_file}"
album_title="${album_file}"
fi
echo -n "* (Default: ${current_date}) Type the year of album: " ; read year_file
if [ -z "${year_file}" ] ; then
year_num="${current_date}"
year_num="${current_date}"
else
year_num="${year_file}"
year_num="${year_file}"
fi
echo -n "* (Default: Pop) Type the genre of album: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Pop"
genre_file="Pop"
else
genre_file="${genre_file}"
genre_file="${genre_file}"
fi
# Init the conversion files
@ -201,16 +265,16 @@ if [ ${num_files} -eq 0 ] ; then
echo ""
exit
else
echo ""
echo "* List of files:"
echo ""
echo ""
echo "* List of files:"
echo ""
while [ ${convert_files} -le ${num_files} ] ; do
show_file=$(cat ${tempFile} | head -${convert_files} | tail -1)
echo " + ${show_file}"
convert_files=$(expr ${convert_files} + 1)
done
echo ""
echo "* The output folder will be '${1}/to-oga'"
echo "* The output folder will be '${1}/to-mp3'"
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
@ -218,77 +282,86 @@ else
exit
else
convert_files=1
cd "${1}" && mkdir -p to-oga && rm -rf to-oga/*
cd "${1}" && mkdir -p to-mp3 && rm -rf to-mp3/*
while [ ${convert_files} -le ${num_files} ] ; do
show_file=$(cat ${tempFile} | head -${convert_files} | tail -1)
fname=$(echo "${show_file}" | cut -d "." -f 1)
name_title_default=$(removeExtension "${show_file}")
name_title_default=$(showFileWithSpace "${name_title_default}")
echo ""
echo "* METADATA for '${show_file}'"
echo ""
echo " - Album: ${album_title}"
echo " - Year: ${year_num}"
echo " - Genre: ${genre_file}"
echo ""
echo "* Information of '${show_file}':"
echo ""
echo "+ Audio Tracks:"
echo ""
ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
# Check the audio track by default
audio_default=$(ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${track_init}) Type number of track: " ; read track_file
if [ -z "${track_file}" ] ; then
track_num="${track_init}"
else
track_num="${track_file}"
fi
echo -n "* (Default: ${artist_init}) Type name of artist: " ; read artist_file
if [ -z "${artist_file}" ] ; then
artist_title="${artist_init}"
else
artist_title="${artist_file}"
artist_init="${artist_file}"
fi
ffmpeg -i "${show_file}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "to-oga/${fname}.${v_ext}"
# Increment variables
convert_files=$(expr ${convert_files} + 1)
track_init=$(expr ${track_num} + 1)
echo ""
echo "* METADATA for '${show_file}'"
echo ""
echo " - Album: ${album_title}"
echo " - Year: ${year_num}"
echo " - Genre: ${genre_file}"
echo ""
echo "* Information of '${show_file}':"
echo ""
echo "+ Audio Tracks:"
echo ""
ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
# Check the audio track by default
audio_default=$(ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${track_init}) Type number of track: " ; read track_file
if [ -z "${track_file}" ] ; then
track_num="${track_init}"
else
track_num="${track_file}"
fi
echo -n "* (Default: ${artist_init}) Type name of artist: " ; read artist_file
if [ -z "${artist_file}" ] ; then
artist_title="${artist_init}"
else
artist_title="${artist_file}"
artist_init="${artist_file}"
fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
ffmpeg -i "${show_file}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "to-mp3/${fname}.${v_ext}"
# Increment variables
convert_files=$(expr ${convert_files} + 1)
track_init=$(expr ${track_num} + 1)
done
fi
fi

View File

@ -2,378 +2,555 @@
###############################################################
# ks-mp4 (ks-tools) - Convert video to MP4 format #
# Date: 10-02-2021 #
# Date: 04-01-2025 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
###############################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="040125"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=$' \t\n'
unset IFS
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] 2> /dev/null ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4
# Basic parameters
# Basic parameters creating config file.
rel_size="1280x534"
vcodec="libx264"
b_vcodec="2400k"
b_vcodec="2200k"
# Presets: ultrafast, superfast, veryfast, faster,
# fast, medium (default), slow, slower, veryslow
v_preset="medium"
v_preset="slow"
acodec="aac"
b_acodec="256k"
b_acodec="192k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="mp4"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Setting the correct resolution for the video file
# Sintaxis: set_resolution <resolution> <file>
function set_resolution() {
check_bc_app_directories="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
set_rel="${1}"
input_video_file="${2}"
bc_found="1"
for file in ${check_bc_app_directories} ; do
if [ -f ${file}/bc ] ; then
bc_found=0
fi
done
if [ ${bc_found} -eq 0 ] ; then
file_rel=$(ffmpeg -i "${2}" 2>&1 | grep Stream | grep Video: | grep -Po '\d{3,5}x\d{3,5}' 2> /dev/null | head -1)
if [ -z "${file_rel}" ] ; then
echo ${set_rel}
else
file_rel_width=$(echo ${file_rel} | cut -d "x" -f 1)
file_rel_height=$(echo ${file_rel} | cut -d "x" -f 2)
set_rel_width=$(echo ${set_rel} | cut -d "x" -f 1)
aspect_rel=$(echo ${file_rel_width} / ${file_rel_height} | bc -l)
new_rel_height=$(echo ${set_rel_width} / ${aspect_rel} | bc)
even_number=$(echo ${new_rel_height} % 2 | bc)
if [ ${even_number} -ne 0 ] ; then
new_rel_height=$(expr ${new_rel_height} + 1)
fi
echo ${set_rel_width}x${new_rel_height}
fi
else
echo ${set_rel}
fi
}
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
if [ ${error_ffmpeg} -ne 0 ] ; then
echo ""
echo "* ks-mp4 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ffmpeg' tool is not installed!"
echo ""
exit
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep sed grep cut head tail tr cat bc"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-mp4 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Sintax: ks-mp4 </absolute/path/video.mkv> </path/prefix_name>
# Syntax: ks-mp4 </absolute/path/video.mkv> </path/prefix_name>
if [ -z "${1}" ] ; then
echo ""
echo "* ks-mp4 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4"
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-mp4 </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4 /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
echo ""
echo "* ks-mp4 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4"
echo ""
echo "+ Config: ${configFile}"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-mp4 </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4 /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
fi
if [ -f "${1}" ] ; then
echo "detected" > /dev/null
echo "detected" > /dev/null
else
echo ""
echo "* ks-mp4 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
echo ""
echo "* ks-mp4 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
fi
# Load profile for codecs
profile_codec=" "
selected_codec="${vcodec}"
if [ "${selected_codec}" == "libx264" ] ; then
profile_codec=" -profile:v high "
elif [ "${selected_codec}" == "libx265" ] ; then
profile_codec=" -profile:v main "
elif [ "${selected_codec}" == "libaom-av1" ] ; then
profile_codec=" -profile:v main "
else
profile_codec=" "
fi
# Conversion parameters
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
f_conversion="-vsync 1 -async 1"
f_conversion="-${video_sync} cfr -af aresample=async=1"
# Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")
yuv420p10le=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "yuv420p10le")
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}"
hevc_main10=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "Main 10")
hevc_hdr_bt=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "bt2020")
hevc_hdr_smp=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "smpte2084")
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}${hevc_main10}"
hevc_hdr="${hevc_hdr_bt}${hevc_hdr_smp}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
if [ -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
# Init conversion file
current_date=$(date +%Y)
if [ -z "${2}" ] ; then
echo ""
echo "* ks-mp4 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4"
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-mp4 </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4 /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
echo ""
echo "* ks-mp4 (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4"
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-mp4 </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4 /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
else
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Video Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo "+ Subtitle Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d "," -f 1
echo ""
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
video_default_patch=$(echo ${video_default} | cut -c4)
if [ "${video_default_patch}" == ":" ] ; then
video_default=$(echo ${video_default} | cut -c1-3)
else
video_default="${video_default}"
fi
fi
# Ask for video
echo -n "* (Default: ${video_default}) Type the number of video track: " ; read video_track
if [ -z "${video_track}" ] ; then
video_track="${video_default}"
else
video_track="${video_track}"
fi
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
# Ask for subtitle
echo -n "* (Default: n) Do you want include subtitles? (y/n): " ; read subtitles_y_n
if [ "${subtitles_y_n}" == "y" ] ; then
echo -n "* (Default: ${subtitle_default}) Type the number of subtitle track: " ; read subtitle_track
if [ -z "${subtitle_track}" ] ; then
subtitle_track="${subtitle_default}"
else
subtitle_track="${subtitle_track}"
fi
fi
echo -n "* (Default: ${rel_size}) Type the resolution: " ; read resolution
if [ -z "${resolution}" ] ; then
resolution="${rel_size}"
else
rel_size="${resolution}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread
if [ "${patch_thread}" == "y" ] ; then
patch_thread="y"
else
patch_thread="n"
fi
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_file="${current_date}"
else
year_file="${year_file}"
fi
echo -n "* (Default: Unknown) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Unknown"
else
genre_file="${genre_file}"
fi
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Video Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo "+ Subtitle Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d "," -f 1
echo ""
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
video_default_patch=$(echo ${video_default} | cut -c4)
if [ "${video_default_patch}" == ":" ] ; then
video_default=$(echo ${video_default} | cut -c1-3)
else
video_default="${video_default}"
fi
fi
# Ask for video
echo -n "* (Default: ${video_default}) Type the number of video track: " ; read video_track
if [ -z "${video_track}" ] ; then
video_track="${video_default}"
else
video_track="${video_track}"
fi
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
# Ask for subtitle
echo -n "* (Default: n) Do you want include subtitles? (y/n): " ; read subtitles_y_n
if [ "${subtitles_y_n}" == "y" ] ; then
echo -n "* (Default: ${subtitle_default}) Type the number of subtitle track: " ; read subtitle_track
if [ -z "${subtitle_track}" ] ; then
subtitle_track="${subtitle_default}"
else
subtitle_track="${subtitle_track}"
fi
fi
echo -n "* (Default: ${rel_size}) Type the resolution: " ; read resolution
if [ -z "${resolution}" ] ; then
resolution="${rel_size}"
else
rel_size="${resolution}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
if [ -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
fi
echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread
if [ "${patch_thread}" == "y" ] ; then
patch_thread="y"
else
patch_thread="n"
fi
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_file="${current_date}"
else
year_file="${year_file}"
fi
echo -n "* (Default: Unknown) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Unknown"
else
genre_file="${genre_file}"
fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
if [ "${subtitles_y_n}" == "y" ] ; then
echo " # Extract subtitles from file ${1}"
echo " ${p_ffmpeg} \"${1}\" -map ${subtitle_track} \"${2}.srt\""
echo ""
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
else
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${subtitles_y_n}" == "y" ] ; then
${p_ffmpeg} "${1}" -map ${subtitle_track} "${2}.srt"
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
if [ "${subtitles_y_n}" == "y" ] ; then
echo " # Extract subtitles from file ${1}"
echo " ${p_ffmpeg} \"${1}\" -map ${subtitle_track} \"${2}.srt\""
echo ""
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
fi
else
echo " # Convert the file '${1}' to MP4"
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${subtitles_y_n}" == "y" ] ; then
${p_ffmpeg} "${1}" -map ${subtitle_track} "${2}.srt"
if [ "${patch_thread}" == "y" ] ; then
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
fi
else
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
fi
fi

View File

@ -2,19 +2,37 @@
###############################################################
# ks-mp4k (ks-tools) - Convert video to MP4 format (4K) #
# Date: 10-02-2021 #
# Date: 04-01-2025 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
###############################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="040125"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=$' \t\n'
unset IFS
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] 2> /dev/null ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4k
# Basic parameters
# Basic parameters creating config file.
rel_size="3840x2160"
vcodec="libx264"
b_vcodec="6000k"
@ -27,353 +45,512 @@ default_lang_audio="spa"
default_lang_subt="spa"
v_ext="mp4"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Setting the correct resolution for the video file
# Sintaxis: set_resolution <resolution> <file>
function set_resolution() {
check_bc_app_directories="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
set_rel="${1}"
input_video_file="${2}"
bc_found="1"
for file in ${check_bc_app_directories} ; do
if [ -f ${file}/bc ] ; then
bc_found=0
fi
done
if [ ${bc_found} -eq 0 ] ; then
file_rel=$(ffmpeg -i "${2}" 2>&1 | grep Stream | grep Video: | grep -Po '\d{3,5}x\d{3,5}' 2> /dev/null | head -1)
if [ -z "${file_rel}" ] ; then
echo ${set_rel}
else
file_rel_width=$(echo ${file_rel} | cut -d "x" -f 1)
file_rel_height=$(echo ${file_rel} | cut -d "x" -f 2)
set_rel_width=$(echo ${set_rel} | cut -d "x" -f 1)
aspect_rel=$(echo ${file_rel_width} / ${file_rel_height} | bc -l)
new_rel_height=$(echo ${set_rel_width} / ${aspect_rel} | bc)
even_number=$(echo ${new_rel_height} % 2 | bc)
if [ ${even_number} -ne 0 ] ; then
new_rel_height=$(expr ${new_rel_height} + 1)
fi
echo ${set_rel_width}x${new_rel_height}
fi
else
echo ${set_rel}
fi
}
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
if [ ${error_ffmpeg} -ne 0 ] ; then
echo ""
echo "* ks-mp4k (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ffmpeg' tool is not installed!"
echo ""
exit
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep sed grep cut head tail tr cat bc"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-mp4k (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Sintax: ks-mp4k </absolute/path/video.mkv> </path/prefix_name>
# Syntax: ks-mp4k </absolute/path/video.mkv> </path/prefix_name>
if [ -z "${1}" ] ; then
echo ""
echo "* ks-mp4k (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4 (4K)"
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-mp4k </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4k /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
echo ""
echo "* ks-mp4k (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4 (4K)"
echo ""
echo "+ Config: ${configFile}"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-mp4k </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4k /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
fi
if [ -f "${1}" ] ; then
echo "detected" > /dev/null
echo "detected" > /dev/null
else
echo ""
echo "* ks-mp4k (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
echo ""
echo "* ks-mp4k (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
fi
# Load profile for codecs
profile_codec=" "
selected_codec="${vcodec}"
if [ "${selected_codec}" == "libx264" ] ; then
profile_codec=" -profile:v high "
elif [ "${selected_codec}" == "libx265" ] ; then
profile_codec=" -profile:v main "
elif [ "${selected_codec}" == "libaom-av1" ] ; then
profile_codec=" -profile:v main "
else
profile_codec=" "
fi
# Conversion parameters
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
f_conversion="-vsync 1 -async 1"
f_conversion="-${video_sync} cfr -af aresample=async=1"
# Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")
yuv420p10le=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "yuv420p10le")
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}"
hevc_main10=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "Main 10")
hevc_hdr_bt=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "bt2020")
hevc_hdr_smp=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "smpte2084")
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}${hevc_main10}"
hevc_hdr="${hevc_hdr_bt}${hevc_hdr_smp}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
if [ -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
# Init conversion file
current_date=$(date +%Y)
if [ -z "${2}" ] ; then
echo ""
echo "* ks-mp4k (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4 (4K)"
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-mp4k </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4k /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
echo ""
echo "* ks-mp4k (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4 (4K)"
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-mp4k </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4k /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
else
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Video Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo "+ Subtitle Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d "," -f 1
echo ""
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
video_default_patch=$(echo ${video_default} | cut -c4)
if [ "${video_default_patch}" == ":" ] ; then
video_default=$(echo ${video_default} | cut -c1-3)
else
video_default="${video_default}"
fi
fi
# Ask for video
echo -n "* (Default: ${video_default}) Type the number of video track: " ; read video_track
if [ -z "${video_track}" ] ; then
video_track="${video_default}"
else
video_track="${video_track}"
fi
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
# Ask for subtitle
echo -n "* (Default: n) Do you want include subtitles? (y/n): " ; read subtitles_y_n
if [ "${subtitles_y_n}" == "y" ] ; then
echo -n "* (Default: ${subtitle_default}) Type the number of subtitle track: " ; read subtitle_track
if [ -z "${subtitle_track}" ] ; then
subtitle_track="${subtitle_default}"
else
subtitle_track="${subtitle_track}"
fi
fi
echo -n "* (Default: ${rel_size}) Type the resolution: " ; read resolution
if [ -z "${resolution}" ] ; then
resolution="${rel_size}"
else
rel_size="${resolution}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread
if [ "${patch_thread}" == "y" ] ; then
patch_thread="y"
else
patch_thread="n"
fi
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_file="${current_date}"
else
year_file="${year_file}"
fi
echo -n "* (Default: Unknown) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Unknown"
else
genre_file="${genre_file}"
fi
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Video Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo "+ Subtitle Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d "," -f 1
echo ""
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
video_default_patch=$(echo ${video_default} | cut -c4)
if [ "${video_default_patch}" == ":" ] ; then
video_default=$(echo ${video_default} | cut -c1-3)
else
video_default="${video_default}"
fi
fi
# Ask for video
echo -n "* (Default: ${video_default}) Type the number of video track: " ; read video_track
if [ -z "${video_track}" ] ; then
video_track="${video_default}"
else
video_track="${video_track}"
fi
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
# Ask for subtitle
echo -n "* (Default: n) Do you want include subtitles? (y/n): " ; read subtitles_y_n
if [ "${subtitles_y_n}" == "y" ] ; then
echo -n "* (Default: ${subtitle_default}) Type the number of subtitle track: " ; read subtitle_track
if [ -z "${subtitle_track}" ] ; then
subtitle_track="${subtitle_default}"
else
subtitle_track="${subtitle_track}"
fi
fi
echo -n "* (Default: ${rel_size}) Type the resolution: " ; read resolution
if [ -z "${resolution}" ] ; then
resolution="${rel_size}"
else
rel_size="${resolution}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
if [ -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
fi
echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread
if [ "${patch_thread}" == "y" ] ; then
patch_thread="y"
else
patch_thread="n"
fi
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_file="${current_date}"
else
year_file="${year_file}"
fi
echo -n "* (Default: Unknown) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Unknown"
else
genre_file="${genre_file}"
fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
if [ "${subtitles_y_n}" == "y" ] ; then
echo " # Extract subtitles from file ${1}"
echo " ${p_ffmpeg} \"${1}\" -map ${subtitle_track} \"${2}.srt\""
echo ""
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
else
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${subtitles_y_n}" == "y" ] ; then
${p_ffmpeg} "${1}" -map ${subtitle_track} "${2}.srt"
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
if [ "${subtitles_y_n}" == "y" ] ; then
echo " # Extract subtitles from file ${1}"
echo " ${p_ffmpeg} \"${1}\" -map ${subtitle_track} \"${2}.srt\""
echo ""
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
fi
else
echo " # Convert the file '${1}' to MP4"
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title} (${year_file})\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title} (${year_file})\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${subtitles_y_n}" == "y" ] ; then
${p_ffmpeg} "${1}" -map ${subtitle_track} "${2}.srt"
if [ "${patch_thread}" == "y" ] ; then
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
fi
else
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title} (${year_file})" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title} (${year_file})" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
fi
fi

View File

@ -2,17 +2,35 @@
###############################################################
# ks-mp4s (ks-tools) - Convert video to MP4 format (Series) #
# Date: 10-02-2021 #
# Date: 04-01-2025 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
###############################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="040125"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=$' \t\n'
unset IFS
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] 2> /dev/null ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4s
# Basic parameters
rel_size="720x480"
@ -20,360 +38,519 @@ vcodec="libx264"
b_vcodec="950k"
# Presets: ultrafast, superfast, veryfast, faster,
# fast, medium (default), slow, slower, veryslow
v_preset="medium"
v_preset="slow"
acodec="aac"
b_acodec="128k"
default_lang_audio="spa"
default_lang_subt="spa"
v_ext="mp4"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Setting the correct resolution for the video file
# Sintaxis: set_resolution <resolution> <file>
function set_resolution() {
check_bc_app_directories="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
set_rel="${1}"
input_video_file="${2}"
bc_found="1"
for file in ${check_bc_app_directories} ; do
if [ -f ${file}/bc ] ; then
bc_found=0
fi
done
if [ ${bc_found} -eq 0 ] ; then
file_rel=$(ffmpeg -i "${2}" 2>&1 | grep Stream | grep Video: | grep -Po '\d{3,5}x\d{3,5}' 2> /dev/null | head -1)
if [ -z "${file_rel}" ] ; then
echo ${set_rel}
else
file_rel_width=$(echo ${file_rel} | cut -d "x" -f 1)
file_rel_height=$(echo ${file_rel} | cut -d "x" -f 2)
set_rel_width=$(echo ${set_rel} | cut -d "x" -f 1)
aspect_rel=$(echo ${file_rel_width} / ${file_rel_height} | bc -l)
new_rel_height=$(echo ${set_rel_width} / ${aspect_rel} | bc)
even_number=$(echo ${new_rel_height} % 2 | bc)
if [ ${even_number} -ne 0 ] ; then
new_rel_height=$(expr ${new_rel_height} + 1)
fi
echo ${set_rel_width}x${new_rel_height}
fi
else
echo ${set_rel}
fi
}
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
rel_size=$(set_resolution ${rel_size} "${1}")
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
if [ ${error_ffmpeg} -ne 0 ] ; then
echo ""
echo "* ks-mp4s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ffmpeg' tool is not installed!"
echo ""
exit
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep sed grep cut head tail tr cat bc"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-mp4s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Sintax: ks-mp4s </absolute/path/video.mkv> </path/prefix_name>
# Syntax: ks-mp4s </absolute/path/video.mkv> </path/prefix_name>
if [ -z "${1}" ] ; then
echo ""
echo "* ks-mp4s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4 (Series)"
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-mp4s </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4s /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
echo ""
echo "* ks-mp4s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4 (Series)"
echo ""
echo "+ Config: ${configFile}"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-mp4s </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4s /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
fi
if [ -f "${1}" ] ; then
echo "detected" > /dev/null
echo "detected" > /dev/null
else
echo ""
echo "* ks-mp4s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
echo ""
echo "* ks-mp4s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
fi
# Load profile for codecs
profile_codec=" "
selected_codec="${vcodec}"
if [ "${selected_codec}" == "libx264" ] ; then
profile_codec=" -profile:v high "
elif [ "${selected_codec}" == "libx265" ] ; then
profile_codec=" -profile:v main "
elif [ "${selected_codec}" == "libaom-av1" ] ; then
profile_codec=" -profile:v main "
else
profile_codec=" "
fi
# Conversion parameters
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
f_conversion="-vsync 1 -async 1"
f_conversion="-${video_sync} cfr -af aresample=async=1"
# Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")
yuv420p10le=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "yuv420p10le")
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}"
hevc_main10=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "Main 10")
hevc_hdr_bt=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "bt2020")
hevc_hdr_smp=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "smpte2084")
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}${hevc_main10}"
hevc_hdr="${hevc_hdr_bt}${hevc_hdr_smp}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
if [ -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
# Init conversion file
current_date=$(date +%Y)
if [ -z "${2}" ] ; then
echo ""
echo "* ks-mp4s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4 (Series)"
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-mp4s </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4s /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
echo ""
echo "* ks-mp4s (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient MP4 (Series)"
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}"
echo " - Bitrate video: ${b_vcodec}"
echo " - Preset: ${v_preset}"
echo " - Audio codec: ${acodec} (stereo)"
echo " - Bitrate audio: ${b_acodec}"
echo " - Default Audio: ${default_lang_audio}"
echo " - Default Subtitle: ${default_lang_subt} (forced)"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-mp4s </absolute/path/video.mkv> </path/prefix_name>"
echo ""
echo " + Example: ks-mp4s /data/movies/Example.mkv /data/converted/Example"
echo ""
exit
else
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Video Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo "+ Subtitle Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d "," -f 1
echo ""
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
video_default_patch=$(echo ${video_default} | cut -c4)
if [ "${video_default_patch}" == ":" ] ; then
video_default=$(echo ${video_default} | cut -c1-3)
else
video_default="${video_default}"
fi
fi
# Ask for video
echo -n "* (Default: ${video_default}) Type the number of video track: " ; read video_track
if [ -z "${video_track}" ] ; then
video_track="${video_default}"
else
video_track="${video_track}"
fi
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
# Ask for subtitle
echo -n "* (Default: n) Do you want include subtitles? (y/n): " ; read subtitles_y_n
if [ "${subtitles_y_n}" == "y" ] ; then
echo -n "* (Default: ${subtitle_default}) Type the number of subtitle track: " ; read subtitle_track
if [ -z "${subtitle_track}" ] ; then
subtitle_track="${subtitle_default}"
else
subtitle_track="${subtitle_track}"
fi
fi
echo -n "* (Default: ${rel_size}) Type the resolution: " ; read resolution
if [ -z "${resolution}" ] ; then
resolution="${rel_size}"
else
rel_size="${resolution}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread
if [ "${patch_thread}" == "y" ] ; then
patch_thread="y"
else
patch_thread="n"
fi
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_file="${current_date}"
else
year_file="${year_file}"
fi
echo -n "* (Default: Unknown) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Unknown"
else
genre_file="${genre_file}"
fi
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Video Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo "+ Subtitle Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d "," -f 1
echo ""
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
video_default_patch=$(echo ${video_default} | cut -c4)
if [ "${video_default_patch}" == ":" ] ; then
video_default=$(echo ${video_default} | cut -c1-3)
else
video_default="${video_default}"
fi
fi
# Ask for video
echo -n "* (Default: ${video_default}) Type the number of video track: " ; read video_track
if [ -z "${video_track}" ] ; then
video_track="${video_default}"
else
video_track="${video_track}"
fi
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
# Ask for subtitle
echo -n "* (Default: n) Do you want include subtitles? (y/n): " ; read subtitles_y_n
if [ "${subtitles_y_n}" == "y" ] ; then
echo -n "* (Default: ${subtitle_default}) Type the number of subtitle track: " ; read subtitle_track
if [ -z "${subtitle_track}" ] ; then
subtitle_track="${subtitle_default}"
else
subtitle_track="${subtitle_track}"
fi
fi
echo -n "* (Default: ${rel_size}) Type the resolution: " ; read resolution
if [ -z "${resolution}" ] ; then
resolution="${rel_size}"
else
rel_size="${resolution}"
if [ -z "${codec_h265_hevc}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
if [ -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec}${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
else
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
fi
fi
fi
echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread
if [ "${patch_thread}" == "y" ] ; then
patch_thread="y"
else
patch_thread="n"
fi
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_file="${current_date}"
else
year_file="${year_file}"
fi
echo -n "* (Default: Unknown) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Unknown"
else
genre_file="${genre_file}"
fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
if [ "${subtitles_y_n}" == "y" ] ; then
echo " # Extract subtitles from file ${1}"
echo " ${p_ffmpeg} \"${1}\" -map ${subtitle_track} \"${2}.srt\""
echo ""
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
else
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${subtitles_y_n}" == "y" ] ; then
${p_ffmpeg} "${1}" -map ${subtitle_track} "${2}.srt"
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
if [ "${subtitles_y_n}" == "y" ] ; then
echo " # Extract subtitles from file ${1}"
echo " ${p_ffmpeg} \"${1}\" -map ${subtitle_track} \"${2}.srt\""
echo ""
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
fi
else
echo " # Convert the file '${1}' to MP4"
if [ ! -z "${hevc_hdr}" ] ; then
p_conversion="-s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles=\"${2}.srt\"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
else
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles=\"${2}.srt\" ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" ${p_ffmpeg_patched} \"${2}.${v_ext}\""
else
echo " # Convert the file '${1}' to MP4"
echo " ${p_ffmpeg} \"${1}\" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_file}\" -metadata genre=\"${genre_file}\" -metadata:s:v:0 title=\"${name_title}\" -metadata:s:a:0 title=\"${acodec} Stereo Audio (${b_acodec})\" \"${2}.${v_ext}\""
fi
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
if [ "${subtitles_y_n}" == "y" ] ; then
${p_ffmpeg} "${1}" -map ${subtitle_track} "${2}.srt"
if [ "${patch_thread}" == "y" ] ; then
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
fi
else
if [ ! -z "${hevc_hdr}" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -s ${rel_size} -c:v ${vcodec} -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,subtitles="${2}.srt"${profile_codec}-pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} -vf subtitles="${2}.srt" ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
else
if [ "${patch_thread}" == "y" ] ; then
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" ${p_ffmpeg_patched} "${2}.${v_ext}"
else
${p_ffmpeg} "${1}" ${f_conversion} -map ${video_track} -map ${audio_track} ${p_conversion} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_file}" -metadata genre="${genre_file}" -metadata:s:v:0 title="${name_title}" -metadata:s:a:0 title="${acodec} Stereo Audio (${b_acodec})" "${2}.${v_ext}"
fi
fi
fi
fi

View File

@ -2,17 +2,56 @@
#################################################################################
# ks-mp4s-folder (ks-tools) - Convert videos from folder to MP4 format (Series) #
# Date: 10-02-2021 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
#################################################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="021123"
# Variables
tempFile="/tmp/ks-mp4s-folder.txt"
tempFileTest="/tmp/ks-mp4s-folder-test.txt"
formatFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob"
formatFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ts"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check if ffmpeg is installed
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep find grep cut head tail cat"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-mp4s-folder (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Show help when folder is empty
if [ -z "${1}" ] ; then
@ -21,7 +60,7 @@ if [ -z "${1}" ] ; then
echo ""
echo "- Convert videos from folder to MP4 format (Series)"
echo ""
echo "+ Sintax: "
echo "+ Syntax: "
echo ""
echo " $ ks-mp4s-folder </path/folder> [subs]"
echo ""
@ -56,7 +95,7 @@ echo "* ks-mp4s-folder (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert videos from folder to MP4 format (Series)"
echo ""
echo -n "* Scanning ${1} " && sleep 4
echo -n "* Scanning ${1} "
echo ""
rm -rf ${tempFile} && touch ${tempFile}
for format in ${formatFiles} ; do
@ -65,7 +104,9 @@ for format in ${formatFiles} ; do
echo "null" > /dev/null
else
echo "+ Video file(s) in .${format} found!"
cd "${1}" && ls -1 *.${format} &>> ${tempFile}
cd "${1}" && ls -1 *.${format} &> /tmp/tempFile.txt
cat /tmp/tempFile.txt >> ${tempFile}
rm -rf /tmp/tempFile.txt 2> /dev/null
fail=0
fi
done
@ -74,7 +115,7 @@ done
num_files=$(cat ${tempFile} | wc -l)
if [ ${num_files} -eq 0 ] ; then
echo ""
echo "+ No video file(s) found in folder '${1}"
echo "+ No video file(s) found in folder '${1}'"
echo ""
exit
else

View File

@ -2,17 +2,19 @@
#############################################################################
# ks-oga (ks-tools) - Convert video/audio file(s) to OGA (OGG Audio) Format #
# Date: 10-02-2021 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
#############################################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="021123"
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-oga
# Basic parameters
acodec="libvorbis"
@ -20,122 +22,182 @@ b_acodec="130k"
v_ext="oga"
default_lang_audio="spa"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
if [ ${error_ffmpeg} -ne 0 ] ; then
echo ""
echo "* ks-oga (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ffmpeg' tool is not installed!"
echo ""
exit
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep sed grep cut head tail tr cat"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-oga (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp2//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.oga//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ac3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.aac//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp2//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.oga//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ac3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.aac//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flac//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wav//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.opus//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
cutDisplayName=$(echo ${DisplayName} | cut -c1)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c2-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c2)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c3-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c3)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c4-100)
fi
fi
fi
echo ${DisplayName}
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
cutDisplayName=$(echo ${DisplayName} | cut -c1)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c2-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c2)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c3-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c3)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c4-100)
fi
fi
fi
echo ${DisplayName}
}
# Sintax: ks-oga </absolute/path/song.mp3> </path/prefix_name>
# Syntax: ks-oga </absolute/path/song.mp3> </path/prefix_name>
if [ -z "${1}" ] ; then
echo ""
echo "* ks-oga (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video/audio file(s) to OGA (OGG Audio) Format"
echo ""
echo "+ Config:"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-oga </absolute/path/song.mp3> </path/prefix_name>"
echo ""
echo " + Example: ks-oga /data/songs/Example.mp3 /data/converted/Example"
echo ""
exit
echo ""
echo "* ks-oga (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video/audio file(s) to OGA (OGG Audio) Format"
echo ""
echo "+ Config: ${configFile}"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-oga </absolute/path/song.mp3> </path/prefix_name>"
echo ""
echo " + Example: ks-oga /data/songs/Example.mp3 /data/converted/Example"
echo ""
exit
fi
if [ -f "${1}" ] ; then
echo "detected" > /dev/null
echo "detected" > /dev/null
else
echo ""
echo "* ks-oga (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
echo ""
echo "* ks-oga (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* The file '${1}' does not exist!"
echo ""
exit
fi
# Conversion parameters
@ -144,122 +206,132 @@ p_ffmpeg="ffmpeg -i"
# Init conversion file
current_date=$(date +%Y)
if [ -z "${2}" ] ; then
echo ""
echo "* ks-oga (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video/audio file(s) to OGA (OGG Audio) Format"
echo ""
echo "+ Config:"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-oga </absolute/path/song.mp3> </path/prefix_name>"
echo ""
echo " + Example: ks-oga /data/songs/Example.mp3 /data/converted/Example"
echo ""
exit
echo ""
echo "* ks-oga (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video/audio file(s) to OGA (OGG Audio) Format"
echo ""
echo "+ Config:"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-oga </absolute/path/song.mp3> </path/prefix_name>"
echo ""
echo " + Example: ks-oga /data/songs/Example.mp3 /data/converted/Example"
echo ""
exit
else
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
# Ask for METADATA
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: Album-Disc) Type name of album: " ; read album_file
if [ -z "${album_file}" ] ; then
album_title="Album-Disc"
else
album_title="${album_file}"
fi
echo -n "* (Default: 01) Type number of track: " ; read track_file
if [ -z "${track_file}" ] ; then
track_num="01"
else
track_num="${track_file}"
fi
echo -n "* (Default: Artist) Type name of artist: " ; read artist_file
if [ -z "${artist_file}" ] ; then
artist_title="Artist"
else
artist_title="${artist_file}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_num="${current_date}"
else
year_num="${year_file}"
fi
echo -n "* (Default: Pop) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Pop"
else
genre_file="${genre_file}"
fi
# Ask for METADATA
echo ""
echo "* METADATA configuration:"
echo ""
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
# Ask name title, year and genre
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: Album-Disc) Type name of album: " ; read album_file
if [ -z "${album_file}" ] ; then
album_title="Album-Disc"
else
album_title="${album_file}"
fi
echo -n "* (Default: 01) Type number of track: " ; read track_file
if [ -z "${track_file}" ] ; then
track_num="01"
else
track_num="${track_file}"
fi
echo -n "* (Default: Artist) Type name of artist: " ; read artist_file
if [ -z "${artist_file}" ] ; then
artist_title="Artist"
else
artist_title="${artist_file}"
fi
echo -n "* (Default: ${current_date}) Type the year: " ; read year_file
if [ -z "${year_file}" ] ; then
year_num="${current_date}"
else
year_num="${year_file}"
fi
echo -n "* (Default: Pop) Type the genre: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Pop"
else
genre_file="${genre_file}"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
echo " # Convert the file '${1}' to OGG Audio"
echo " ${p_ffmpeg} \"${1}\" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} -metadata title=\"${name_title}\" -metadata date=\"${year_num}\" -metadata genre=\"${genre_file}\" -metadata album=\"${album_title}\" -metadata artist=\"${artist_title}\" -metadata track=\"${track_num}\" \"${2}.${v_ext}\""
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
${p_ffmpeg} "${1}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "${2}.${v_ext}"
fi
# Show commands for conversion
echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:"
echo ""
echo " # Convert the file '${1}' to OGG Audio"
echo " ${p_ffmpeg} \"${1}\" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_num}\" -metadata genre=\"${genre_file}\" -metadata album=\"${album_title}\" -metadata artist=\"${artist_title}\" -metadata track=\"${track_num}\" \"${2}.${v_ext}\""
# Execute commands for conversion
echo ""
echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg
if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit
else
${p_ffmpeg} "${1}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "${2}.${v_ext}"
fi
fi

View File

@ -2,22 +2,24 @@
############################################################################
# ks-oga-album (ks-tools) - Convert folder album to OGA (OGG Audio) Format #
# Date: 10-02-2021 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
############################################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="021123"
# Variables
tempFile="/tmp/ks-mp4s-folder.txt"
tempFileTest="/tmp/ks-mp4s-folder-test.txt"
formatFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ogg oga mp3 mp2 aac ac3"
formatFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ogg oga mp3 mp2 aac ac3 flac opus wav"
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-oga
# Basic parameters
acodec="libvorbis"
@ -27,112 +29,172 @@ track_init="1"
artist_init="Artist"
default_lang_audio="spa"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
if [ ${error_ffmpeg} -ne 0 ] ; then
echo ""
echo "* ks-oga-album (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ffmpeg' tool is not installed!"
echo ""
exit
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep find grep cut head tail tr cat"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-oga-album (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
cutDisplayName=$(echo ${DisplayName} | cut -c1)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c2-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c2)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c3-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c3)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c4-100)
fi
fi
fi
echo ${DisplayName}
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
cutDisplayName=$(echo ${DisplayName} | cut -c1)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c2-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c2)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c3-100)
else
cutDisplayName=$(echo ${DisplayName} | cut -c3)
if [ "${cutDisplayName}" == "-" ] ; then
DisplayName=$(echo ${DisplayName} | cut -c4-100)
fi
fi
fi
echo ${DisplayName}
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp2//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.oga//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ac3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.aac//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp2//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.oga//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ac3//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.aac//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flac//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wav//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.opus//g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Sintax: ks-oga </absolute/path/song.mp3> </path/prefix_name>
# Syntax: ks-oga </absolute/path/song.mp3> </path/prefix_name>
if [ -z "${1}" ] ; then
echo ""
echo "* ks-oga-album (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert folder album to OGA (OGG Audio) Format"
echo ""
echo "+ Config:"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo ""
echo " $ ks-oga </absolute/path/album>"
echo ""
echo " + Example: ks-oga /data/albums/matrix-soundtrack"
echo ""
exit
echo ""
echo "* ks-oga-album (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert folder album to OGA (OGG Audio) Format"
echo ""
echo "+ Config: ${configFile}"
echo ""
echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}"
echo " - Container: ${v_ext}"
echo ""
echo "+ Syntax: "
echo ""
echo " $ ks-oga-album </absolute/path/album>"
echo ""
echo " + Example: ks-oga-album /data/albums/matrix-soundtrack"
echo ""
exit
fi
# Check if folder exist
@ -154,7 +216,7 @@ echo "* ks-oga-album (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert folder album to OGA (OGG Audio) Format"
echo ""
echo -n "* Scanning ${1} " && sleep 4
echo -n "* Scanning ${1} "
echo ""
rm -rf ${tempFile} && touch ${tempFile}
for format in ${formatFiles} ; do
@ -163,7 +225,9 @@ for format in ${formatFiles} ; do
echo "null" > /dev/null
else
echo "+ Video file(s) in .${format} found!"
cd "${1}" && ls -1 *.${format} &>> ${tempFile}
cd "${1}" && ls -1 *.${format} &> /tmp/tempFile.txt
cat /tmp/tempFile.txt >> ${tempFile}
rm -rf /tmp/tempFile.txt 2> /dev/null
fail=0
fi
done
@ -175,21 +239,21 @@ echo "* Common METADATA configuration:"
echo ""
echo -n "* (Default: Album-Disc) Type name of album: " ; read album_file
if [ -z "${album_file}" ] ; then
album_title="Album-Disc"
album_title="Album-Disc"
else
album_title="${album_file}"
album_title="${album_file}"
fi
echo -n "* (Default: ${current_date}) Type the year of album: " ; read year_file
if [ -z "${year_file}" ] ; then
year_num="${current_date}"
year_num="${current_date}"
else
year_num="${year_file}"
year_num="${year_file}"
fi
echo -n "* (Default: Pop) Type the genre of album: " ; read genre_file
if [ -z "${genre_file}" ] ; then
genre_file="Pop"
genre_file="Pop"
else
genre_file="${genre_file}"
genre_file="${genre_file}"
fi
# Init the conversion files
@ -201,9 +265,9 @@ if [ ${num_files} -eq 0 ] ; then
echo ""
exit
else
echo ""
echo "* List of files:"
echo ""
echo ""
echo "* List of files:"
echo ""
while [ ${convert_files} -le ${num_files} ] ; do
show_file=$(cat ${tempFile} | head -${convert_files} | tail -1)
echo " + ${show_file}"
@ -224,71 +288,80 @@ else
fname=$(echo "${show_file}" | cut -d "." -f 1)
name_title_default=$(removeExtension "${show_file}")
name_title_default=$(showFileWithSpace "${name_title_default}")
echo ""
echo "* METADATA for '${show_file}'"
echo ""
echo " - Album: ${album_title}"
echo " - Year: ${year_num}"
echo " - Genre: ${genre_file}"
echo ""
echo "* Information of '${show_file}':"
echo ""
echo "+ Audio Tracks:"
echo ""
ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
# Check the audio track by default
audio_default=$(ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${track_init}) Type number of track: " ; read track_file
if [ -z "${track_file}" ] ; then
track_num="${track_init}"
else
track_num="${track_file}"
fi
echo -n "* (Default: ${artist_init}) Type name of artist: " ; read artist_file
if [ -z "${artist_file}" ] ; then
artist_title="${artist_init}"
else
artist_title="${artist_file}"
artist_init="${artist_file}"
fi
ffmpeg -i "${show_file}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "to-oga/${fname}.${v_ext}"
# Increment variables
convert_files=$(expr ${convert_files} + 1)
track_init=$(expr ${track_num} + 1)
echo ""
echo "* METADATA for '${show_file}'"
echo ""
echo " - Album: ${album_title}"
echo " - Year: ${year_num}"
echo " - Genre: ${genre_file}"
echo ""
echo "* Information of '${show_file}':"
echo ""
echo "+ Audio Tracks:"
echo ""
ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
# Check the audio track by default
audio_default=$(ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(ffmpeg -i "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
# Ask for audio
echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track
if [ -z "${audio_track}" ] ; then
audio_track="${audio_default}"
else
audio_track="${audio_track}"
fi
echo -n "* (Default: ${name_title_default}) Type name of title: " ; read name_title
if [ -z "${name_title}" ] ; then
name_title="${name_title_default}"
else
name_title="${name_title}"
fi
echo -n "* (Default: ${track_init}) Type number of track: " ; read track_file
if [ -z "${track_file}" ] ; then
track_num="${track_init}"
else
track_num="${track_file}"
fi
echo -n "* (Default: ${artist_init}) Type name of artist: " ; read artist_file
if [ -z "${artist_file}" ] ; then
artist_title="${artist_init}"
else
artist_title="${artist_file}"
artist_init="${artist_file}"
fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${show_file}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
ffmpeg -i "${show_file}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "to-oga/${fname}.${v_ext}"
# Increment variables
convert_files=$(expr ${convert_files} + 1)
track_init=$(expr ${track_num} + 1)
done
fi
fi

1261
src/ks-upa

File diff suppressed because it is too large Load Diff

1306
src/ks-upf

File diff suppressed because it is too large Load Diff

1206
src/ks-upr

File diff suppressed because it is too large Load Diff

1261
src/ks-upv

File diff suppressed because it is too large Load Diff

View File

@ -2,12 +2,12 @@
###############################################################
# ks-avi (ks-tools) - Convert video to VOB DVD Format #
# Date: 10-02-2021 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
###############################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="021123"
# Basic parameters
rel_size="720x480"
@ -18,25 +18,52 @@ b_acodec="192k"
default_lang_audio="spa"
v_ext="vob"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
if [ ${error_ffmpeg} -ne 0 ] ; then
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin $(brew --prefix 2> /dev/null)/bin"
dependencies="ffmpeg grep grep cut head tail tr"
dependencies_found=""
dependencies_not_found=""
for checkPath in ${path_check} ; do
for checkDependencies in ${dependencies} ; do
if [ -f ${checkPath}/${checkDependencies} ] ; then
dependencies_found="${dependencies_found} ${checkDependencies}"
fi
done
done
for notFound in ${dependencies} ; do
check_found_one=$(echo ${dependencies_found} | grep " ${notFound}")
check_found_two=$(echo ${dependencies_found} | grep "${notFound} ")
if_not_found="${check_found_one}${check_found_two}"
if [ -z "${if_not_found}" ] ; then
dependencies_not_found="${dependencies_not_found} ${notFound}"
fi
done
# Show if all tools are installed
if [ -z "${dependencies_not_found}" ] ; then
echo > /dev/null
else
echo ""
echo "* ks-vob (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ffmpeg' tool is not installed!"
echo "* Some required tools are not installed:${dependencies_not_found}"
echo "* The process has been stopped"
echo ""
exit
fi
# Sintax: ks-vob -f </absolute/path/video.mp4> </path/prefix_name>
# Syntax: ks-vob -f </absolute/path/video.mp4> </path/prefix_name>
if [ -z "${1}" ] ; then
echo ""
echo "* ks-vob (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient VOB"
echo ""
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
@ -48,7 +75,7 @@ if [ -z "${1}" ] ; then
echo " - Split: 30 minutes"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo "+ Syntax: "
echo ""
echo " $ ks-vob </absolute/path/video.mkv> </path/prefix_name>"
echo
@ -76,7 +103,7 @@ if [ -z "${2}" ] ; then
echo "* ks-vob (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Convert video file(s) to compact and efficient VOB"
echo ""
echo ""
echo "+ Config:"
echo ""
echo " - Resolution: ${rel_size}"
@ -88,7 +115,7 @@ if [ -z "${2}" ] ; then
echo " - Split: 30 minutes"
echo " - Container: ${v_ext}"
echo ""
echo "+ Sintax: "
echo "+ Syntax: "
echo ""
echo " $ ks-vob </absolute/path/video.mkv> </path/prefix_name>"
echo

377
wrapper/ks-av1-wrapper Executable file
View File

@ -0,0 +1,377 @@
#!/bin/bash
###############################################################
# ks-av1-wrapper (ks-tools) - Wrapper for ks-av1 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@duck.com #
###############################################################
VERSION="8.5"
M_DATE="021123"
# Conversion parameters
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
rel_size="1280x534"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-av1
source ${configFile}
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
if [ ${error_ffmpeg} -ne 0 ] ; then
echo ""
echo "* ks-av1-wrapper (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ffmpeg' tool is not installed!"
echo ""
exit
fi
# Check if ks-av1 is installed
wrap_test=$(ks-av1 &> /dev/null)
error_wrap=$?
if [ ${error_wrap} -ne 0 ] ; then
echo ""
echo "* ks-av1-wrapper (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ks-av1' tool is not installed!"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Function to remove extension from file
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv/g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Function to show files with spaces.
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Show info tracks of input video video file.
# Syntax: showInfo <video_file>
function showInfo() {
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Video Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo "+ Subtitle Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d "," -f 1
echo ""
exit
}
# Show the video track default
# Syntax: showVideoDefault <video_file>
function showVideoDefault() {
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
video_default_patch=$(echo ${video_default} | cut -c4)
if [ "${video_default_patch}" == ":" ] ; then
video_default=$(echo ${video_default} | cut -c1-3)
else
video_default="${video_default}"
fi
fi
echo "${video_default}"
}
# Show the audio track default
# Syntax: showAudioDefault <video_file>
function showAudioDefault() {
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
echo "${audio_default}"
}
# Show the subtitle track default
# Syntax: showSubtitleDefault <video_file>
function showSubtitleDefault() {
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
echo "${subtitle_default}"
}
# Show default resolution
# Syntax: showResolutionDefault
function showResolutionDefault() {
echo "${rel_size}"
}
# Show default year (METADATA)
# Syntax: showResolutionDefault
function showYearDefault() {
current_date=$(date +%Y)
echo "${current_date}"
}
# Show the name title default (MEDATA)
# Syntax: showNameDefault <video_file>
function showNameDefault() {
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
echo "${name_title_default}"
}
# Show the genre default (MEDATA)
# Syntax: showGenreDefault
function showGenreDefault() {
echo "Unknown"
}
# Show help
function showHelp() {
echo ""
echo "* ks-av1-wrapper (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Wrapper for ks-av1 to create graphical interfaces"
echo ""
echo "+ Syntax:"
echo ""
echo " * TRACKS/CONFIG DETECT:"
echo ""
echo " $ ks-av1-wrapper --show-info <video_file>"
echo " $ ks-av1-wrapper --show-video-default <video_file>"
echo " $ ks-av1-wrapper --show-audio-default <video_file>"
echo " $ ks-av1-wrapper --show-subtitle-default <video_file>"
echo " $ ks-av1-wrapper --show-resolution-default"
echo ""
echo " * METADATA DETECT:"
echo ""
echo " $ ks-av1-wrapper --show-name-title-default <video_file>"
echo " $ ks-av1-wrapper --show-year-default"
echo " $ ks-av1-wrapper --show-genre-default"
echo ""
echo " * CONVERT:"
echo ""
echo " $ ks-av1-wrapper --conv </path/video_file> </path/output_prefix> <video-track> <audio-track> <resolution> \"<name-title>\" <year> \"<genre>\" [patch]"
echo " $ ks-av1-wrapper --conv-with-sub </path/video_file> </path/output_prefix> <video-track> <audio-track> <subs-track> <resolution> \"<name-title>\" <year> \"<genre>\" [patch]"
echo ""
echo " * CONVERT WITH DEFAULT DETECTION (NOT RECOMMENDED):"
echo ""
echo " $ ks-av1-wrapper --conv </path/video_file> </path/output_prefix>"
echo " $ ks-av1-wrapper --conv-with-sub </path/video_file> </path/output_prefix>"
echo ""
echo "* EXAMPLES:"
echo ""
echo " $ ks-av1-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 1280x534 \"My video\" 2018 \"Comedy\""
echo " $ ks-av1-wrapper --conv-with-sub /tmp/video.mkv /tmp/output 0:0 0:1 0:3 1280x720 \"My video\" 2018 \"Comedy\""
echo " $ ks-av1-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 1280x720 \"My video\" 2018 \"Comedy\" patch"
echo ""
echo "* Notes:"
echo ""
echo " + The option 'patch' apply the '-thread_queue_size 2048' patch to ffmpeg."
echo " + If you specify a path or file with spaces, you must use quotes."
echo ""
exit
}
# Run the parameters
if [ -z "${1}" ] ; then
showHelp
elif [ "${1}" == "--show-info" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
showInfo "${2}"
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--show-video-default" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
showVideoDefault "${2}"
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--show-audio-default" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
showAudioDefault "${2}"
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--show-subtitle-default" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
showSubtitleDefault "${2}"
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--show-resolution-default" ] ; then
showResolutionDefault
elif [ "${1}" == "--show-name-title-default" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
showNameDefault "${2}"
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--show-year-default" ] ; then
showYearDefault
elif [ "${1}" == "--show-genre-default" ] ; then
showGenreDefault
elif [ "${1}" == "--conv" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
if [ "${10}" == "patch" ] ; then
echo -e "${4}\n${5}\nn\n${6}\ny\n${7}\n${8}\n${9}\ny\n" | ks-av1 "${2}" "${3}"
else
echo -e "${4}\n${5}\nn\n${6}\nn\n${7}\n${8}\n${9}\ny\n" | ks-av1 "${2}" "${3}"
fi
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--conv-with-sub" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
if [ "${11}" == "patch" ] ; then
echo -e "${4}\n${5}\ny\n${6}\n${7}\ny\n${8}\n${9}\n${10}\ny\n" | ks-av1 "${2}" "${3}"
else
echo -e "${4}\n${5}\ny\n${6}\n${7}\nn\n${8}\n${9}\n${10}\ny\n" | ks-av1 "${2}" "${3}"
fi
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
else
showHelp
fi

377
wrapper/ks-av1s-wrapper Executable file
View File

@ -0,0 +1,377 @@
#!/bin/bash
###############################################################
# ks-av1s-wrapper (ks-tools) - Wrapper for ks-av1s #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@duck.com #
###############################################################
VERSION="8.5"
M_DATE="021123"
# Conversion parameters
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
rel_size="720x404"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-av1s
source ${configFile}
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
if [ ${error_ffmpeg} -ne 0 ] ; then
echo ""
echo "* ks-av1s-wrapper (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ffmpeg' tool is not installed!"
echo ""
exit
fi
# Check if ks-av1s is installed
wrap_test=$(ks-av1s &> /dev/null)
error_wrap=$?
if [ ${error_wrap} -ne 0 ] ; then
echo ""
echo "* ks-av1s-wrapper (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "+ The 'ks-av1s' tool is not installed!"
echo ""
exit
fi
# Funcion to show the name of file/folder from full path
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Function to remove extension from file
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null
echo "${wordToConvert}" > ${ksToolsSedFile}
# Remove extensions
sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null
sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null
sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null
sed -i 's/.flv/g' "${ksToolsSedFile}" &> /dev/null
# Show file without extension
wordToConvert=$(cat ${ksToolsSedFile})
echo ${wordToConvert}
}
# Function to show files with spaces.
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Show info tracks of input video video file.
# Syntax: showInfo <video_file>
function showInfo() {
echo ""
echo "* Information of ${1}:"
echo ""
echo "+ Video Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1
echo ""
echo "+ Audio Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1
echo ""
echo "+ Subtitle Tracks:"
${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d "," -f 1
echo ""
exit
}
# Show the video track default
# Syntax: showVideoDefault <video_file>
function showVideoDefault() {
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
video_default_patch=$(echo ${video_default} | cut -c4)
if [ "${video_default_patch}" == ":" ] ; then
video_default=$(echo ${video_default} | cut -c1-3)
else
video_default="${video_default}"
fi
fi
echo "${video_default}"
}
# Show the audio track default
# Syntax: showAudioDefault <video_file>
function showAudioDefault() {
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
else
audio_default_patch=$(echo ${audio_default} | cut -c4)
if [ "${audio_default_patch}" == ":" ] ; then
audio_default=$(echo ${audio_default} | cut -c1-3)
else
audio_default="${audio_default}"
fi
fi
echo "${audio_default}"
}
# Show the subtitle track default
# Syntax: showSubtitleDefault <video_file>
function showSubtitleDefault() {
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
else
subtitle_default_patch=$(echo ${subtitle_default} | cut -c4)
if [ "${subtitle_default_patch}" == ":" ] ; then
subtitle_default=$(echo ${subtitle_default} | cut -c1-3)
else
subtitle_default="${subtitle_default}"
fi
fi
echo "${subtitle_default}"
}
# Show default resolution
# Syntax: showResolutionDefault
function showResolutionDefault() {
echo "${rel_size}"
}
# Show default year (METADATA)
# Syntax: showResolutionDefault
function showYearDefault() {
current_date=$(date +%Y)
echo "${current_date}"
}
# Show the name title default (MEDATA)
# Syntax: showNameDefault <video_file>
function showNameDefault() {
# Prepare name title by default
FullPath="${1}"
name_title_default=$(extractFolderOrFile "${FullPath}")
name_title_default=$(removeExtension "${name_title_default}")
name_title_default=$(showFileWithSpace "${name_title_default}")
echo "${name_title_default}"
}
# Show the genre default (MEDATA)
# Syntax: showGenreDefault
function showGenreDefault() {
echo "Unknown"
}
# Show help
function showHelp() {
echo ""
echo "* ks-av1s-wrapper (ks-tools) v${VERSION} (${M_DATE})"
echo ""
echo "- Wrapper for ks-av1s to create graphical interfaces"
echo ""
echo "+ Syntax:"
echo ""
echo " * TRACKS/CONFIG DETECT:"
echo ""
echo " $ ks-av1s-wrapper --show-info <video_file>"
echo " $ ks-av1s-wrapper --show-video-default <video_file>"
echo " $ ks-av1s-wrapper --show-audio-default <video_file>"
echo " $ ks-av1s-wrapper --show-subtitle-default <video_file>"
echo " $ ks-av1s-wrapper --show-resolution-default"
echo ""
echo " * METADATA DETECT:"
echo ""
echo " $ ks-av1s-wrapper --show-name-title-default <video_file>"
echo " $ ks-av1s-wrapper --show-year-default"
echo " $ ks-av1s-wrapper --show-genre-default"
echo ""
echo " * CONVERT:"
echo ""
echo " $ ks-av1s-wrapper --conv </path/video_file> </path/output_prefix> <video-track> <audio-track> <resolution> \"<name-title>\" <year> \"<genre>\" [patch]"
echo " $ ks-av1s-wrapper --conv-with-sub </path/video_file> </path/output_prefix> <video-track> <audio-track> <subs-track> <resolution> \"<name-title>\" <year> \"<genre>\" [patch]"
echo ""
echo " * CONVERT WITH DEFAULT DETECTION (NOT RECOMMENDED):"
echo ""
echo " $ ks-av1s-wrapper --conv </path/video_file> </path/output_prefix>"
echo " $ ks-av1s-wrapper --conv-with-sub </path/video_file> </path/output_prefix>"
echo ""
echo "* EXAMPLES:"
echo ""
echo " $ ks-av1s-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 720x404 \"My video\" 2018 \"Comedy\""
echo " $ ks-av1s-wrapper --conv-with-sub /tmp/video.mkv /tmp/output 0:0 0:1 0:3 720x404 \"My video\" 2018 \"Comedy\""
echo " $ ks-av1s-wrapper --conv /tmp/video.mkv /tmp/output 0:0 0:1 720x480 \"My video\" 2018 \"Comedy\" patch"
echo ""
echo "* Notes:"
echo ""
echo " + The option 'patch' apply the '-thread_queue_size 2048' patch to ffmpeg."
echo " + If you specify a path or file with spaces, you must use quotes."
echo ""
exit
}
# Run the parameters
if [ -z "${1}" ] ; then
showHelp
elif [ "${1}" == "--show-info" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
showInfo "${2}"
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--show-video-default" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
showVideoDefault "${2}"
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--show-audio-default" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
showAudioDefault "${2}"
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--show-subtitle-default" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
showSubtitleDefault "${2}"
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--show-resolution-default" ] ; then
showResolutionDefault
elif [ "${1}" == "--show-name-title-default" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
showNameDefault "${2}"
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--show-year-default" ] ; then
showYearDefault
elif [ "${1}" == "--show-genre-default" ] ; then
showGenreDefault
elif [ "${1}" == "--conv" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
if [ "${10}" == "patch" ] ; then
echo -e "${4}\n${5}\nn\n${6}\ny\n${7}\n${8}\n${9}\ny\n" | ks-av1s "${2}" "${3}"
else
echo -e "${4}\n${5}\nn\n${6}\nn\n${7}\n${8}\n${9}\ny\n" | ks-av1s "${2}" "${3}"
fi
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
elif [ "${1}" == "--conv-with-sub" ] ; then
# Check if file exist
if [ -f "${2}" ] ; then
if [ "${11}" == "patch" ] ; then
echo -e "${4}\n${5}\ny\n${6}\n${7}\ny\n${8}\n${9}\n${10}\ny\n" | ks-av1s "${2}" "${3}"
else
echo -e "${4}\n${5}\ny\n${6}\n${7}\nn\n${8}\n${9}\n${10}\ny\n" | ks-av1s "${2}" "${3}"
fi
else
echo ""
echo "* The file '${2}' does not exist!'"
echo ""
exit
fi
else
showHelp
fi

View File

@ -2,24 +2,32 @@
###############################################################
# ks-avi-wrapper (ks-tools) - Wrapper for ks-avi #
# Date: 10-02-2021 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
###############################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="021123"
# Conversion parameters
ks_mp4_to_wrap="/usr/bin/ks-avi"
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
rel_size="720x480"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-avi
source ${configFile}
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
@ -33,9 +41,9 @@ if [ ${error_ffmpeg} -ne 0 ] ; then
fi
# Check if ks-avi is installed
if [ -f ${ks_mp4_to_wrap} ] ; then
echo "ks-avi detected" > /dev/null
else
wrap_test=$(ks-avi &> /dev/null)
error_wrap=$?
if [ ${error_wrap} -ne 0 ] ; then
echo ""
echo "* ks-avi-wrapper (ks-tools) v${VERSION} (${M_DATE})"
echo ""
@ -45,7 +53,7 @@ else
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
@ -65,7 +73,7 @@ function extractFolderOrFile() {
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
@ -89,17 +97,17 @@ function removeExtension() {
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Show info tracks of input video video file.
# Sintax: showInfo <video_file>
# Syntax: showInfo <video_file>
function showInfo() {
echo ""
echo "* Information of ${1}:"
@ -117,10 +125,10 @@ function showInfo() {
}
# Show the video track default
# Sintax: showVideoDefault <video_file>
# Syntax: showVideoDefault <video_file>
function showVideoDefault() {
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
@ -135,12 +143,12 @@ function showVideoDefault() {
}
# Show the audio track default
# Sintax: showAudioDefault <video_file>
# Syntax: showAudioDefault <video_file>
function showAudioDefault() {
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
@ -163,14 +171,14 @@ function showAudioDefault() {
}
# Show the subtitle track default
# Sintax: showSubtitleDefault <video_file>
# Syntax: showSubtitleDefault <video_file>
function showSubtitleDefault() {
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
@ -201,20 +209,20 @@ function showSubtitleDefault() {
}
# Show default resolution
# Sintax: showResolutionDefault
# Syntax: showResolutionDefault
function showResolutionDefault() {
echo "${rel_size}"
}
# Show default year (METADATA)
# Sintax: showResolutionDefault
# Syntax: showResolutionDefault
function showYearDefault() {
current_date=$(date +%Y)
echo "${current_date}"
}
# Show the name title default (MEDATA)
# Sintax: showNameDefault <video_file>
# Syntax: showNameDefault <video_file>
function showNameDefault() {
# Prepare name title by default
FullPath="${1}"
@ -225,7 +233,7 @@ function showNameDefault() {
}
# Show the genre default (MEDATA)
# Sintax: showGenreDefault
# Syntax: showGenreDefault
function showGenreDefault() {
echo "Unknown"
}
@ -237,7 +245,7 @@ function showHelp() {
echo ""
echo "- Wrapper for ks-avi to create graphical interfaces"
echo ""
echo "+ Sintax:"
echo "+ Syntax:"
echo ""
echo " * TRACKS/CONFIG DETECT:"
echo ""

View File

@ -2,24 +2,32 @@
###############################################################
# ks-mp4-wrapper (ks-tools) - Wrapper for ks-mp4 #
# Date: 10-01-2021 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
###############################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="021123"
# Conversion parameters
ks_mp4_to_wrap="/usr/bin/ks-mp4"
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
rel_size="1280x534"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4
source ${configFile}
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
@ -33,9 +41,9 @@ if [ ${error_ffmpeg} -ne 0 ] ; then
fi
# Check if ks-mp4 is installed
if [ -f ${ks_mp4_to_wrap} ] ; then
echo "ks-mp4 detected" > /dev/null
else
wrap_test=$(ks-mp4 &> /dev/null)
error_wrap=$?
if [ ${error_wrap} -ne 0 ] ; then
echo ""
echo "* ks-mp4-wrapper (ks-tools) v${VERSION} (${M_DATE})"
echo ""
@ -45,7 +53,7 @@ else
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
@ -65,7 +73,7 @@ function extractFolderOrFile() {
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
@ -89,17 +97,17 @@ function removeExtension() {
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Show info tracks of input video video file.
# Sintax: showInfo <video_file>
# Syntax: showInfo <video_file>
function showInfo() {
echo ""
echo "* Information of ${1}:"
@ -117,10 +125,10 @@ function showInfo() {
}
# Show the video track default
# Sintax: showVideoDefault <video_file>
# Syntax: showVideoDefault <video_file>
function showVideoDefault() {
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
@ -135,12 +143,12 @@ function showVideoDefault() {
}
# Show the audio track default
# Sintax: showAudioDefault <video_file>
# Syntax: showAudioDefault <video_file>
function showAudioDefault() {
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
@ -163,14 +171,14 @@ function showAudioDefault() {
}
# Show the subtitle track default
# Sintax: showSubtitleDefault <video_file>
# Syntax: showSubtitleDefault <video_file>
function showSubtitleDefault() {
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
@ -201,20 +209,20 @@ function showSubtitleDefault() {
}
# Show default resolution
# Sintax: showResolutionDefault
# Syntax: showResolutionDefault
function showResolutionDefault() {
echo "${rel_size}"
}
# Show default year (METADATA)
# Sintax: showResolutionDefault
# Syntax: showResolutionDefault
function showYearDefault() {
current_date=$(date +%Y)
echo "${current_date}"
}
# Show the name title default (MEDATA)
# Sintax: showNameDefault <video_file>
# Syntax: showNameDefault <video_file>
function showNameDefault() {
# Prepare name title by default
FullPath="${1}"
@ -225,7 +233,7 @@ function showNameDefault() {
}
# Show the genre default (MEDATA)
# Sintax: showGenreDefault
# Syntax: showGenreDefault
function showGenreDefault() {
echo "Unknown"
}
@ -237,7 +245,7 @@ function showHelp() {
echo ""
echo "- Wrapper for ks-mp4 to create graphical interfaces"
echo ""
echo "+ Sintax:"
echo "+ Syntax:"
echo ""
echo " * TRACKS/CONFIG DETECT:"
echo ""

View File

@ -2,24 +2,32 @@
###############################################################
# ks-mp4k-wrapper (ks-tools) - Wrapper for ks-mp4k #
# Date: 10-02-2021 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
###############################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="021123"
# Conversion parameters
ks_mp4_to_wrap="/usr/bin/ks-mp4k"
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
rel_size="3840x2160"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4k
source ${configFile}
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
@ -33,9 +41,9 @@ if [ ${error_ffmpeg} -ne 0 ] ; then
fi
# Check if ks-mp4k is installed
if [ -f ${ks_mp4_to_wrap} ] ; then
echo "ks-mp4k detected" > /dev/null
else
wrap_test=$(ks-mp4k &> /dev/null)
error_wrap=$?
if [ ${error_wrap} -ne 0 ] ; then
echo ""
echo "* ks-mp4k-wrapper (ks-tools) v${VERSION} (${M_DATE})"
echo ""
@ -45,7 +53,7 @@ else
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
@ -65,7 +73,7 @@ function extractFolderOrFile() {
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
@ -89,17 +97,17 @@ function removeExtension() {
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Show info tracks of input video video file.
# Sintax: showInfo <video_file>
# Syntax: showInfo <video_file>
function showInfo() {
echo ""
echo "* Information of ${1}:"
@ -117,10 +125,10 @@ function showInfo() {
}
# Show the video track default
# Sintax: showVideoDefault <video_file>
# Syntax: showVideoDefault <video_file>
function showVideoDefault() {
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
@ -135,12 +143,12 @@ function showVideoDefault() {
}
# Show the audio track default
# Sintax: showAudioDefault <video_file>
# Syntax: showAudioDefault <video_file>
function showAudioDefault() {
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
@ -163,14 +171,14 @@ function showAudioDefault() {
}
# Show the subtitle track default
# Sintax: showSubtitleDefault <video_file>
# Syntax: showSubtitleDefault <video_file>
function showSubtitleDefault() {
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
@ -201,20 +209,20 @@ function showSubtitleDefault() {
}
# Show default resolution
# Sintax: showResolutionDefault
# Syntax: showResolutionDefault
function showResolutionDefault() {
echo "${rel_size}"
}
# Show default year (METADATA)
# Sintax: showResolutionDefault
# Syntax: showResolutionDefault
function showYearDefault() {
current_date=$(date +%Y)
echo "${current_date}"
}
# Show the name title default (MEDATA)
# Sintax: showNameDefault <video_file>
# Syntax: showNameDefault <video_file>
function showNameDefault() {
# Prepare name title by default
FullPath="${1}"
@ -225,7 +233,7 @@ function showNameDefault() {
}
# Show the genre default (MEDATA)
# Sintax: showGenreDefault
# Syntax: showGenreDefault
function showGenreDefault() {
echo "Unknown"
}
@ -237,7 +245,7 @@ function showHelp() {
echo ""
echo "- Wrapper for ks-mp4k to create graphical interfaces"
echo ""
echo "+ Sintax:"
echo "+ Syntax:"
echo ""
echo " * TRACKS/CONFIG DETECT:"
echo ""

View File

@ -2,24 +2,32 @@
###############################################################
# ks-mp4s-wrapper (ks-tools) - Wrapper for ks-mp4s #
# Date: 10-02-2021 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
###############################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="021123"
# Conversion parameters
ks_mp4_to_wrap="/usr/bin/ks-mp4s"
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
rel_size="720x404"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4s
source ${configFile}
# Global parameters
dirTemp="/tmp"
listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
@ -33,9 +41,9 @@ if [ ${error_ffmpeg} -ne 0 ] ; then
fi
# Check if ks-mp4s is installed
if [ -f ${ks_mp4_to_wrap} ] ; then
echo "ks-mp4s detected" > /dev/null
else
wrap_test=$(ks-mp4s &> /dev/null)
error_wrap=$?
if [ ${error_wrap} -ne 0 ] ; then
echo ""
echo "* ks-mp4s-wrapper (ks-tools) v${VERSION} (${M_DATE})"
echo ""
@ -45,7 +53,7 @@ else
fi
# Funcion to show the name of file/folder from full path
# Sintax: extractFolderOrFile <full/path/file.txt>
# Syntax: extractFolderOrFile <full/path/file.txt>
function extractFolderOrFile() {
pathToExtract="${1}/"
findFolder=0
@ -65,7 +73,7 @@ function extractFolderOrFile() {
}
# Function to remove extension from file
# Sintax: removeExtension "<text>"
# Syntax: removeExtension "<text>"
function removeExtension() {
wordToConvert=${1}
ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt"
@ -89,17 +97,17 @@ function removeExtension() {
}
# Function to show files with spaces.
# Sintax: showFileWithSpace <file number>
# Syntax: showFileWithSpace <file number>
function showFileWithSpace() {
echo "${1}" > ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp
sed -i 's/_/ /g' ${dirTemp}/name.tmp 2> /dev/null
DisplayName=$(cat ${dirTemp}/name.tmp)
rm -rf ${dirTemp}/name.tmp
echo ${DisplayName}
}
# Show info tracks of input video video file.
# Sintax: showInfo <video_file>
# Syntax: showInfo <video_file>
function showInfo() {
echo ""
echo "* Information of ${1}:"
@ -117,10 +125,10 @@ function showInfo() {
}
# Show the video track default
# Sintax: showVideoDefault <video_file>
# Syntax: showVideoDefault <video_file>
function showVideoDefault() {
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
@ -135,12 +143,12 @@ function showVideoDefault() {
}
# Show the audio track default
# Sintax: showAudioDefault <video_file>
# Syntax: showAudioDefault <video_file>
function showAudioDefault() {
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
@ -163,14 +171,14 @@ function showAudioDefault() {
}
# Show the subtitle track default
# Sintax: showSubtitleDefault <video_file>
# Syntax: showSubtitleDefault <video_file>
function showSubtitleDefault() {
# Check the subtitle track by default
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | grep "(forced)" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | grep "(${default_lang_subt})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
subtitle_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Subtitle:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${subtitle_default}" ] ; then
subtitle_default="0:3"
else
@ -201,20 +209,20 @@ function showSubtitleDefault() {
}
# Show default resolution
# Sintax: showResolutionDefault
# Syntax: showResolutionDefault
function showResolutionDefault() {
echo "${rel_size}"
}
# Show default year (METADATA)
# Sintax: showResolutionDefault
# Syntax: showResolutionDefault
function showYearDefault() {
current_date=$(date +%Y)
echo "${current_date}"
}
# Show the name title default (MEDATA)
# Sintax: showNameDefault <video_file>
# Syntax: showNameDefault <video_file>
function showNameDefault() {
# Prepare name title by default
FullPath="${1}"
@ -225,7 +233,7 @@ function showNameDefault() {
}
# Show the genre default (MEDATA)
# Sintax: showGenreDefault
# Syntax: showGenreDefault
function showGenreDefault() {
echo "Unknown"
}
@ -237,7 +245,7 @@ function showHelp() {
echo ""
echo "- Wrapper for ks-mp4s to create graphical interfaces"
echo ""
echo "+ Sintax:"
echo "+ Syntax:"
echo ""
echo " * TRACKS/CONFIG DETECT:"
echo ""

View File

@ -2,19 +2,24 @@
###############################################################
# ks-vob-wrapper (ks-tools) - Wrapper for ks-vob #
# Date: 10-02-2021 #
# Date: 02-11-2023 #
# Author: q3aql #
# Contact: q3aql@protonmail.ch #
# Contact: q3aql@duck.com #
###############################################################
VERSION="6.6"
M_DATE="100221"
VERSION="8.5"
M_DATE="021123"
# Conversion parameters
ks_mp4_to_wrap="/usr/bin/ks-vob"
p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999"
rel_size="720x480"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
source "/usr/bin/cygwin-alias.sh"
fi
# Check if ffmpeg is installed
ffmpeg_test=$(ffmpeg --help 2>&1)
error_ffmpeg=$?
@ -28,9 +33,9 @@ if [ ${error_ffmpeg} -ne 0 ] ; then
fi
# Check if ks-vob is installed
if [ -f ${ks_mp4_to_wrap} ] ; then
echo "ks-vob detected" > /dev/null
else
wrap_test=$(ks-vob &> /dev/null)
error_wrap=$?
if [ ${error_wrap} -ne 0 ] ; then
echo ""
echo "* ks-vob-wrapper (ks-tools) v${VERSION} (${M_DATE})"
echo ""
@ -40,7 +45,7 @@ else
fi
# Show info tracks of input video video file.
# Sintax: showInfo <video_file>
# Syntax: showInfo <video_file>
function showInfo() {
echo ""
echo "* Information of ${1}:"
@ -55,10 +60,10 @@ function showInfo() {
}
# Show the video track default
# Sintax: showVideoDefault <video_file>
# Syntax: showVideoDefault <video_file>
function showVideoDefault() {
# Check de video track by default
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
video_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${video_default}" ] ; then
video_default="0:0"
else
@ -73,12 +78,12 @@ function showVideoDefault() {
}
# Show the audio track default
# Sintax: showAudioDefault <video_file>
# Syntax: showAudioDefault <video_file>
function showAudioDefault() {
# Check the audio track by default
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | head -1)
audio_default=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1)
if [ -z "${audio_default}" ] ; then
audio_default="0:1"
else
@ -101,7 +106,7 @@ function showAudioDefault() {
}
# Show default resolution
# Sintax: showResolutionDefault
# Syntax: showResolutionDefault
function showResolutionDefault() {
echo "${rel_size}"
}
@ -113,7 +118,7 @@ function showHelp() {
echo ""
echo "- Wrapper for ks-vob to create graphical interfaces"
echo ""
echo "+ Sintax:"
echo "+ Syntax:"
echo ""
echo " * TRACKS/CONFIG DETECT:"
echo ""