Advertisement
aweserver

meltsub_720p

Dec 27th, 2024 (edited)
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.90 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, time
  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.     try:
  12.       duration = fields['duration']
  13.       time_obj = time.gmtime(int(float(fields['duration'])))
  14.       resultant_time = str(time.strftime("%H:%M:%S",time_obj))
  15.       return resultant_time
  16.     except:
  17.       duration = fields['tags']['DURATION']
  18.       return duration[:8]
  19.  
  20. input_file_path = "/content/vid_source.mkv"
  21. output_file_path = "output_sub_bawah.srt"
  22. language_code = "id"
  23. use_gpu = True
  24. start_time = "0:0"
  25. end_time = str(get_vid_duration(input_file_path))
  26. confidence_threshold = 75
  27. similarity_threshold = 80
  28. frames_to_skip = 0
  29. crop_x = 50
  30. crop_y = 570
  31. crop_width = 1180
  32. crop_height = 150
  33.  
  34. 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)
  35.  
  36.  
  37. input_file_path = "/content/vid_source.mkv"
  38. output_file_path = "output_sub_atas.srt"
  39. language_code = "id"
  40. use_gpu = True
  41. start_time = "0:0"
  42. end_time = str(get_vid_duration(input_file_path))
  43. confidence_threshold = 75
  44. similarity_threshold = 80
  45. frames_to_skip = 0
  46. crop_x = 0
  47. crop_y = 0
  48. crop_width = 1180
  49. crop_height = 150
  50.  
  51. 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