1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-14 20:31:56 +00:00

Fix the test fail when enable ffmpeg-opus. v6.0.100 (#3868)

1. After enabling FFmpeg opus, the transcoding time for each opus packet
is around 4ms.
2. To speed up case execution, our test publisher sends 400 opus packets
at intervals of 1ms.
3. After the publisher starts, wait for 30ms, then the player starts.
4. Due to the lengthy processing time for each opus packet, SRS
continuously receives packets from the publisher, so it doesn't switch
coroutines and can't accept the player's connection.
5. Only after all opus packets are processed will it accept the player
connection. Therefore, the player doesn't receive any data, leading to
the failure of the case.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
This commit is contained in:
john 2023-11-16 18:17:04 +08:00 committed by GitHub
parent a2324a620a
commit 24235d8b6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 7 deletions

View file

@ -198,7 +198,7 @@ jobs:
- name: Run SRS regression-test
run: |
docker run --rm srs:test bash -c './objs/srs -c conf/regression-test.conf && \
cd 3rdparty/srs-bench && (./objs/srs_test -test.v || (cat ../../objs/srs.log && exit 1)) && \
cd 3rdparty/srs-bench && (./objs/srs_test -test.v || (cat ../../objs/srs.log && exit 1)) && cat ../../objs/srs.log && \
./objs/srs_gb28181_test -test.v'
runs-on: ubuntu-20.04

View file

@ -24,7 +24,6 @@ import (
"bytes"
"context"
"fmt"
"github.com/pkg/errors"
"math/rand"
"os"
"sync"
@ -36,6 +35,7 @@ import (
"github.com/ossrs/go-oryx-lib/logger"
"github.com/ossrs/go-oryx-lib/rtmp"
"github.com/pion/interceptor"
"github.com/pkg/errors"
)
func TestRtmpPublishPlay(t *testing.T) {
@ -623,7 +623,10 @@ func TestRtmpPublish_HttpFlvPlayNoVideo(t *testing.T) {
go func() {
defer wg.Done()
publisher.onSendPacket = func(m *rtmp.Message) error {
time.Sleep(1 * time.Millisecond)
// Note that must greater than the cost of ffmpeg-opus, which is about 4ms, otherwise,
// the publisher will always get audio frames to transcode and won't accept new players
// connection and finally failed the case.
time.Sleep(5 * time.Millisecond)
return nil
}
if r0 = publisher.Ingest(ctx, *srsPublishAvatar); r0 != nil {

View file

@ -16,7 +16,8 @@ COPY . /srs
WORKDIR /srs/trunk
# Note that we must enable the gcc7 or link failed.
RUN ./configure --srt=on --gb28181=on --srt=on --gb28181=on --apm=on --h265=on --utest=on
# Note that we must disable the build-cache, or it will failed, but donot know why.
RUN ./configure --srt=on --gb28181=on --srt=on --apm=on --h265=on --utest=on --ffmpeg-opus=off --build-cache=on
RUN make utest ${MAKEARGS}
# Build benchmark tool.

View file

@ -37,6 +37,7 @@ SRS_FFMPEG_TOOL=NO
# FFmpeg fit is the source code for RTC, to transcode audio or video in SRS.
SRS_FFMPEG_FIT=RESERVED
# Whether use FFmpeg native opus codec for RTC. If not, use libopus instead.
# Should disable it by default, because the cost of it is very high, see https://github.com/ossrs/srs/pull/3868
SRS_FFMPEG_OPUS=NO
# arguments
SRS_PREFIX=/usr/local/srs

View file

@ -7,6 +7,7 @@ The changelog for SRS.
<a name="v6-changes"></a>
## SRS 6.0 Changelog
* v6.0, 2023-11-16, Merge [#3868](https://github.com/ossrs/srs/pull/3868): Fix the test fail when enable ffmpeg-opus. v6.0.100 (#3868)
* v6.0, 2023-11-15, Merge [#3879](https://github.com/ossrs/srs/pull/3879): Add --extra-ldflags. v6.0.99 (#3879)
* v6.0, 2023-11-06, Merge [#3851](https://github.com/ossrs/srs/pull/3851): donot compile libopus when enable sys-ffmpeg. v6.0.98 (#3851)
* v6.0, 2023-11-04, Merge [#3852](https://github.com/ossrs/srs/pull/3852): RTC: Refine FFmpeg opus audio noisy issue. v6.0.97 (#3852)

View file

@ -27,11 +27,11 @@ ProcessorCount(JOBS)
# We should always configure SRS for switching between branches.
IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
EXECUTE_PROCESS(
COMMAND ./configure --osx --srt=on --gb28181=on --apm=on --h265=on --utest=on --jobs=${JOBS}
COMMAND ./configure --osx --srt=on --gb28181=on --apm=on --h265=on --utest=on --ffmpeg-opus=off --jobs=${JOBS}
WORKING_DIRECTORY ${SRS_DIR} RESULT_VARIABLE ret)
ELSE ()
EXECUTE_PROCESS(
COMMAND ./configure --srt=on --gb28181=on --apm=on --h265=on --utest=on --jobs=${JOBS}
COMMAND ./configure --srt=on --gb28181=on --apm=on --h265=on --utest=on --ffmpeg-opus=off --jobs=${JOBS}
WORKING_DIRECTORY ${SRS_DIR} RESULT_VARIABLE ret)
ENDIF ()
if(NOT ret EQUAL 0)

View file

@ -247,6 +247,10 @@ srs_error_t SrsAudioTranscoder::init_enc(SrsAudioCodecId dst_codec, int dst_chan
//TODO: for more level setting
enc_->compression_level = 1;
enc_->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
#ifdef SRS_FFMPEG_OPUS
av_opt_set(enc_->priv_data, "opus_delay", "2.5", 0);
#endif
} else if (dst_codec == SrsAudioCodecIdAAC) {
enc_->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
}

View file

@ -9,6 +9,6 @@
#define VERSION_MAJOR 6
#define VERSION_MINOR 0
#define VERSION_REVISION 99
#define VERSION_REVISION 100
#endif