@@ -252,7 +252,7 @@ func (e *encoder) Read() ([]byte, func(), error) {
252
252
e .raw .d_w , e .raw .d_h = C .uint (width ), C .uint (height )
253
253
}
254
254
255
- duration := t .Sub (e .tLastFrame ).Nanoseconds () / 1000000
255
+ duration := t .Sub (e .tLastFrame ).Microseconds ()
256
256
// VPX doesn't allow 0 duration. If 0 is given, vpx_codec_encode will fail with VPX_CODEC_INVALID_PARAM.
257
257
// 0 duration is possible because mediadevices first gets the frame meta data by reading from the source,
258
258
// and consequently the codec will read the first frame from the buffer. This means the first frame won't
@@ -267,7 +267,7 @@ func (e *encoder) Read() ([]byte, func(), error) {
267
267
}
268
268
if ec := C .encode_wrapper (
269
269
e .codec , e .raw ,
270
- C .long (t .Sub (e .tStart ).Nanoseconds () / 1000000 ), C .ulong (duration ), C .long (flags ), C .ulong (e .deadline ),
270
+ C .long (t .Sub (e .tStart ).Microseconds () ), C .ulong (duration ), C .long (flags ), C .ulong (e .deadline ),
271
271
(* C .uchar )(& yuvImg .Y [0 ]), (* C .uchar )(& yuvImg .Cb [0 ]), (* C .uchar )(& yuvImg .Cr [0 ]),
272
272
); ec != C .VPX_CODEC_OK {
273
273
return nil , func () {}, fmt .Errorf ("vpx_codec_encode failed (%d)" , ec )
0 commit comments