File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,12 @@ def main_options(parser: ArgumentParser) -> ArgumentParser:
188
188
metavar = "BITRATE" ,
189
189
help = "Set the number of bits per second for video" ,
190
190
)
191
+ parser .add_argument (
192
+ "-vprofile" ,
193
+ "-profile:v" ,
194
+ metavar = "PROFILE" ,
195
+ help = "Set the video profile. For h264: high, main, or baseline" ,
196
+ )
191
197
parser .add_argument (
192
198
"--scale" ,
193
199
type = number ,
Original file line number Diff line number Diff line change @@ -130,22 +130,34 @@ def render_av(
130
130
log .debug (f"Tous: { tous } " )
131
131
log .debug (f"Clips: { tl .v } " )
132
132
133
+ codec = av .Codec (args .video_codec , "w" )
134
+
133
135
if args .video_codec == "gif" :
134
- _c = av .Codec ("gif" , "w" )
135
- if _c .video_formats is not None and target_pix_fmt in (
136
- f .name for f in _c .video_formats
136
+ if codec .video_formats is not None and target_pix_fmt in (
137
+ f .name for f in codec .video_formats
137
138
):
138
139
target_pix_fmt = target_pix_fmt
139
140
else :
140
141
target_pix_fmt = "rgb8"
141
- del _c
142
142
else :
143
143
target_pix_fmt = (
144
144
target_pix_fmt if target_pix_fmt in allowed_pix_fmt else "yuv420p"
145
145
)
146
146
147
+ del codec
147
148
ops = {"mov_flags" : "faststart" }
148
149
output_stream = output .add_stream (args .video_codec , rate = target_fps , options = ops )
150
+
151
+ if args .vprofile is not None :
152
+ if args .vprofile .title () not in output_stream .codec_context .profiles :
153
+ a = [f'"{ x .lower ()} "' for x in output_stream .codec_context .profiles ]
154
+ b = " " .join (a )
155
+ log .error (
156
+ f"`{ args .vprofile } ` is not a valid profile.\n profiles supported: { b } "
157
+ )
158
+
159
+ output_stream .codec_context .profile = args .vprofile .title ()
160
+
149
161
yield output_stream
150
162
if not isinstance (output_stream , av .VideoStream ):
151
163
log .error (f"Not a known video codec: { args .video_codec } " )
Original file line number Diff line number Diff line change @@ -198,6 +198,7 @@ class Args:
198
198
video_codec : str = "auto"
199
199
audio_codec : str = "auto"
200
200
video_bitrate : str = "auto"
201
+ vprofile : str | None = None
201
202
audio_bitrate : str = "auto"
202
203
scale : float = 1.0
203
204
sn : bool = False
You can’t perform that action at this time.
0 commit comments