Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from videocr import save_subtitles_to_file
- import sys
- def get_vid_duration(filename):
- import subprocess, json
- result = subprocess.check_output(
- f'ffprobe -v quiet -show_streams -select_streams v:0 -of json "{filename}"',
- shell=True).decode()
- fields = json.loads(result)['streams'][0]
- duration = fields['tags']['DURATION']
- fps = eval(fields['r_frame_rate'])
- return duration[:8]
- input_file_path = "/content/vid_source.mkv"
- output_file_path = "output_sub.srt"
- language_code = "id"
- use_gpu = True
- start_time = "0:0"
- end_time = str(get_vid_duration(input_file_path))
- confidence_threshold = 75
- similarity_threshold = 80
- frames_to_skip = 0
- crop_x = 50
- crop_y = 570
- crop_width = 1180
- crop_height = 150
- save_subtitles_to_file(input_file_path, output_file_path, lang=language_code, time_start=start_time, time_end=end_time, conf_threshold=confidence_threshold, sim_threshold=similarity_threshold, use_gpu=use_gpu, frames_to_skip=frames_to_skip, crop_x=crop_x, crop_y=crop_y, crop_width=crop_width, crop_height=crop_height)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement