srs icon indicating copy to clipboard operation
srs copied to clipboard

RTSP2RTMP2RTC: RTMP and DVR is ok, but there is noise in RTC.

Open 2653248604 opened this issue 3 years ago • 9 comments

Note: Before asking a question, please read the FAQ (Please read FAQ before filing an issue) https://github.com/ossrs/srs/issues/2716

Description

Please describe your issue here.

  1. SRS version: srs-4.0.198
  1. SRS log:
[1970-01-01 09:36:21.998][Trace][418][p7u6j85b] XCORE-SRS/4.0.198(Leo)
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] config parse complete
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] write log to console
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b][MAIN] SRS/4.0.198(Leo), MIT
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] authors: https://github.com/ossrs/srs/blob/4.0release/trunk/AUTHORS.txt
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] contributors: Winlin<[email protected]> Winlin<[email protected]> Winlin<[email protected]> Wenjie<[email protected]> Wenjie<[email protected]> Wenjie<[email protected]> xiangcheng.liu<[email protected]> naijia.liu<[email protected]> alcoholyi<[email protected]> byteman<[email protected]> chad.wang<[email protected]> suhetao<[email protected]> Johnny<[email protected]> karthikeyan<[email protected]> StevenLiu<[email protected]> zhengfl<[email protected]> tufang14<[email protected]> allspace<[email protected]> niesongsong<[email protected]> rudeb0t<[email protected]> CallMeNP<[email protected]> synote<[email protected]> lovecat<[email protected]> panda1986<[email protected]> YueHonghui<[email protected]> ThomasDreibholz<[email protected]> JuntaoLiu<[email protected]> RocFang<[email protected]> MakarovYaroslav<[email protected]> MirkoVelic<[email protected]> HuiZhang(huzhang2)<[email protected]> OtterWa<[email protected]> walkermi<[email protected]> haofz<[email protected]> ME_Kun_Han<[email protected]> ljx0305<[email protected]> cenxinwei<[email protected]> StarBrilliant<[email protected]> xubin<[email protected]> intliang<[email protected]> flowerwrong<[email protected]> YLX<[email protected]> J<[email protected]> Harlan<[email protected]> hankun<[email protected]> JonathanBarratt<[email protected]> KeeganH<[email protected]> StevenLiu<[email protected]> liuxc0116<[email protected]> ChengdongZhang<[email protected]> lovacat<[email protected]> qiang.li<[email protected]> HungMingWu<[email protected]> Himer<[email protected]> XiaLixin<[email protected]> XiaLixin<[email protected]> XiaLixin<[email protected]> XiaLixin<[email protected]> alphonsetai<[email protected]> Michael.Ma<[email protected]> lam2003<[email protected]> ShiWei<[email protected]> ShiWei<[email protected]> XiaofengWang<[email protected]> XiaoZhihong<[email protected]> XiaoZhihong<[email protected]> XiaoZhihong<[email protected]> yanghuiwen<[email protected]> WuPengqiang<[email protected]> WuPengqiang<[email protected]> l<22312935+lam2003@github> xfalcon<x-falcon@github> ChenGuanghua<[email protected]> ChenGuanghua<[email protected]> LiPeng<[email protected]> LiPeng<[email protected]> yajun18<[email protected]> liulichuan<[email protected]> yapingcat<[email protected]> chenchengbin<[email protected]> ChenHaibo<[email protected]> ChenHaibo<[email protected]> jasongwq<[email protected]> yinjiaoyuan<[email protected]> PieerePi<[email protected]> JesseXi<[email protected]> PieerePi<40780488+PieerePi@github> ghostsf<[email protected]> xbpeng121<53243357+xbpeng121@github> johzzy<[email protected]> stone<[email protected]> cfw11<34058899+cfw11@github> Hung-YiChen<[email protected]> long<[email protected]> matthew1838<77285055+matthew1838@github> rise<[email protected]> 
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] cwd=/mytest/srs, work_dir=./, build: 2021-12-20 09:03:37, configure: --cross-build --cc=aarch64-linux-gnu-gcc --cxx=aarch64-linux-gnu-g++ --ar=aarch64-linux-gnu-ar --ld=aarch64-linux-gnu-ld --randlib=aarch64-linux-gnu-randlib, uname: Linux a-virtual-machine 5.4.0-87-generic #98~18.04.1-Ubuntu SMP Wed Sep 22 10:45:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux, osx: 0
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] configure detail: --prefix=/usr/local/srs --hls=on --hds=off --dvr=on --ssl=on --https=on --ssl-1-0=off --ssl-local=off --sys-ssl=off --transcode=on --ingest=on --stat=on --http-callback=on --http-server=on --stream-caster=on --http-api=on --utest=off --cherrypy=off --srt=off --rtc=on --simulator=off --cxx11=off --cxx14=off --ffmpeg-fit=on --nasm=on --srtp-nasm=on --clean=on --gperf=off --gmc=off --gmd=off --gmp=off --gcp=off --gprof=off --static=off --shared-st=off --shared-srt=off --shared-ffmpeg=off --log-verbose=off --log-info=off --log-trace=on --gcov=off --debug=off --debug-stats=off --cross-build=on --arch=aarch64 --host=aarch64-linux-gnu --cross-prefix=aarch64-linux-gnu- --cc=aarch64-linux-gnu-gcc --cxx=aarch64-linux-gnu-g++ --ar=aarch64-linux-gnu-ar --ld=aarch64-linux-gnu-ld --randlib=aarch64-linux-gnu-randlib
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] srs checking config...
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] ips, iface[0] eno0 ipv4 0x11043 192.168.142.100, iface[1] swp1 ipv4 0x11043 192.168.2.1, iface[2] eno0 ipv6 0x11043 fe80::382b:93ff:fea4:bf78%eno0, iface[3] eno2 ipv6 0x11043 fe80::8056:14ff:fe53:8e15%eno2, iface[4] swp1 ipv6 0x11043 fe80::8056:14ff:fe53:8e15%swp1
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] devices, intranet eno0 192.168.142.100, intranet swp1 192.168.2.1, intranet eno0 fe80::382b:93ff:fea4:bf78%eno0, intranet eno2 fe80::8056:14ff:fe53:8e15%eno2, intranet swp1 fe80::8056:14ff:fe53:8e15%swp1
[1970-01-01 09:36:21.999][Warn][418][p7u6j85b][2] stats network use index=0, ip=192.168.142.100, ifname=eno0
[1970-01-01 09:36:21.999][Warn][418][p7u6j85b][2] stats disk not configed, disk iops disabled.
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] write log to console
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] features, rch:on, dash:on, hls:on, hds:off, srt:off, hc:on, ha:on, hs:on, hp:on, dvr:on, trans:on, inge:on, stat:on, sc:on
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] SRS on  aarch64(crossbuild), conf:rtmp2rtc.conf, limit:1000, writev:1024, encoding:little-endian, HZ:100
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] mw sleep:350ms. mr enabled:on, default:0, sleep:350ms
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] gc:on, pq:30000ms, cscc:[0,16), csa:on, tn:on(may hurts performance), ss:auto(guess by merged write)
[1970-01-01 09:36:21.999][Trace][418][p7u6j85b] system default latency(ms): mw(0-350) + mr(0-350) + play-queue(0-30000)
[1970-01-01 09:36:21.999][Warn][418][p7u6j85b][2] SRS/4.0.198 is not stable
[1970-01-01 09:36:22.014][Trace][418][p7u6j85b] fingerprint=3B:0D:96:65:2F:C8:2C:22:0A:D4:13:43:BA:68:DD:EC:49:53:92:74:50:1E:CC:39:42:8B:A5:47:70:1A:56:67
[1970-01-01 09:36:22.014][Trace][418][p7u6j85b] CircuitBreaker: enabled=1, high=2x90, critical=1x95, dying=5x99
[1970-01-01 09:36:22.014][Trace][418][p7u6j85b] http flv live stream, vhost=__defaultVhost__, mount=[vhost]/[app]/[stream].flv
[1970-01-01 09:36:22.014][Trace][418][p7u6j85b] http: root mount to ./objs/nginx/html
[1970-01-01 09:36:22.014][Trace][418][p7u6j85b] server main cid=p7u6j85b, pid=418, ppid=401, asprocess=0
[1970-01-01 09:36:22.014][Trace][418][p7u6j85b] write pid=418 to ./objs/srs.pid success!
[1970-01-01 09:36:22.014][Trace][418][p7u6j85b] RTMP listen at tcp://0.0.0.0:1935, fd=6
[1970-01-01 09:36:22.015][Trace][418][p7u6j85b] HTTP-API listen at tcp://0.0.0.0:1985, fd=7
[1970-01-01 09:36:22.015][Trace][418][p7u6j85b] HTTP-Server listen at tcp://0.0.0.0:8080, fd=8
[1970-01-01 09:36:22.015][Trace][418][p7u6j85b] signal installed, reload=1, reopen=10, fast_quit=15, grace_quit=3
[1970-01-01 09:36:22.015][Trace][418][p7u6j85b] http: api mount /console to ./objs/nginx/html/console
[1970-01-01 09:36:22.015][Trace][418][p7u6j85b] rtc listen at udp://0.0.0.0:8000, fd=9
[1970-01-01 09:36:22.015][Trace][418][404384kk] Hybrid cpu=0.00%,11MB
[1970-01-01 09:36:22.015][Warn][418][03362712][22] use private address as ip: 192.168.142.100, ifname=eno0
[1970-01-01 09:36:22.015][Trace][418][03362712] Startup query id=97fdf2921e2211b2b951253e38a1d56f, eip=192.168.142.100, wait=562s
[1970-01-01 09:36:22.015][Trace][418][0g75y1ua] TCP: connection manager run, conns=0
[1970-01-01 09:36:22.016][Trace][418][97z43td0] UDP #9 LISTEN at 0.0.0.0:8000, SO_SNDBUF(default=212992, expect=10485760, actual=425984, r0=0), SO_RCVBUF(default=212992, expect=10485760, actual=425984, r0=0)
[1970-01-01 09:36:22.016][Trace][418][33v3s691] RTC: connection manager run, conns=0
[1970-01-01 09:36:26.994][Trace][418][404384kk] Hybrid cpu=0.00%,11MB
[1970-01-01 09:36:28.993][Trace][418][00228f89] RTMP client ip=192.168.142.100:41518, fd=10
[1970-01-01 09:36:29.000][Trace][418][00228f89] complex handshake success
[1970-01-01 09:36:29.000][Trace][418][00228f89] connect app, tcUrl=rtmp://192.168.142.100:1935/live/livestream, pageUrl=, swfUrl=, schema=rtmp, vhost=192.168.142.100, port=1935, app=live/livestream, args=null
[1970-01-01 09:36:29.000][Trace][418][00228f89] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[1970-01-01 09:36:29.001][Trace][418][00228f89] client identified, type=fmle-publish, vhost=192.168.142.100, app=live/livestream, stream=2, param=, duration=0ms
[1970-01-01 09:36:29.001][Trace][418][00228f89] connected stream, tcUrl=rtmp://192.168.142.100:1935/live/livestream, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live/livestream, stream=2, param=, args=null
[1970-01-01 09:36:29.001][Trace][418][00228f89] new source, stream_url=/live/livestream/2
[1970-01-01 09:36:29.001][Trace][418][00228f89] source url=/live/livestream/2, ip=192.168.142.100, cache=1, is_edge=0, source_id=/
[1970-01-01 09:36:29.001][Trace][418][00228f89] new source, stream_url=/live/livestream/2
[1970-01-01 09:36:29.007][Trace][418][00228f89] RTC bridge from RTMP, rtmp2rtc=1, keep_bframe=0, merge_nalus=0
[1970-01-01 09:36:29.008][Trace][418][00228f89] ignore disabled exec for vhost=__defaultVhost__
[1970-01-01 09:36:29.008][Trace][418][00228f89] http: mount flv stream for sid=/live/livestream/2, mount=/live/livestream/2.flv
[1970-01-01 09:36:29.008][Trace][418][00228f89] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0
[1970-01-01 09:36:29.008][Trace][418][00228f89] got metadata, width=2560, height=1440, vcodec=7, acodec=10
[1970-01-01 09:36:29.008][Trace][418][00228f89] 44B video sh,  codec(7, profile=Main, level=5, 2560x1440, 0kbps, 0.0fps, 0.0s)
[1970-01-01 09:36:29.008][Trace][418][00228f89] 4B audio sh, codec(10, profile=LC, 1channels, 0kbps, 16000HZ), flv(16bits, 2channels, 44100HZ)

  • Successful streaming and playback, using rtc-player, video is normal, but there is background noise in the audio.
  • Video and audio are normal when using srs-player.
  • Video and audio are normal in the flv files captured by dvr.
  1. The configuration of SRS is as follows (Config):

listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;

http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}

http_api {
    enabled         on;
    listen          1985;
}
stats {
    network         0;
}
rtc_server {
    enabled on;
    listen 8000;
    # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#config-candidate
    candidate $CANDIDATE;
}

vhost __defaultVhost__ {
    dvr {
        enabled      on;
        dvr_path     /disk/[2006]/[01]/[02]-[15].[04].[05].[999].flv;
        dvr_plan     segment;
        dvr_duration    30;
        dvr_wait_keyframe       on;
	#time_jitter             full;
    }
    rtc {
        enabled     on;
        # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#rtmp-to-rtc
        rtmp_to_rtc on;
        # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#rtc-to-rtmp
        rtc_to_rtmp on;
#	keep_bframe on;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
}

Replay

How to replay bug?

Steps to reproduce the bug

  1. ./objs/srs -c rtmp2rtc.conf 2. ffmpeg streaming command: ffmpeg -rtsp_transport tcp -i "rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0" -c copy -f flv -r 25 rtmp://192.168.142.100:1935/live/livestream Logs: ffmpeg version N-104861-g7fe5c7f02d Copyright (c) 2000-2021 the FFmpeg developers built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) configuration: --prefix=. --enable-cross-compile --cross-prefix=aarch64-linux-gnu- --arch=arm64 --target-os=linux --pkg-config-flags=--static --pkg-config=pkg-config --pkgconfigdir=/disk2/nxp/build_def --shlibdir=lib --extra-cflags=-I/disk2/nxp/build_def/include --extra-ldflags=-L/disk2/nxp/build_def/lib --extra-libs='-lpthread -lm' --enable-static --enable-pic --disable-doc --enable-gpl --enable-nonfree --enable-hardcoded-tables --enable-openssl --enable-libaom --enable-libfdk-aac --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvpx --enable-libx264 --enable-libx265 libavutil 57. 11.100 / 57. 11.100 libavcodec 59. 14.100 / 59. 14.100 libavformat 59. 10.100 / 59. 10.100 libavdevice 59. 0.101 / 59. 0.101 libavfilter 8. 20.100 / 8. 20.100 libswscale 6. 1.101 / 6. 1.101 libswresample 4. 0.100 / 4. 0.100 libpostproc 56. 0.100 / 56. 0.100 Input #0, rtsp, from 'rtsp://admin:[email protected]:554/Streaming/Channels/101': Metadata: title : Media Presentation Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 2560x1440, 25 fps, 25 tbr, 90k tbn Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp Output #0, flv, to 'rtmp://192.168.142.100:1935/live/livestream/2': Metadata: title : Media Presentation encoder : Lavf59.10.100 Stream #0:0: Video: h264 (Main) ([7][0][0][0] / 0x0007), yuvj420p(pc, bt709, progressive), 2560x1440, q=2-31, 25 fps, 25 tbr, 1k tbn Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 16000 Hz, mono, fltp Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help [flv @ 0xaaab02445ac0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly [flv @ 0xaaab02445ac0] Failed to update header with correct duration.972.9kbits/s speed=1.08x
    [flv @ 0xaaab02445ac0] Failed to update header with correct filesize. frame= 444 fps= 27 q=-1.0 Lsize= 17304kB time=00:00:17.78 bitrate=7971.0kbits/s speed=1.07x
    video:17230kB audio:60kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.079371% 3. Access the browser at http://192.168.142.100:8080/players/rtc_player.html?autostart=true

Expected behavior (Expect)

> Describe your expectation (Please describe your expectation)

TRANS_BY_GPT3

2653248604 avatar Dec 24 '21 02:12 2653248604

Audio encoding for RTSP:

Audio: aac (LC) ([10][0][0][0] / 0x000A), 16000 Hz, mono, fltp

This encoding and decoding might have some issues with RTC, but there shouldn't be any major problems with RTMP and FLV.

TRANS_BY_GPT3

winlinvip avatar Dec 25 '21 00:12 winlinvip

@2653248604 Can you test the video recorded by your DVR separately using ffmpeg to see if there are any issues? I am unable to test the original stream you provided. I couldn't reproduce the issue when testing with your audio encoding format.

ffmpeg -re -i input.mp4 -acodec aac -ar 16000 -ac 1 -vcodec libx264 -bf 0 -f flv rtmp://127.0.0.1:1935/live/livestream

I can play it normally here.

Stream #0:1(und): Audio: aac (LC) ([10][0][0][0] / 0x000A), 16000 Hz, mono, fltp, 69 kb/s (default)

TRANS_BY_GPT3

Bepartofyou avatar Dec 26 '21 04:12 Bepartofyou

I use the video recorded with DVR to promote, but there is also audio noise.

./ffmpeg -re -i ../01-00.20.44.241.flv -acodec aac -ar 16000 -ac 1 -vcodec copy -f flv rtmp://192.168.142.100:1935/live/livestream

In addition, when I play the recorded video with VLC or Thunder, it is okay. The video recorded with DVR is 27MB and cannot be uploaded. Is there any other way to transfer it to you? Can you check if it works on your end?

I am using the arm64 platform, and both SRS and FFmpeg have been recompiled. However, as far as I understand, RTC uses SRS for internal AAC decoding and then converts it to Opus. FFmpeg seems to only copy the bitstream directly without encoding or decoding it. Compilation command for SRS:

./configure --cross-build \
--cc=aarch64-linux-gnu-gcc --cxx=aarch64-linux-gnu-g++ \
--ar=aarch64-linux-gnu-ar --ld=aarch64-linux-gnu-ld \
--randlib=aarch64-linux-gnu-randlib

FFmpeg compilation command:

PKG_CONFIG_PATH=/disk2/nxp/build_def/lib/pkgconfig ./configure \
--prefix=. \
--enable-cross-compile \
--cross-prefix=aarch64-linux-gnu- \
--arch=arm64 \
--target-os=linux \
--pkg-config-flags="--static" \
--pkg-config=pkg-config \
--pkgconfigdir="/disk2/nxp/build_def" \
--shlibdir=lib \
--extra-cflags="-I/disk2/nxp/build_def/include" \
--extra-ldflags="-L/disk2/nxp/build_def/lib" \
--extra-libs="-lpthread -lm" \
--enable-static \
--enable-pic \
--disable-doc \
--enable-gpl \
--enable-nonfree \
--enable-hardcoded-tables \
--enable-openssl \
--enable-libaom \
--enable-libfdk-aac \
--enable-libopus \
--enable-libsvtav1 \
--enable-libdav1d \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-libvmaf

TRANS_BY_GPT3

2653248604 avatar Dec 26 '21 16:12 2653248604

If there is noise when directly pushing RTMP for the original stream, then it has nothing to do with RTC.

The troubleshooting direction should be to directly record the original stream and take a look.

TRANS_BY_GPT3

winlinvip avatar Dec 27 '21 03:12 winlinvip

No, the experiment I mentioned above refers to re-streaming the captured DVR file. When playing the RTMP stream using VLC or SRS Player, both the audio and video are normal. However, when using RTC Player, there is a problem with the audio. It cannot be heard at all and it feels like there is noise due to mismatched sampling frequencies.

------------------ Original Email ------------------ Sender: "ossrs/srs" @.; Sent: December 27, 2021 (Monday) at 11:18 AM @.>; @.@.>; Subject: Re: [ossrs/srs] RTSP2RTMP2RTC: RTMP and DVR audio are normal, RTC audio has noise (Issue #2810)

If there is noise when directly pushing the original stream to RTMP playback, then it is not related to RTC.

The troubleshooting direction should be to directly record the original stream and take a look.

—' translates to '—' in English. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

TRANS_BY_GPT3

2653248604 avatar Dec 28 '21 09:12 2653248604

In addition, I would like to add that I am also streaming other movie videos (h264+aac) separately, and the phenomenon is the same (rtmp is okay, rtc audio is not okay). The rtsp streams are from Hikvision and Dahua, and their aac audio is mono with a sampling rate of 16000Hz.

TRANS_BY_GPT3

2653248604 avatar Dec 28 '21 11:12 2653248604

@2653248604 Can you provide a download link or a cloud storage link so that I can test your file first and see if it performs the same on a Mac?

TRANS_BY_GPT3

Bepartofyou avatar Jan 04 '22 13:01 Bepartofyou

https://pan.baidu.com/s/1PHyEe2_4iD0JtFbzV_irDQ  Extraction code: bac9

------------------ Original Email ------------------ Sender: "ossrs/srs" @.>; Sent: January 4, 2022 (Tuesday) 9:51 PM @.>; @.@.>; Subject: Re: [ossrs/srs] RTSP2RTMP2RTC: RTMP and DVR have normal sound, RTC has noise (Issue #2810)

@2653248604 Can you provide a download link or something like a cloud storage, so that I can test your file first and see if it performs the same on Mac?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

TRANS_BY_GPT3

2653248604 avatar Jan 05 '22 07:01 2653248604

It seems like a real problem has been encountered, hahaha.

TRANS_BY_GPT3

winlinvip avatar Jan 06 '22 04:01 winlinvip