Skip to content

Commit

Permalink
muxer: remove useless check
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Dec 26, 2023
1 parent a85e630 commit d240822
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions muxer_segmenter_fmp4.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,22 +325,18 @@ func (m *muxerSegmenterFMP4) writeVideo(
forceSwitch bool,
sample *augmentedSample,
) error {
// add a starting DTS to avoid a negative BaseTime
// add a starting DTS to avoid a negative audio BaseTime
sample.dts += fmp4StartDTS

// BaseTime is still negative, this is not supported by fMP4. Reject the sample silently.
if (sample.dts - m.startDTS) < 0 {
return nil
}

// put samples into a queue in order to
// - compute sample duration
// - check if next sample is IDR
sample, m.nextVideoSample = m.nextVideoSample, sample
if sample == nil {
return nil
}
sample.Duration = uint32(durationGoToMp4(m.nextVideoSample.dts-sample.dts, 90000))
duration := m.nextVideoSample.dts - sample.dts
sample.Duration = uint32(durationGoToMp4(duration, 90000))

// create first segment
if m.currentSegment == nil {
Expand Down Expand Up @@ -368,7 +364,7 @@ func (m *muxerSegmenterFMP4) writeVideo(
}
}

m.adjustPartDuration(m.nextVideoSample.dts - sample.dts)
m.adjustPartDuration(duration)

err := m.currentSegment.writeVideo(sample, m.nextVideoSample.dts, m.adjustedPartDuration)
if err != nil {
Expand Down Expand Up @@ -424,7 +420,7 @@ func (m *muxerSegmenterFMP4) writeVideo(
}

func (m *muxerSegmenterFMP4) writeAudio(sample *augmentedSample) error {
// add a starting DTS to avoid a negative BaseTime
// add a starting DTS to avoid a negative audio BaseTime
sample.dts += fmp4StartDTS

// BaseTime is still negative, this is not supported by fMP4. Reject the sample silently.
Expand All @@ -444,7 +440,8 @@ func (m *muxerSegmenterFMP4) writeAudio(sample *augmentedSample) error {
if sample == nil {
return nil
}
sample.Duration = uint32(durationGoToMp4(m.nextAudioSample.dts-sample.dts, m.audioTimeScale))
duration := m.nextAudioSample.dts - sample.dts
sample.Duration = uint32(durationGoToMp4(duration, m.audioTimeScale))

if m.videoTrack == nil {
// create first segment
Expand Down

0 comments on commit d240822

Please sign in to comment.