diff --git a/auto_editor/edit.py b/auto_editor/edit.py index 69a1ffdf5..3d71cb02c 100644 --- a/auto_editor/edit.py +++ b/auto_editor/edit.py @@ -136,24 +136,6 @@ def set_audio_codec( return codec -def normalize_encoder(codec: str) -> tuple[str, bool]: - is_hardware = False - if "_" in codec: - is_hardware = codec.split("_")[-1] in {"videotoolbox", "cuvid", "nvec"} - - id = av.Codec(codec, "w").id - name = { - 27: "h264", - 97: "gif", - 173: "hevc", - 167: "vp9", - 139: "vp8", - 86018: "aac", - }.get(id, codec) - - return name, is_hardware - - def parse_export(export: str, log: Log) -> dict[str, Any]: exploded = export.split(":", maxsplit=1) if len(exploded) == 1: @@ -391,25 +373,14 @@ def make_media(tl: v3, output_path: str) -> None: no_color = log.no_color or log.machine encoder_titles = [] if output_stream is not None: - name, h = normalize_encoder(output_stream.name) - if no_color: - encoder_titles.append(name) - else: - is_bold = ";1" if h else "" - encoder_titles.append(f"\033[95{is_bold}m{name}") + name = output_stream.codec.canonical_name + encoder_titles.append(name if no_color else f"\033[95m{name}") if audio_streams: - name, h = normalize_encoder(audio_streams[0].name) # type: ignore - if no_color: - encoder_titles.append(name) - else: - is_bold = ";1" if h else "" - encoder_titles.append(f"\033[96{is_bold}m{name}") + name = audio_streams[0].name + encoder_titles.append(name if no_color else f"\033[96m{name}") if subtitle_streams: - name = subtitle_streams[0].name # type: ignore - if no_color: - encoder_titles.append(name) - else: - encoder_titles.append(f"\033[32m{name}") + name = subtitle_streams[0].name + encoder_titles.append(name if no_color else f"\033[32m{name}") title = f"({os.path.splitext(output_path)[1][1:]}) " if no_color: diff --git a/auto_editor/ffwrapper.py b/auto_editor/ffwrapper.py index bbb5e70b8..ace705665 100644 --- a/auto_editor/ffwrapper.py +++ b/auto_editor/ffwrapper.py @@ -147,10 +147,9 @@ def initFileInfo(path: str, log: Log) -> FileInfo: adur = float(a.duration * a.time_base) a_cc = a.codec_context - name = a_cc.name if a_cc.name != "mp3float" else "mp3" audios += ( AudioStream( - name, + a_cc.codec.canonical_name, 0 if a_cc.sample_rate is None else a_cc.sample_rate, a.layout.name, a_cc.channels, diff --git a/auto_editor/render/video.py b/auto_editor/render/video.py index 43a90d2d3..7de014161 100644 --- a/auto_editor/render/video.py +++ b/auto_editor/render/video.py @@ -108,14 +108,14 @@ def render_av( codec = av.Codec(args.video_codec, "w") - if codec.id == 97: # gif + if codec.canonical_name == "gif": if codec.video_formats is not None and target_pix_fmt in ( f.name for f in codec.video_formats ): target_pix_fmt = target_pix_fmt else: target_pix_fmt = "rgb8" - elif codec.id == 147: # prores + elif codec.canonical_name == "prores": target_pix_fmt = "yuv422p10le" else: target_pix_fmt = ( diff --git a/auto_editor/utils/bar.py b/auto_editor/utils/bar.py index b48450b4e..d79d12561 100644 --- a/auto_editor/utils/bar.py +++ b/auto_editor/utils/bar.py @@ -89,7 +89,7 @@ def tick(self, index: float) -> None: percent = round(progress * 100, 1) p_pad = " " * (4 - len(str(percent))) columns = get_terminal_size().columns - bar_len = max(1, columns - (len_title + 32)) + bar_len = max(1, columns - len_title - 32) bar_str = self._bar_str(progress, bar_len) bar = f" {self.icon}{title} {bar_str} {p_pad}{percent}% ETA {new_time}"