From 133866a944d5991af7e28a6515c0f55bd2889911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haibo=20Chen=28=E9=99=88=E6=B5=B7=E5=8D=9A=29?= <495810242@qq.com> Date: Wed, 4 Jun 2025 22:11:58 +0800 Subject: [PATCH] Transcode: Bugfix: Fix loop transcoding with host. #3516. v6.0.168 v7.0.41 (#4325) #### What issue has been resolved? for issue: https://github.com/ossrs/srs/issues/3516 https://github.com/ossrs/srs/issues/4055 https://github.com/ossrs/srs/pull/3618 #### What is the root cause of the problem? The issue arises from a mismatch between the `input` and `output` formats within the [`SrsEncoder::initialize_ffmpeg`](https://github.com/ossrs/srs/pull/4325/files#diff-a3dd7c498fc26d36def2e8c2c3b7edfe1bf78f0620b1a838aefa70ba119cad03L241-L254) function. For example: Input: `rtmp://127.0.0.1:1935/live?vhost=__defaultVhost__/livestream_ff` Output: `rtmp://127.0.0.1:1935/live/livestream_ff?vhost=__defaultVhost__` This may result in the failure of the [code segment](https://github.com/ossrs/srs/pull/4325/files#diff-a3dd7c498fc26d36def2e8c2c3b7edfe1bf78f0620b1a838aefa70ba119cad03L292-L298) responsible for determining whether to loop. #### What is the approach to solving this issue? It simply involves modifying the order of `stream` and `vhost`. #### How was the issue introduced? The commit introducing this bug is: https://github.com/ossrs/srs/commit/7d47017a001b3c937c555f17f73554b61341d854 The order of [parameters in the configuration file](https://github.com/ossrs/srs/commit/7d47017a001b3c937c555f17f73554b61341d854#diff-428de168925d659dae72bb49273c3b048ed2800906c6848560badae854250126L26-R26) has been modified to address the `ingest` issue. #### Outstanding issues Please note that this PR does not entirely resolve the issue; for example, modifying the `output` format in configuration still results in exceptions. To comprehensively address this problem, extensive code modifications would be required. However, strictly adhering to the configuration file format can effectively prevent this issue. --------- Co-authored-by: Jacob Su Co-authored-by: john Co-authored-by: winlin --- trunk/doc/CHANGELOG.md | 2 ++ trunk/src/app/srs_app_encoder.cpp | 8 ++++---- trunk/src/core/srs_core_version6.hpp | 2 +- trunk/src/core/srs_core_version7.hpp | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 9fa59b27e..033f4d39f 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 7.0 Changelog +* v7.0, 2025-06-04, Merge [#4325](https://github.com/ossrs/srs/pull/4325): fix bug: loop transcoding #3516. v7.0.41 (#4325) * v7.0, 2025-06-04, Merge [#4341](https://github.com/ossrs/srs/pull/4341): Update the release in the README for consistent. v7.0.40 (#4341) * v7.0, 2025-06-04, Merge [#4368](https://github.com/ossrs/srs/pull/4368): Update the codename for version 7.0 to "Kai". v7.0.39 (#4368) * v7.0, 2025-06-01, Merge [#4366](https://github.com/ossrs/srs/pull/4366): Script: Use clang-format to unify the coding style. v7.0.38 (#4366) @@ -51,6 +52,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v6.0, 2025-06-04, Merge [#4325](https://github.com/ossrs/srs/pull/4325): fix bug: loop transcoding #3516. v6.0.168 (#4325) * v6.0, 2025-05-29, Merge [#4356](https://github.com/ossrs/srs/pull/4356): RTMP: Use extended timestamp as delta when chunk fmt=1/2. v6.0.167 (#4356) * v6.0, 2025-03-21, Merge [#4303](https://github.com/ossrs/srs/pull/4303): replace values with enums. v6.0.165 (#4303) * v6.0, 2025-03-20, Merge [#4305](https://github.com/ossrs/srs/pull/4305): free sample to prevent memory leak. v6.0.164 (#4305) diff --git a/trunk/src/app/srs_app_encoder.cpp b/trunk/src/app/srs_app_encoder.cpp index b465c100f..b55d82462 100644 --- a/trunk/src/app/srs_app_encoder.cpp +++ b/trunk/src/app/srs_app_encoder.cpp @@ -247,11 +247,11 @@ srs_error_t SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, Sr input += srs_int2str(req->port); input += "/"; input += req->app; - input += "?vhost="; - input += req->vhost; input += "/"; input += req->stream; - + input += "?vhost="; + input += req->vhost; + // stream name: vhost/app/stream for print input_stream_name = req->vhost; input_stream_name += "/"; @@ -288,7 +288,7 @@ srs_error_t SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, Sr } log_file += ".log"; } - + // important: loop check, donot transcode again. std::vector::iterator it; it = std::find(_transcoded_url.begin(), _transcoded_url.end(), input); diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index af0474289..cc7d160e2 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 167 +#define VERSION_REVISION 168 #endif diff --git a/trunk/src/core/srs_core_version7.hpp b/trunk/src/core/srs_core_version7.hpp index dc2fb364a..2b23a1e6e 100644 --- a/trunk/src/core/srs_core_version7.hpp +++ b/trunk/src/core/srs_core_version7.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 7 #define VERSION_MINOR 0 -#define VERSION_REVISION 40 +#define VERSION_REVISION 41 #endif \ No newline at end of file