Guest User

Untitled

a guest
Feb 3rd, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. def remux_file(self, track_info: dict, input_file: str, video_track_ids: list, audio_track_ids: list, subtitle_track_ids: list, converted_files: list):
  2. output_file = f"'{os.path.splitext(input_file)[0]}.optimised{os.path.splitext(input_file)[1]}'"
  3.  
  4. command = [self.mkvmerge_path, "-o", output_file, "--no-subtitles"]
  5.  
  6. if video_track_ids:
  7. command.extend(["--video-tracks", ','.join(map(str, video_track_ids))])
  8.  
  9. if audio_track_ids:
  10. command.extend(["--audio-tracks", ','.join(map(str, audio_track_ids))])
  11.  
  12. for file_path in converted_files:
  13. track_id = Path(file_path).stem
  14. if track_id in subtitle_track_ids and os.path.splitext(file_path)[1].lower() == '.srt':
  15. track = next((track for track in track_info.get("tracks", []) if track["type"] == "subtitles" and str(track["id"]) == track_id), None)
  16. if track:
  17. command.extend([
  18. #"--set codec", "SubRip/SRT",
  19. #"--id", f"{track['properties'].get('id', '')}", #f"0:{track['properties'].get('id', '')}",
  20. #"--set codec-id", "S_TEXT/UTF8",
  21. "--language", f"0:{track['properties'].get('language', 'und')}",
  22. "--track-name", f'0:"{track["properties"].get("track_name", "")}"',
  23. "--default-track", f"0:{track['properties'].get('default_track', False)}",
  24. "--forced-track", f"0:{track['properties'].get('forced_track', False)}",
  25. f"'{file_path}'"
  26. ])
  27. else:
  28. logging.log(self.log_lvl, f"No track info found for track ID: {track_id}")
  29.  
  30. command.append(f"'{input_file}'")
  31.  
  32. logging.log(self.log_lvl, f"Executing mkvmerge command: {' '.join(command)}")
Advertisement
Add Comment
Please, Sign In to add comment