@@ -93,10 +93,14 @@ cdef class OutputContainer(Container):
93
93
# Now lets set some more sane video defaults
94
94
elif codec.type == lib.AVMEDIA_TYPE_VIDEO:
95
95
codec_context.pix_fmt = lib.AV_PIX_FMT_YUV420P
96
- codec_context.width = 640
97
- codec_context.height = 480
98
- codec_context.bit_rate = 1024000
99
- codec_context.bit_rate_tolerance = 128000
96
+ codec_context.width = kwargs.pop(" width" , 640 )
97
+ codec_context.height = kwargs.pop(" height" , 480 )
98
+ codec_context.bit_rate = kwargs.pop(" bit_rate" , 1024000 )
99
+ codec_context.bit_rate_tolerance = kwargs.pop(" bit_rate_tolerance" , 128000 )
100
+ try :
101
+ to_avrational(kwargs.pop(" time_base" ), & codec_context.time_base)
102
+ except KeyError :
103
+ pass
100
104
to_avrational(rate or 24 , & codec_context.framerate)
101
105
102
106
stream.avg_frame_rate = codec_context.framerate
@@ -105,9 +109,14 @@ cdef class OutputContainer(Container):
105
109
# Some sane audio defaults
106
110
elif codec.type == lib.AVMEDIA_TYPE_AUDIO:
107
111
codec_context.sample_fmt = codec.sample_fmts[0 ]
108
- codec_context.bit_rate = 128000
109
- codec_context.bit_rate_tolerance = 32000
112
+ codec_context.bit_rate = kwargs.pop(" bit_rate" , 128000 )
113
+ codec_context.bit_rate_tolerance = kwargs.pop(" bit_rate_tolerance" , 32000 )
114
+ try :
115
+ to_avrational(kwargs.pop(" time_base" ), & codec_context.time_base)
116
+ except KeyError :
117
+ pass
110
118
codec_context.sample_rate = rate or 48000
119
+ stream.time_base = codec_context.time_base
111
120
lib.av_channel_layout_default(& codec_context.ch_layout, 2 )
112
121
113
122
# Some formats want stream headers to be separate
0 commit comments