feat: add CLI argument handling and build script
- Added command-line argument parsing to accept input file path instead of hardcoded value - Added build task to compile standalone executable with deno compile - Added usage message for incorrect invocation
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 Kessinen
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# dvdsubconvert
|
||||||
|
|
||||||
|
A command-line tool built with Deno to extract, convert, and remux DVD subtitles
|
||||||
|
from MKV video files into SRT format, then combine them back into a new MKV
|
||||||
|
file.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Ensure the following tools are installed and available in your PATH:
|
||||||
|
|
||||||
|
- [MKVToolNix](https://mkvtoolnix.download/) (provides `mkvmerge` and
|
||||||
|
`mkvextract`)
|
||||||
|
- [FFmpeg](https://ffmpeg.org/)
|
||||||
|
- [vobsub2srt](https://github.com/ruediger/VobSub2SRT) (for converting VobSub
|
||||||
|
subtitles to SRT)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Clone the repository and ensure Deno is installed
|
||||||
|
([Deno installation guide](https://deno.land/manual/getting_started/installation)).
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Run the tool with a single MKV file as input:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
deno run --allow-run --allow-write --allow-read src/main.ts input.mkv
|
||||||
|
```
|
||||||
|
|
||||||
|
The tool will:
|
||||||
|
|
||||||
|
1. Analyze the MKV file for subtitle tracks.
|
||||||
|
2. Extract supported subtitle languages.
|
||||||
|
3. Convert VobSub subtitles to SRT format.
|
||||||
|
4. Remux the SRT subtitles into a new MKV file named `subit.mkv`.
|
||||||
|
|
||||||
|
Supported languages (ISO 639-1 codes):
|
||||||
|
|
||||||
|
- English (en)
|
||||||
|
- Finnish (fi)
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
- `subit.mkv`: The resulting MKV file with converted SRT subtitles.
|
||||||
|
- Temporary files (`.srt`, `.idx`, `.sub`) are cleaned up automatically.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[Include license info from LICENSE file]
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"dev": "deno run --watch --allow-run --allow-write --allow-read src/main.ts"
|
"dev": "deno run --watch --allow-run --allow-write --allow-read src/main.ts",
|
||||||
|
"build": "deno compile --allow-run --allow-write --allow-read --output dist/dvdsubconvert src/main.ts"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
"@std/assert": "jsr:@std/assert@1"
|
"@std/assert": "jsr:@std/assert@1"
|
||||||
|
|||||||
+8
-4
@@ -1,7 +1,5 @@
|
|||||||
import { videoFile } from "./types.ts";
|
import { videoFile } from "./types.ts";
|
||||||
|
|
||||||
const input = "/home/esa/Videos/tmp/3MUSKETEERS_D1_PAL/B3_t00.mkv";
|
|
||||||
|
|
||||||
// TODO: Check if mkvmerge, ffmpeg and vobsub2srt are installed.
|
// TODO: Check if mkvmerge, ffmpeg and vobsub2srt are installed.
|
||||||
|
|
||||||
const lang_codes = {
|
const lang_codes = {
|
||||||
@@ -73,7 +71,7 @@ function cleanUp(languages: Record<string, string>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main(input: string) {
|
||||||
const mkvmerge_output = subtitlesLookup(input);
|
const mkvmerge_output = subtitlesLookup(input);
|
||||||
const languages_in_file: Record<string, string> = {};
|
const languages_in_file: Record<string, string> = {};
|
||||||
for (const track of mkvmerge_output.tracks) {
|
for (const track of mkvmerge_output.tracks) {
|
||||||
@@ -139,7 +137,13 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (import.meta.main) {
|
if (import.meta.main) {
|
||||||
main().catch((e) => {
|
const args = Deno.args;
|
||||||
|
if (args.length !== 1) {
|
||||||
|
console.error("Usage: deno run main.ts <input.mkv>");
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
const input = args[0];
|
||||||
|
main(input).catch((e) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user