diff --git a/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 b/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 index 769aee0efb..7f8827fffb 100644 --- a/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 +++ b/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 @@ -5,7 +5,7 @@ #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-ec3-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1216655,AVERAGE-BANDWIDTH=1104925,CODECS="avc1.64001e,ec-3",RESOLUTION=640x360,FRAME-RATE=9.990,AUDIO="default-audio-group" +#EXT-X-STREAM-INF:BANDWIDTH=1216655,AVERAGE-BANDWIDTH=1104925,CODECS="avc1.64001e,ec-3",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" bear-640x360-ec3-video.m3u8 #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=217180,AVERAGE-BANDWIDTH=157213,CODECS="avc1.64001e",RESOLUTION=640x360,URI="bear-640x360-ec3-video-iframe.m3u8" diff --git a/packager/media/formats/mp2t/ts_muxer.cc b/packager/media/formats/mp2t/ts_muxer.cc index 4c5bab7e78..e3d6447ad4 100644 --- a/packager/media/formats/mp2t/ts_muxer.cc +++ b/packager/media/formats/mp2t/ts_muxer.cc @@ -34,10 +34,12 @@ Status TsMuxer::Finalize() { Status TsMuxer::AddSample(size_t stream_id, const MediaSample& sample) { DCHECK_EQ(stream_id, 0u); - if (sample_duration_ == 0) { - sample_duration_ = sample.duration() * kTsTimescale / streams().front()->time_scale(); - if (muxer_listener()) - muxer_listener()->OnSampleDurationReady(sample_duration_); + if (num_samples_ < 2) { + sample_durations_[num_samples_] = sample.duration() * kTsTimescale / + streams().front()->time_scale(); + if (num_samples_ == 1 && muxer_listener()) + muxer_listener()->OnSampleDurationReady(sample_durations_[num_samples_]); + num_samples_++; } return segmenter_->AddSample(sample); } diff --git a/packager/media/formats/mp2t/ts_muxer.h b/packager/media/formats/mp2t/ts_muxer.h index c2aab357cd..c4c0c4bc74 100644 --- a/packager/media/formats/mp2t/ts_muxer.h +++ b/packager/media/formats/mp2t/ts_muxer.h @@ -35,7 +35,8 @@ class TsMuxer : public Muxer { void FireOnMediaEndEvent(); std::unique_ptr segmenter_; - int64_t sample_duration_ = 0; + int64_t sample_durations_[2]; + int64_t num_samples_ = 0; DISALLOW_COPY_AND_ASSIGN(TsMuxer); };