Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FLV: SRS 4.0 recognizes mono audio streams (AAC) as stereo. #3556

Open
HunterTang opened this issue May 27, 2023 · 1 comment
Open

FLV: SRS 4.0 recognizes mono audio streams (AAC) as stereo. #3556

HunterTang opened this issue May 27, 2023 · 1 comment
Assignees
Labels
Bug It might be a bug. EnglishNative This issue is conveyed exclusively in English. Enhancement Improvement or enhancement.

Comments

@HunterTang
Copy link

HunterTang commented May 27, 2023

Description

  1. Application scenario

There is an older system with a Chrome kernel (compatible with XP) that can only recognize mono audio streams. A mono audio stream was pushed to SRS, and when using flv.js to play the FLV stream, it could not be played. The backend showed that it was recognized as stereo. Currently, this issue is temporarily resolved by using libmp3lame for transcoding.

  1. Actual testing

2.1 Transcoding test with FFMPEG
Push to SRS after transcoding with FFMPEG (version 4.4), the ffmpeg command is as follows:
ffmpeg -i rtmp://127.0.0.1/live/livestream -vn -ac 1 -ar 22050 -c:a libfdk_aac -f flv rtmp://IP/live/livestream

FFmpeg prints the following information:

libavutil      56. 70.100 / 56. 70.100
libavcodec     58.134.100 / 58.134.100
libavformat    58. 76.100 / 58. 76.100
libavdevice    58. 13.100 / 58. 13.100
libavfilter     7.110.100 /  7.110.100
libswscale      5.  9.100 /  5.  9.100
libswresample   3.  9.100 /  3.  9.100
libpostproc    55.  9.100 / 55.  9.100
...

Duration: 00:00:00.00, start: 3046.899000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 44100 Hz, mono, fltp, 65 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (aac (native) -> aac (libfdk_aac))
...
Stream #0:0: Audio: aac ([10][0][0][0] / 0x000A), 22050 Hz, mono, s16, 48 kb/s
Metadata:
encoder         : Lavc58.134.100 libfdk_aac

Using ffprob to view the stream information, it correctly recognizes mono:

Duration: 00:00:00.00, start: 10.867000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 22050 Hz, mono, fltp, 47 kb/s

The following stream information is received through the SRS backend web page:

Recv: 0.00Kbps
Send: 0.00Kbps
Audio: AAC/22050/Stereo/LC

2.2 Pushing mono stream directly with OBS
Pushing a mono audio stream directly to SRS with OBS, the stream information in ffporb is as follows:

Duration: N/A, start: 0.000000, bitrate: 2625 kb/s
Stream #0:0: Data: none
Stream #0:1: Audio: aac (LC), 44100 Hz, mono, fltp, 65 kb/s
Stream #0:2: Video: h264 (Constrained Baseline), yuv420p(progressive), 1920x1080, 2560 kb/s, 30 fps, 30 tbr, 1k tbn

The following stream information is received through the SRS backend web page:

Recv: 0.00Kbps
Send: 0.00Kbps
Video: H264/Baseline/4/1920x1080
Audio: AAC/44100/Stereo/LC
  1. SRS version:
v-4.0.268
v-4.0.251
  1. SRS configuration file:
listen              1935;
max_connections     22000;
pid                 /mnt/srs/srs.pid;
srs_log_tank        file;
srs_log_file        /mnt/srs/log/srs.log;
daemon              on;
http_api {
    enabled         on;
    listen          1985;
}
http_server {
    enabled         on;
    listen          8080;
    dir             /usr/local/srs/objs/nginx/html;
}
rtc_server {
    enabled on;
    listen 8000; # UDP port
    candidate $CANDIDATE;
}
vhost __defaultVhost__ {
    hls {
        enabled         off;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
    rtc {
        enabled     on;
        rtmp_to_rtc on;
        rtc_to_rtmp on;
    }
    forward {
        enabled    off;
    }
}

Replay

Push a mono audio stream to SRS with OBS, and then view the received stream information on the SRS backend page. You can also preview and view the playback log in the console, which will show that the received audio stream is mp4a 40.5 instead of mp4a 40.2.

Expect

Correctly recognize mono audio streams.

@winlinvip winlinvip changed the title SRS4.0将mono的音频流(AAC)识别为stereo FLV: SRS 4.0 recognizes mono audio streams (AAC) as stereo. Jun 10, 2023
@winlinvip winlinvip self-assigned this Jun 10, 2023
@winlinvip winlinvip added Bug It might be a bug. Enhancement Improvement or enhancement. labels Jun 10, 2023
@winlinvip
Copy link
Member

winlinvip commented Jun 10, 2023

When pushing an AAC mono stream, FFmpeg recognizes it as a mono stream, but SRS mistakenly recognizes it as a stereo stream. This seems to be an error in SRS, possibly related to metadata parsing, which causes flv.js to be unable to play the stream due to incorrect audio channel information.

@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It might be a bug. EnglishNative This issue is conveyed exclusively in English. Enhancement Improvement or enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants