From d3baab899b2ea0b73f0eafb624ab80061090bf76 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 16 Nov 2022 20:58:02 +0530 Subject: [PATCH] Add the `elsubs.sh` script --- elsubs.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 elsubs.sh diff --git a/elsubs.sh b/elsubs.sh new file mode 100755 index 0000000..b6cb764 --- /dev/null +++ b/elsubs.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +mkdir -p $1 $1/$1-FRAMES $1/$1-FRAMES/top $1/$1-FRAMES/bottom +yt-dlp -o $1/$1.video -f bestvideo[height=480] http://youtube.com/watch?v=$1 +ffmpeg -i $1/$1.video -vf fps=0.5 $1/$1-FRAMES/frame_%05d.jpeg + +for f in $1/$1-FRAMES/frame_*; do convert $f -crop 854x35+0+375 -threshold 55% -negate $1/$1-FRAMES/top/`basename $f`; done +for f in $1/$1-FRAMES/frame_*; do convert $f -crop 854x25+0+410 -threshold 55% -negate $1/$1-FRAMES/bottom/`basename $f`; done + +ls -d -1 $1/$1-FRAMES/top/*.jpeg | tesseract - - -l $2 -c page_separator="" | cat > $1/$1.top.txt +ls -d -1 $1/$1-FRAMES/bottom/*.jpeg | tesseract - - -l eng -c page_separator="" | cat > $1/$1.bottom.txt