kaegi / alass

"Automatic Language-Agnostic Subtitle Synchronization"
GNU General Public License v3.0
994 stars 52 forks source link

Make it more pipe-friendly #17

Open Des-Nerger opened 3 years ago

Des-Nerger commented 3 years ago

I suggest changes to make it easier to use in complex pipelines:

  1. Print all messages (including progress bars) to stderr
  2. Allow to override file extension with a command-line switch. The output file probably doesn't need this override, since its format meant to be inferred from the incorrect-sub-file.

I made a quick patch just for my own needs, but I'm not very good at rust, I think you could implement it better.

Example use case

Given that I have these symlinks:

$ cd ~ && ls -l std{in.ass,out.srt} | cut -d' ' -f 10-12
stdin.ass -> /dev/stdin
stdout.srt -> /dev/stdout

Here's an example of a pipeline I use it in:

T="$GOPATH/src/github.com/Des-Nerger/sinojapsubs-tools"
go run "$T"/make-parallel-ass-subs.go \
    <(eval "$ESUBS" | go run "$T"/sync.go -o /dev/stdout ~/stdin.ass +0.75s | \
        go run "$T"/english/blank_frequent_english_idstems.go \
            $(awk '{printf$1FS} NR==384{print"";exit}' \
                ~/Documentation/hermitdave_FrequencyIDStems_en_full.txt)) \
    <(eval "$ESUBS" | alass-cli --disable-fps-guessing --split-penalty 20 ~/stdin.ass \
        <(eval "$JSUBS" | python3 ~/Documents/half_to_full_katakana.py) ~/stdout.srt | \
            go run "$T"/japanese/add-auto-furigana.go | \
                go run "$T"/rubied-srt2ass.go /dev/stdin /dev/stdout) \
    "$BASENAME".ben+furija.ass