From b3143e8c140239a2833d8efcfb39b718f2d30b98 Mon Sep 17 00:00:00 2001 From: langhuihui <178529795@qq.com> Date: Mon, 2 Jun 2025 22:31:25 +0800 Subject: [PATCH] fix: mp4 download --- plugin/mp4/api.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugin/mp4/api.go b/plugin/mp4/api.go index 6a82868..5e3fdbf 100644 --- a/plugin/mp4/api.go +++ b/plugin/mp4/api.go @@ -249,12 +249,13 @@ func (p *MP4Plugin) download(w http.ResponseWriter, r *http.Request) { } if i == 0 { startTimestamp := startTime.Sub(stream.StartTime).Milliseconds() - var startSample *box.Sample - if startSample, err = demuxer.SeekTime(uint64(startTimestamp)); err != nil { - tsOffset = 0 - continue + if startTimestamp > 0 { + var startSample *box.Sample + if startSample, err = demuxer.SeekTime(uint64(startTimestamp)); err != nil { + continue + } + tsOffset = -int64(startSample.Timestamp) } - tsOffset = -int64(startSample.Timestamp) } var part *ContentPart for track, sample := range demuxer.RangeSample {