File tree Expand file tree Collapse file tree 2 files changed +19
-21
lines changed Expand file tree Collapse file tree 2 files changed +19
-21
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,9 @@ def set_video_codec(
99
99
log .error (f"Unknown encoder: { codec } " )
100
100
# Normalize encoder names
101
101
if cobj .id not in (Codec (x , "w" ).id for x in ctr .vcodecs ):
102
- log .error (codec_error .format (codec , out_ext ))
102
+ log .error (
103
+ f"'{ codec } ' video encoder is not supported in the '{ out_ext } ' container"
104
+ )
103
105
104
106
return codec
105
107
@@ -127,8 +129,9 @@ def set_audio_codec(
127
129
log .error (f"Unknown encoder: { codec } " )
128
130
# Normalize encoder names
129
131
if cobj .id not in (Codec (x , "w" ).id for x in ctr .acodecs ):
130
- log .error (codec_error .format (codec , out_ext ))
131
-
132
+ log .error (
133
+ f"'{ codec } ' audio encoder is not supported in the '{ out_ext } ' container"
134
+ )
132
135
return codec
133
136
134
137
Original file line number Diff line number Diff line change @@ -101,27 +101,22 @@ def render_av(
101
101
log .debug (f"Tous: { tous } " )
102
102
log .debug (f"Clips: { tl .v } " )
103
103
104
- codec = av .Codec (args .video_codec , "w" )
105
-
106
- need_valid_fmt = True
107
- if codec .video_formats is not None :
108
- for video_format in codec .video_formats :
109
- if pix_fmt == video_format .name :
110
- need_valid_fmt = False
111
- break
112
-
113
- if need_valid_fmt :
114
- if codec .canonical_name == "gif" :
115
- pix_fmt = "rgb8"
116
- elif codec .canonical_name == "prores" :
117
- pix_fmt = "yuv422p10le"
118
- else :
119
- pix_fmt = "yuv420p"
120
-
121
- del codec
122
104
output_stream = output .add_stream (args .video_codec , rate = target_fps )
123
105
output_stream .options = {"x265-params" : "log-level=error" }
124
106
107
+ need_valid_fmt = not (
108
+ output_stream .codec .video_formats
109
+ and any (pix_fmt == vfmt .name for vfmt in output_stream .codec .video_formats )
110
+ )
111
+ if need_valid_fmt :
112
+ match output_stream .codec .canonical_name :
113
+ case "gif" :
114
+ pix_fmt = "rgb8"
115
+ case "prores" :
116
+ pix_fmt = "yuv422p10le"
117
+ case _:
118
+ pix_fmt = "yuv420p"
119
+
125
120
cc = output_stream .codec_context
126
121
if args .vprofile is not None :
127
122
if args .vprofile .title () not in cc .profiles :
You can’t perform that action at this time.
0 commit comments