Advertisement
aweserver

meltsub_720p

Dec 27th, 2024 (edited)
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. from videocr import save_subtitles_to_file
  2. import sys
  3.  
  4. def get_vid_duration(filename):
  5.     import subprocess, json
  6.  
  7.     result = subprocess.check_output(
  8.             f'ffprobe -v quiet -show_streams -select_streams v:0 -of json "{filename}"',
  9.             shell=True).decode()
  10.     fields = json.loads(result)['streams'][0]
  11.  
  12.     duration = fields['tags']['DURATION']
  13.     fps      = eval(fields['r_frame_rate'])
  14.     return duration[:8]
  15.  
  16. input_file_path = "/content/vid_source.mkv"
  17. output_file_path = "output_sub.srt"
  18. language_code = "id"
  19. use_gpu = True
  20. start_time = "0:0"
  21. end_time = str(get_vid_duration(input_file_path))
  22. confidence_threshold = 75
  23. similarity_threshold = 80
  24. frames_to_skip = 0
  25. crop_x = 50
  26. crop_y = 570
  27. crop_width = 1180
  28. crop_height = 150
  29.  
  30. 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