From 46357e159dd9a8ef8a1a6705c1c8029f50e79773 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 6 Feb 2024 10:44:56 +0800 Subject: [PATCH] VLive: Fix the re bug for file. v5.13.27 --- DEVELOPER.md | 3 ++- platform/forward.go | 4 +--- platform/trancode.go | 1 + platform/utils.go | 12 +++++++++++- platform/version.go | 2 +- platform/virtual-live-stream.go | 3 ++- scripts/setup-aapanel/info.json | 2 +- scripts/setup-bt/info.json | 2 +- scripts/setup-droplet/srs.json | 2 +- 9 files changed, 21 insertions(+), 10 deletions(-) diff --git a/DEVELOPER.md b/DEVELOPER.md index 257bbbc5..a8ac1f46 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -1143,7 +1143,8 @@ The following are the update records for the SRS Stack server. * Room: Fix the empty room UI sort and secret bug. [v5.13.23](https://github.com/ossrs/srs-stack/releases/tag/v5.13.23) * FFmpeg: Fix restart bug for abnormal speed. v5.13.24 * FFmpeg: Fix bug for output SRT protocol. v5.13.25 - * FFmpeg: Support ingest SRT protocol. [v5.13.26](https://github.com/ossrs/srs-stack/releases/tag/v5.13.26) + * FFmpeg: Support ingest SRT protocol. v5.13.26 + * VLive: Fix the re bug for file. [v5.13.27](https://github.com/ossrs/srs-stack/releases/tag/v5.13.27) * v5.12 * Refine local variable name conf to config. v5.12.1 * Add forced exit on timeout for program termination. v5.12.1 diff --git a/platform/forward.go b/platform/forward.go index 14f080b9..415b66f0 100644 --- a/platform/forward.go +++ b/platform/forward.go @@ -585,9 +585,7 @@ func (v *ForwardTask) doForward(ctx context.Context, input *SrsStream) error { // Start FFmpeg process. args := []string{} - args = append(args, "-re", - "-fflags", "nobuffer", // Reduce the latency introduced by optional buffering. - ) + args = append(args, "-re") // For RTSP stream source, always use TCP transport. if strings.HasPrefix(inputURL, "rtsp://") { args = append(args, "-rtsp_transport", "tcp") diff --git a/platform/trancode.go b/platform/trancode.go index 342add8b..80cd4965 100644 --- a/platform/trancode.go +++ b/platform/trancode.go @@ -481,6 +481,7 @@ func (v *TranscodeTask) doTranscode(ctx context.Context, input *SrsStream) error // Start FFmpeg process. args := []string{} + args = append(args, "-re") // For RTSP stream source, always use TCP transport. if strings.HasPrefix(inputURL, "rtsp://") { args = append(args, "-rtsp_transport", "tcp") diff --git a/platform/utils.go b/platform/utils.go index af3a6b9e..40fbdf8d 100644 --- a/platform/utils.go +++ b/platform/utils.go @@ -1547,6 +1547,8 @@ func (v *FFmpegHeartbeat) Parse(u *url.URL) { // Polling the FFmpeg stderr and detect the error. func (v *FFmpegHeartbeat) Polling(ctx context.Context, stderr io.Reader) { pollingReadyCtx, cancelPollingReady := context.WithCancel(ctx) + logger.Tf(ctx, "FFmpeg: Start to polling heartbeat, start=%v, msd=%v, afs=%v", + v.starttime, v.MaxStreamDuration, v.AbnormalFastSpeed) // Print the extra logs when quit. go func() { @@ -1584,6 +1586,7 @@ func (v *FFmpegHeartbeat) Polling(ctx context.Context, stderr io.Reader) { }() // Handle the FFmpeg log, detect the error and update the heartbeat. + var firstNormalFrame bool handleOutputOfFFmpeg := func(ffmpegLog string) { // Filter the line of log. line := strings.TrimSpace(ffmpegLog) @@ -1603,7 +1606,7 @@ func (v *FFmpegHeartbeat) Polling(ctx context.Context, stderr io.Reader) { v.extraLogs = append(v.extraLogs, line) return } - if strings.Contains(line, "time=N/A") || strings.Contains(line, "time=00:00:00.00") { + if strings.Contains(line, "time=N/A") || strings.Contains(line, "speed=N/A") { v.extraLogs = append(v.extraLogs, line) return } @@ -1659,6 +1662,13 @@ func (v *FFmpegHeartbeat) Polling(ctx context.Context, stderr io.Reader) { v.update, v.parsedCount = time.Now(), v.parsedCount+1 v.line, v.timestamp, v.speed = line, timestamp, speed + if !firstNormalFrame { + firstNormalFrame = true + logger.Tf(ctx, "FFmpeg: First normal frame, parsed=%v, failed=%v,<%v>, speed=%v,%v,%v,<%v>, not-change=%v,<%v>, last=<%v>", + v.parsedCount, v.failedParsedCount, v.lastFailedParsed, v.failedSpeedCount, + v.veryFastSpeedCount, v.verySlowSpeedCount, v.lastFailedSpeed, v.notChangedCount, v.lastNotChanged, + v.line) + } // Handle the routine heartbeat logs. select { diff --git a/platform/version.go b/platform/version.go index 9783a49d..ae2426b8 100644 --- a/platform/version.go +++ b/platform/version.go @@ -6,4 +6,4 @@ package main // The version for platform. -const version = "v5.13.26" +const version = "v5.13.27" diff --git a/platform/virtual-live-stream.go b/platform/virtual-live-stream.go index eb233b46..f1d47ceb 100644 --- a/platform/virtual-live-stream.go +++ b/platform/virtual-live-stream.go @@ -1032,8 +1032,9 @@ func (v *VLiveTask) doVirtualLiveStream(ctx context.Context, input *FFprobeSourc // Start FFmpeg process. args := []string{} - if input.Type != FFprobeSourceTypeStream { + if input.Type == FFprobeSourceTypeFile || input.Type == FFprobeSourceTypeUpload { args = append(args, "-stream_loop", "-1") + args = append(args, "-re") } // For RTSP stream source, always use TCP transport. if strings.HasPrefix(input.Target, "rtsp://") { diff --git a/scripts/setup-aapanel/info.json b/scripts/setup-aapanel/info.json index 4fd0eebf..7b339e17 100644 --- a/scripts/setup-aapanel/info.json +++ b/scripts/setup-aapanel/info.json @@ -2,7 +2,7 @@ "title": "SRS Stack", "name": "srs_stack", "ps": "SRS Stack is an all-in-one, out-of-the-box, and open-source video solution for creating online video services, including live streaming and WebRTC, on the cloud or through self-hosting. Built with SRS, FFmpeg, and WebRTC, it supports various protocols and offers features like authentication, multi-platform streaming, recording, transcoding, virtual live events, AI transcription, AI assistant, automatic HTTPS, and HTTP Open API.", - "versions": "5.13.26", + "versions": "5.13.27", "checks": "/www/server/panel/plugin/srs_stack", "author": "Winlin", "home": "https://github.com/ossrs/srs-stack" diff --git a/scripts/setup-bt/info.json b/scripts/setup-bt/info.json index 7a832a1f..2afc37f9 100644 --- a/scripts/setup-bt/info.json +++ b/scripts/setup-bt/info.json @@ -2,7 +2,7 @@ "title": "SRS音视频服务器", "name": "srs_stack", "ps": "SRS Stack让你一键拥有自己的视频云解决方案,可以在云上或私有化部署,支持丰富的音视频协议,提供鉴权、私人直播间、多平台转播、录制、转码、虚拟直播、AI字幕、直播间AI助手、自动HTTPS、开放API等丰富功能,基于SRS、FFmpeg和WebRTC构建。", - "versions": "5.13.26", + "versions": "5.13.27", "checks": "/www/server/panel/plugin/srs_stack", "author": "Winlin", "home": "https://github.com/ossrs/srs-stack" diff --git a/scripts/setup-droplet/srs.json b/scripts/setup-droplet/srs.json index fba95a26..08fe607d 100644 --- a/scripts/setup-droplet/srs.json +++ b/scripts/setup-droplet/srs.json @@ -3,7 +3,7 @@ "do_token": "{{env `DIGITALOCEAN_TOKEN`}}", "image_name": "srs-5-snapshot-{{timestamp}}", "application_name": "SRS", - "application_version": "5.13.26" + "application_version": "5.13.27" }, "sensitive-variables": ["do_token"], "builders": [