Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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):
- output_file = f"'{os.path.splitext(input_file)[0]}.optimised{os.path.splitext(input_file)[1]}'"
- command = [self.mkvmerge_path, "-o", output_file, "--no-subtitles"]
- if video_track_ids:
- command.extend(["--video-tracks", ','.join(map(str, video_track_ids))])
- if audio_track_ids:
- command.extend(["--audio-tracks", ','.join(map(str, audio_track_ids))])
- for file_path in converted_files:
- track_id = Path(file_path).stem
- if track_id in subtitle_track_ids and os.path.splitext(file_path)[1].lower() == '.srt':
- track = next((track for track in track_info.get("tracks", []) if track["type"] == "subtitles" and str(track["id"]) == track_id), None)
- if track:
- command.extend([
- #"--set codec", "SubRip/SRT",
- #"--id", f"{track['properties'].get('id', '')}", #f"0:{track['properties'].get('id', '')}",
- #"--set codec-id", "S_TEXT/UTF8",
- "--language", f"0:{track['properties'].get('language', 'und')}",
- "--track-name", f'0:"{track["properties"].get("track_name", "")}"',
- "--default-track", f"0:{track['properties'].get('default_track', False)}",
- "--forced-track", f"0:{track['properties'].get('forced_track', False)}",
- f"'{file_path}'"
- ])
- else:
- logging.log(self.log_lvl, f"No track info found for track ID: {track_id}")
- command.append(f"'{input_file}'")
- logging.log(self.log_lvl, f"Executing mkvmerge command: {' '.join(command)}")
Advertisement
Add Comment
Please, Sign In to add comment