@@ -296,18 +296,18 @@ func (r *Recorder) Run() (err error) {
296296
297297 if vt == nil {
298298 vt = sub .VideoReader .Track
299- switch vt .ICodecCtx .GetBase ().(type ) {
299+ switch video .ICodecCtx .GetBase ().(type ) {
300300 case * codec.H264Ctx :
301301 track := r .muxer .AddTrack (box .MP4_CODEC_H264 )
302302 videoTrack = track
303- track .ICodecCtx = vt .ICodecCtx
303+ track .ICodecCtx = video .ICodecCtx
304304 case * codec.H265Ctx :
305305 track := r .muxer .AddTrack (box .MP4_CODEC_H265 )
306306 videoTrack = track
307- track .ICodecCtx = vt .ICodecCtx
307+ track .ICodecCtx = video .ICodecCtx
308308 }
309309 }
310- ctx := vt .ICodecCtx .(pkg.IVideoCodecCtx )
310+ ctx := video .ICodecCtx .(pkg.IVideoCodecCtx )
311311 if videoTrackCtx , ok := videoTrack .ICodecCtx .(pkg.IVideoCodecCtx ); ok && videoTrackCtx != ctx {
312312 width , height := uint32 (ctx .Width ()), uint32 (ctx .Height ())
313313 oldWidth , oldHeight := uint32 (videoTrackCtx .Width ()), uint32 (videoTrackCtx .Height ())
@@ -322,6 +322,17 @@ func (r *Recorder) Run() (err error) {
322322 at , vt = nil , nil
323323 if vr := sub .VideoReader ; vr != nil {
324324 vr .ResetAbsTime ()
325+ vt = vr .Track
326+ switch video .ICodecCtx .GetBase ().(type ) {
327+ case * codec.H264Ctx :
328+ track := r .muxer .AddTrack (box .MP4_CODEC_H264 )
329+ videoTrack = track
330+ track .ICodecCtx = video .ICodecCtx
331+ case * codec.H265Ctx :
332+ track := r .muxer .AddTrack (box .MP4_CODEC_H265 )
333+ videoTrack = track
334+ track .ICodecCtx = video .ICodecCtx
335+ }
325336 }
326337 if ar := sub .AudioReader ; ar != nil {
327338 ar .ResetAbsTime ()
0 commit comments