@@ -136,6 +136,24 @@ def set_audio_codec(
136
136
return codec
137
137
138
138
139
+ def normalize_encoder (codec : str ) -> tuple [str , bool ]:
140
+ is_hardware = False
141
+ if "_" in codec :
142
+ is_hardware = codec .split ("_" )[- 1 ] in {"videotoolbox" , "cuvid" , "nvec" }
143
+
144
+ id = av .Codec (codec , "w" ).id
145
+ name = {
146
+ 27 : "h264" ,
147
+ 97 : "gif" ,
148
+ 173 : "hevc" ,
149
+ 167 : "vp9" ,
150
+ 139 : "vp8" ,
151
+ 86018 : "aac" ,
152
+ }.get (id , codec )
153
+
154
+ return name , is_hardware
155
+
156
+
139
157
def parse_export (export : str , log : Log ) -> dict [str , Any ]:
140
158
exploded = export .split (":" , maxsplit = 1 )
141
159
if len (exploded ) == 1 :
@@ -365,17 +383,46 @@ def make_media(tl: v3, output_path: str) -> None:
365
383
366
384
# Setup video
367
385
if ctr .default_vid != "none" and tl .v :
368
- vframes = render_av (output , tl , args , bar , log )
386
+ vframes = render_av (output , tl , args , log )
369
387
output_stream = next (vframes )
370
388
else :
371
389
output_stream , vframes = None , iter ([])
372
390
391
+ no_color = log .no_color or log .machine
392
+ encoder_titles = []
393
+ if output_stream is not None :
394
+ name , h = normalize_encoder (output_stream .name )
395
+ if no_color :
396
+ encoder_titles .append (name )
397
+ else :
398
+ is_bold = ";1" if h else ""
399
+ encoder_titles .append (f"\033 [95{ is_bold } m{ name } " )
400
+ if audio_streams :
401
+ name , h = normalize_encoder (audio_streams [0 ].name ) # type: ignore
402
+ if no_color :
403
+ encoder_titles .append (name )
404
+ else :
405
+ is_bold = ";1" if h else ""
406
+ encoder_titles .append (f"\033 [96{ is_bold } m{ name } " )
407
+ if subtitle_streams :
408
+ name = subtitle_streams [0 ].name # type: ignore
409
+ if no_color :
410
+ encoder_titles .append (name )
411
+ else :
412
+ encoder_titles .append (f"\033 [32m{ name } " )
413
+
414
+ title = f"({ os .path .splitext (output_path )[1 ][1 :]} ) "
415
+ if no_color :
416
+ title += "+" .join (encoder_titles )
417
+ else :
418
+ title += "\033 [0m+" .join (encoder_titles ) + "\033 [0m"
419
+ bar .start (tl .end , title )
420
+
373
421
# Process frames
374
422
while True :
375
423
audio_frames = [next (frames , None ) for frames in audio_gen_frames ]
376
- video_frame = next (vframes , None )
424
+ index , video_frame = next (vframes , ( 0 , None ) )
377
425
subtitle_frames = [next (packet , None ) for packet in sub_gen_frames ]
378
-
379
426
if (
380
427
all (frame is None for frame in audio_frames )
381
428
and video_frame is None
@@ -405,12 +452,16 @@ def make_media(tl: v3, output_path: str) -> None:
405
452
except av .FFmpegError as e :
406
453
log .error (e )
407
454
455
+ bar .tick (index )
456
+
408
457
# Flush streams
409
458
if output_stream is not None :
410
459
output .mux (output_stream .encode (None ))
411
460
for audio_stream in audio_streams :
412
461
output .mux (audio_stream .encode (None ))
413
462
463
+ bar .end ()
464
+
414
465
# Close resources
415
466
for audio_input in audio_inputs :
416
467
audio_input .close ()
0 commit comments