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.48k stars 5.36k forks source link

Trancode/transmux SRT stream using ffmpeg not working, but transcode/transmux RTMP stream working. #3342

Open bandirsen opened 1 year ago

bandirsen commented 1 year ago

Description

I'm using obs to publish content to srs through SRT protocol I want to transmux/transcode the SRT stream using ffmpeg

1. SRS Version: 5

2. SRS Log:

Attaching to srs
srs  | [2022-12-27 14:09:51.200][INFO][1][7ql1q44j] XCORE-SRS/5.0.98(Bee)
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] config parse complete
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] write log to console
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] SRS/5.0.98(Bee), MIT
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] authors: Winlin<winlin@vip.126.com> ZhaoWenjie<zhaowenjie@tal.com> ShiWei<shiwei05@kuaishou.com> XiaoZhihong<hondaxiao@tencent.com> WuPengqiang<pengqiang.wpq@alibaba-inc.com> XiaLixin<xialixin@kanzhun.com> LiPeng<mozhan.lp@alibaba-inc.com> ChenGuanghua<jinxue.cgh@alibaba-inc.com> ChenHaibo<nmgchenhaibo@foxmail.com> Johzzy<hellojinqiang@gmail.com> Zhouxiaojun2008<279686030@qq.com> Pengfei.ma<pengfei.ma.chn@outlook.com> ZhangJunqin<zhangjunqin@jd.com> and https://github.com/ossrs/srs/blob/develop/trunk/AUTHORS.md#contributors
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] cwd=/usr/local/srs, work_dir=./, build: 2022-11-25 05:46:54, configure: --gb28181=on --sanitizer-static=on, uname: Linux buildkitsandbox 5.15.0-1023-azure #29~20.04.1-Ubuntu SMP Wed Oct 26 19:18:25 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux, osx: 0, env: 0, pkg: dcis
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] configure detail: --prefix=/usr/local/srs --config=conf/srs.conf --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-converter=on --http-api=on --utest=off --cherrypy=off --srt=on --rtc=on --gb28181=on --simulator=off --cxx11=on --cxx14=off --backtrace=on --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 --log-level_v2=on --gcov=off --debug=off --debug-stats=off --cross-build=off --sanitizer=on --cygwin64=off --single-thread=off --cc=gcc --cxx=g++ --ar=ar --ld=ld --randlib=randlib
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] srs checking config...
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] ips, iface[0] eth0 ipv4 0x11043 172.150.0.10
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] devices, internet eth0 172.150.0.10
srs  | [2022-12-27 14:09:51.201][WARN][1][7ql1q44j][2] stats network use index=0, ip=172.150.0.10, ifname=eth0
srs  | [2022-12-27 14:09:51.201][WARN][1][7ql1q44j][2] stats disk not configed, disk iops disabled.
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] write log to console
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] features, rch:on, dash:on, hls:on, hds:off, srt:on, hc:on, ha:on, hs:on, hp:on, dvr:on, trans:on, inge:on, stat:on, sc:on
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] SRS on amd64 x86_64, conf:conf/docker.conf, limit:1000, writev:1024, encoding:little-endian, HZ:100
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] mw sleep:350ms. mr enabled:on, default:0, sleep:350ms
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] gc:on, pq:30000ms, cscc:[0,16), csa:on, tn:on(may hurts performance), ss:auto(guess by merged write)
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] system default latency(ms): mw(0-350) + mr(0-350) + play-queue(0-30000)
srs  | [2022-12-27 14:09:51.201][WARN][1][7ql1q44j][2] SRS/5.0.98 is not stable
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] write pid=1 to ./objs/srs.pid success!
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] Thread #1(primordial): init name=srs-master-1, interval=5000ms
srs  | [2022-12-27 14:09:51.201][INFO][1][7ql1q44j] Pool: Start threads primordial=1, hybrids=1 ok
srs  | [2022-12-27 14:09:51.201][INFO][1][1p218393] Thread #2: run with tid=7, entry=0x60c000000400, label=hybrid, name=srs-hybrid-2
srs  | [2022-12-27 14:09:51.205][INFO][1][1p218393] TencentCloud CLS is disabled
srs  | [2022-12-27 14:09:51.205][INFO][1][1p218393] TencentCloud APM is disabled
srs  | [2022-12-27 14:09:51.208][INFO][1][1p218393] fingerprint=D5:EF:B1:D3:D8:38:B8:2F:88:B7:9A:38:DC:3C:C5:0E:71:73:5D:66:B3:01:31:67:69:32:F7:4F:01:48:CB:9A
srs  | [2022-12-27 14:09:51.208][INFO][1][1p218393] CircuitBreaker: enabled=1, high=2x90, critical=1x95, dying=5x99
srs  | [2022-12-27 14:09:51.208][INFO][1][1p218393] http: root mount to ./objs/nginx/html
srs  | [2022-12-27 14:09:51.208][INFO][1][1p218393] server main cid=1p218393, pid=1, ppid=0, asprocess=0
srs  | [2022-12-27 14:09:51.208][INFO][1][1p218393] RTMP listen at tcp://0.0.0.0:1935, fd=9
srs  | [2022-12-27 14:09:51.208][INFO][1][1p218393] HTTP-API listen at tcp://0.0.0.0:1985, fd=10
srs  | [2022-12-27 14:09:51.208][INFO][1][1p218393] HTTP-Server listen at tcp://0.0.0.0:8080, fd=11
srs  | [2022-12-27 14:09:51.208][INFO][1][1p218393] signal installed, reload=1, reopen=10, fast_quit=15, grace_quit=3
srs  | [2022-12-27 14:09:51.209][INFO][1][1p218393] http: api mount /console to ./objs/nginx/html/console
srs  | [2022-12-27 14:09:51.209][INFO][1][1p218393] srt listen at udp://0.0.0.0:10080, fd=398793399
srs  | [2022-12-27 14:09:51.210][INFO][1][s45o275i] Hybrid cpu=0.00%,38MB
srs  | [2022-12-27 14:09:51.210][WARN][1][1703t85n][22] use public address as ip: 172.150.0.10, ifname=eth0
srs  | [2022-12-27 14:09:51.210][INFO][1][1703t85n] Startup query id=vid-0dfb67i, session=vid-840u953, eip=172.150.0.10, wait=300s
srs  | [2022-12-27 14:09:51.210][INFO][1][5sbo73hb] TCP: connection manager run, conns=0
srs  | [2022-12-27 14:09:51.210][INFO][1][190993mq] GB: connection manager run, conns=0
srs  | [2022-12-27 14:09:51.210][INFO][1][5230302v] SRT: connection manager run, conns=0
srs  | [2022-12-27 14:09:51.210][INFO][1][822iv757] RTC: connection manager run, conns=0
srs  | [2022-12-27 14:09:56.202][INFO][1][s45o275i] Hybrid cpu=1.00%,38MB
srs  | [2022-12-27 14:09:56.206][INFO][1][7ql1q44j] Process: cpu=0.00%,38MB, threads=2
srs  | [2022-12-27 14:10:01.203][INFO][1][s45o275i] Hybrid cpu=0.00%,38MB
srs  | [2022-12-27 14:10:01.211][INFO][1][7ql1q44j] Process: cpu=0.00%,38MB, threads=2
srs  | [2022-12-27 14:10:06.204][INFO][1][s45o275i] Hybrid cpu=1.00%,39MB, cid=1,1, timer=63,0,0, clock=1,48,1,0,0,0,0,0,0
srs  | [2022-12-27 14:10:06.215][INFO][1][7ql1q44j] Process: cpu=0.00%,39MB, threads=2
srs  | [2022-12-27 14:10:11.205][INFO][1][s45o275i] Hybrid cpu=0.00%,39MB, cid=1,1, timer=63,0,0, clock=1,48,1,0,0,0,0,0,0
srs  | [2022-12-27 14:10:11.220][INFO][1][7ql1q44j] Process: cpu=0.00%,39MB, threads=2

