ossrs / srs

SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
25.72k stars 5.39k forks source link

API - Incorrect display of stream AV parameters (left over restrictions from flv legacy specs) #4212

Open laurfb opened 2 weeks ago

laurfb commented 2 weeks ago

In Stream (console) page srs report always 44100 as sampling frequency for audio regardless of real value. At the moment srs can manage/recognize only four sampling frequency (5512, 11025, 22050, 44100). Any other sampling feequency, apart from the four mentioned, are displayed as 44100.

Version srs docker v6.x/5.x

To Reproduce push some rtmp stream to srs (OBS/ffmpeg, etc,) like:

ffmpeg -re -i input.mp4 -c:v libx264 -profile:v high -preset:v ultrafast -b:v 8M -c:a aac -ar 48000 -ac 2 -b:a 256k -f flv rtmp://192.168.1.1:1935/live/test

or with any other sampling frequency (48000, 96000, whatever)

Checking outputed stream with ffmpeg/ffprobe/ffplay we got corectly the expected audio sampling frequency: 48000 96000

but srs always display 44100 srs_report

Expected behavior Display real (detected) value (48000, 96000...).

Additional context Related to this issue: srs doen't display any info about received streams if "srt_to_rtmp" option is set to "off". If "srt_to_rtmp" is set to "on" srs display altered info for video and always "44100" as sampling frequency for audio regardless real input values. sshot-351

Don't know in this case if this is the expected behavior (no info if "srt_to_rtmp" is set to "off")

To Reproduce Push srt stream to srs:

ffmpeg -re -i input.mp4 -c:v libx264 -profile:v high -preset:v ultrafast -b:v 8M -c:a aac -ar 48000 -ac 2 -b:a 256k -f mpegts srt://192.168.1.1:10080?streamid=#!::r=live/test,m=publish

Check output stream data with:

ffplay srt://192.168.1.1:10080?streamid=#!::r=live/test,m=request or with ffprobe srt://192.168.1.1:10080?streamid=#!::r=live/test,m=request

and compare with info reported by srs

regards, Laur

duiniuluantanqin commented 1 week ago

This PR(fix sample_rate error in statistic) is experimental and not recommended for merging into the main branch. Many scenarios haven't been considered, such as the MP3 format. This would add a lot of code without much benefit.

Of course, if you don't need to consider more formats, you can merge it into your own branch. It is functional.

laurfb commented 1 week ago

Hi. Did some test with srt streams with aac, mp3 and ogg audio codecs. The results:

srt/rtmp streams with aac audio, sampling 48000: statistics displayed for both, but with default 44100 sampling frequncy instead of 48000 display_srt_aac

srt/rtmp streams with mp3 audio, sampling 48000: statistics displayed only for rtmp, again with default 44100 sampling frequncy instead of 48000, only video for srt display_srt_mp3

srt/rtmp streams with ogg audio, sampling 48000: the same, statistic displayed only for rtmp, default 44100 sampling frequncy displayed instead of 48000, only video for srt, audio detected as AAC display_srt_ogg

Anyway, it's an (important) step ahead! :) Thx!

regards, Laur

duiniuluantanqin commented 1 week ago

OK, I will recheck the SRT streaming