Skip to content
duangsuse edited this page Mar 30, 2020 · 2 revisions

Welcome to the extract-subtitles wiki!

Normal usage

./extract_subtitles.py --help # program opts. like -lang eng -crop '0(x,y)[w,h]'

NOTE: all documents below will use (x,y)(w,h) as an synonym for 0(x,y)[w,h]

Extract subtitle, then convert to SRT file (you can use subtitle editor / srt tool then)

./gui_crop_select.py SomethingNew.mp4 # and select subtitle crop box

./extract_subtitles.py -crop '(617,955)(685,32)' --crop-debug -filter-code '~cvInGrayRange(it, 0xbf,0xff)' --draw-plot --use-sharp --chunk-size 1000  SomethingNew.mp4

./timeline_ops.py merge frames/timeline_SomethingNew.mp4.txt 0.25|./timeline_ops.py to-lrc 29.97 srt> mux.srt
# FPS (29.97) should be changed if timeline seems incorrect

Samples

Simple postprocess routine

./timeline_ops.py merge frames/timeline_SomethingNew.mp4.txt 0.25
./timeline_ops.py to-lrc 29.97 srt #(or no "srt") for LRC output

Use bandpass filter and inverse color (if input is white text with black background, ~it)

./extract_subtitles.py -crop '(617,955)(685,32)' --crop-debug -filter-code '~cv2.inRange(it, (0xBF,0xBF,0xBF), (0xFF,0xFF,0xFF))' SomethingNew.mp4

Use FFMpeg to crop input video (not related) (see also)

ffmpeg -filter:v "crop=in_w:in_h/20:0:in_h*97/100" -r 0.5 frames/%04d.jpg -i input.mp4

Make merged (occur time to duration) subtitles simplified to start-time

./timeline_ops.py simplify #paste output for timeline_ops.py merge

https://t.me/dsuse/13065

Clone this wiki locally