3. SRS Config:

# SRT config.

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

http_api {
    enabled         on;
    listen          1985;
}

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

srt_server {
    enabled on;
    listen 10080;
    maxbw 1000000000;
    connect_timeout 4000;
    peerlatency 0;
    recvlatency 0;
    latency 0;
    tsbpdmode off;
    tlpktdrop off;
    sendbuf 2000000;
    recvbuf 2000000;
}

# @doc https://github.com/ossrs/srs/issues/1147#issuecomment-577607026
vhost __defaultVhost__ {
    srt {
        enabled     on;
        srt_to_rtmp on;
    }

    transcode {
        enabled     on;
        ffmpeg      ./objs/ffmpeg/bin/ffmpeg;
        engine ff {
            enabled on;
            iformat mpegts;
            vcodec  copy;
            acodec  copy;
            oformat dash;
            output ./objs/nginx/dash/test.mpd;
        }
    }
}

Replay:

Please describe how to replay the bug? (重现Bug的步骤)

Step 1: run srs v.5 docker (no problem) Step 2: publish live stream using obs to srs through SRT protocol (no problem) Step 3: check generated dash files inside srs docker container Step 4: if i publish from obs using RTMP protocol, it's working fine, dash files are generated but I if use SRT protocol, nothing happen, it seems SRT protocol not triggering ffmpeg transcoding process

Expect (Expected Behavior) I expecting SRT input stream to srs also triggering ffmpeg transcoding/transmuxing, because like RTMP, SRT also supported by both srs and ffmpeg

TRANS_BY_GPT3

winlinvip commented 1 year ago

The log shows that there is no stream. Please attach the correct log.

xiaozhihong commented 1 year ago

@bandirsen You should change the conf iformat mpegts to iformat flv. Because the ffmpeg command line is runing in rtmp source, when publish by srt and enable srt_to_rtmp, srs will remux mpegts (in srt) to rtmp.