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

H265: Support HEVC over SRT, RTMP with NVENC and LARIX #3388

Closed johan149 closed 1 year ago

johan149 commented 1 year ago

Description

Streaming HEVC over RTMP, SRT with NVENC and LARIX app doesn't work even tho it's the same codec, and FFprobe detects all the same codec parameters between Libx265 and Hevc_nvenc ad Larix.

  1. SRS Version: SRS/6.0.20 with ./configure --h265=on --srt=on

  2. SRS Log:

[2023-01-23 05:43:10.514][INFO][1][463fft03] Hybrid cpu=1.00%,25MB, cid=2,1, timer=62,0,0, clock=0,47,1,0,0,0,0,0,0, free=1
[2023-01-23 05:43:11.198][INFO][1][905k6971] Process: cpu=1.00%,25MB, threads=2
[2023-01-23 05:43:12.407][INFO][1][530831c6] HTTP #0 172.17.0.1:44760 GET http://127.0.0.1:1985/api/v1/streams/?callback=angular.callbacks._1fk, content-length=-1
[2023-01-23 05:43:12.407][INFO][1][530831c6] TCP: before dispose resource(HttpConn)(0x7f39402b89f0), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-01-23 05:43:12.407][INFO][1][530831c6] client finished.
[2023-01-23 05:43:12.407][INFO][1][086445j5] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2023-01-23 05:43:12.407][INFO][1][530831c6] TCP: disposing #0 resource(HttpConn)(0x7f39402b89f0), conns=1, disposing=1, zombies=0
[2023-01-23 05:43:15.515][INFO][1][463fft03] Hybrid cpu=1.00%,25MB, cid=1,1, timer=62,0,0, clock=0,47,1,0,0,0,0,0,0, free=1
[2023-01-23 05:43:16.203][INFO][1][905k6971] Process: cpu=0.00%,25MB, threads=2
[2023-01-23 05:43:16.398][INFO][1][66259ie8] HTTP #0 172.17.0.1:58326 GET http://127.0.0.1:1985/api/v1/streams/?callback=angular.callbacks._1fl, content-length=-1
[2023-01-23 05:43:16.398][INFO][1][66259ie8] TCP: before dispose resource(HttpConn)(0x7f39402fec40), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-01-23 05:43:16.398][INFO][1][66259ie8] client finished.
[2023-01-23 05:43:16.398][INFO][1][086445j5] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2023-01-23 05:43:16.398][INFO][1][66259ie8] TCP: disposing #0 resource(HttpConn)(0x7f39402fec40), conns=1, disposing=1, zombies=0
[2023-01-23 05:43:19.405][WARN][1][][11][SRT] /srs/objs/Platform-SRS6-Linux-5.4.0-GCC4.8.5-x86_64/srt-1-fit/srtcore/core.cpp:2156(processSrtMsg_HSREQ) # : HSREQ/rcv: Agent did not set rcv-TSBPD - ignoring proposed latency from peer
[2023-01-23 05:43:19.413][ERROR][1][020f334a][11][SRT] /srs/objs/Platform-SRS6-Linux-5.4.0-GCC4.8.5-x86_64/srt-1-fit/srtcore/api.cpp:1116(accept) # : srt_accept: no pending connection available at the moment(Resource temporarily unavailable)
[2023-01-23 05:43:19.413][INFO][1][359qs871] SRT client ip=47.41.194.198:41441, fd=395446114
[2023-01-23 05:43:19.413][INFO][1][359qs871] @srt, streamid=#!::r=live/srt_hevc_nvenc,m=publish?pkt_size=1316, stream_url=/live/srt_hevc_nvenc, vhost=__defaultVhost__, app=live, stream=srt_hevc_nvenc, param=pkt_size=1316
[2023-01-23 05:43:19.413][INFO][1][359qs871] new srt source, stream_url=/live/srt_hevc_nvenc
[2023-01-23 05:43:19.413][INFO][1][359qs871] new live source, stream_url=/live/srt_hevc_nvenc
[2023-01-23 05:43:19.414][INFO][1][359qs871] hls: win=60000ms, frag=10000ms, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1, dispose=0ms, dts_directly=1
[2023-01-23 05:43:19.414][INFO][1][359qs871] ignore disabled exec for vhost=__defaultVhost__
[2023-01-23 05:43:19.414][INFO][1][359qs871] http: mount flv stream for sid=/live/srt_hevc_nvenc, mount=/live/srt_hevc_nvenc.ts
[2023-01-23 05:43:19.601][INFO][1][359qs871] 4B audio sh, codec(10, profile=LC, 2channels, 0kbps, 44100HZ), flv(16bits, 2channels, 44100HZ)
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] VIDEO: Timestamp 1446=>1423, may need mix_correct.
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4054(CasterTsHevcVps)(Invalid ts HEVC VPS for stream caster) : ts: handle ts message : ts: consume hevc video : check vps sps pps : srt to rtmp sps/pps : format consume video : demux hevc SPS/PPS : hevc demux vps sps pps failed : scaling_list_delta_coef : read uev : no bytes for leadingZeroBits=3
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:273][errno=11]
thread [1][359qs871]: on_ts_message() [./src/app/srs_app_srt_source.cpp:364][errno=11]
thread [1][359qs871]: on_ts_video_hevc() [./src/app/srs_app_srt_source.cpp:607][errno=11]
thread [1][359qs871]: check_vps_sps_pps_change() [./src/app/srs_app_srt_source.cpp:654][errno=11]
thread [1][359qs871]: on_video_imp() [./src/app/srs_app_source.cpp:2437][errno=11]
thread [1][359qs871]: video_avc_demux() [./src/kernel/srs_kernel_codec.cpp:896][errno=11]
thread [1][359qs871]: hevc_demux_hvcc() [./src/kernel/srs_kernel_codec.cpp:1050][errno=11]
thread [1][359qs871]: hevc_demux_pps_rbsp() [./src/kernel/srs_kernel_codec.cpp:1698][errno=11]
thread [1][359qs871]: read_bits_se() [./src/kernel/srs_kernel_buffer.cpp:511][errno=11]
thread [1][359qs871]: read_bits_ue() [./src/kernel/srs_kernel_buffer.cpp:489][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=3
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=4
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=5
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=6
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=7
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=8
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=9
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=10
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=11
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=12
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=13
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=14
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=15
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.614][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=0
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.636][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=1
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.636][WARN][1][359qs871][11] parse ts packet err=code=4019(CasterTsPse)(Invalid ts PSE payload for stream caster) : ts: ts packet decode : ts: demux payload : ts: PES fresh packet length=0, us=0, cc=2
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:264][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:629][errno=11]
thread [1][359qs871]: decode() [./src/kernel/srs_kernel_ts.cpp:1955][errno=11]
[2023-01-23 05:43:19.680][INFO][1][359qs871] HLS: Switch video codec 10(H264) to 12(HEVC)
[2023-01-23 05:43:19.680][INFO][1][359qs871] TS: Refresh PMT when vcodec=7=>12, acodec=10=>10
[2023-01-23 05:43:20.404][INFO][1][v8j67h46] HTTP #0 172.17.0.1:58330 GET http://127.0.0.1:1985/api/v1/streams/?callback=angular.callbacks._1fm, content-length=-1
[2023-01-23 05:43:20.405][INFO][1][v8j67h46] TCP: before dispose resource(HttpConn)(0x7f39402f09c0), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-01-23 05:43:20.405][INFO][1][v8j67h46] client finished.
[2023-01-23 05:43:20.405][INFO][1][086445j5] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2023-01-23 05:43:20.405][INFO][1][v8j67h46] TCP: disposing #0 resource(HttpConn)(0x7f39402f09c0), conns=1, disposing=1, zombies=0
[2023-01-23 05:43:20.515][INFO][1][463fft03] Hybrid cpu=1.00%,27MB, cid=1,1, timer=62,0,0, clock=0,47,1,0,0,0,0,0,0, free=1
[2023-01-23 05:43:21.208][INFO][1][905k6971] Process: cpu=3.00%,27MB, threads=2
[2023-01-23 05:43:22.508][INFO][1][359qs871] <- SRT_CPB Transport Stats # pktRecv=1405, pktRcvLoss=0, pktRcvRetrans=0, pktRcvDrop=0
[2023-01-23 05:43:22.509][INFO][1][359qs871] <- SRT_CPB time=3101, packets=1390, okbps=0,0,0, ikbps=0,0,0
[2023-01-23 05:43:24.401][INFO][1][40518xiz] HTTP #0 172.17.0.1:42352 GET http://127.0.0.1:1985/api/v1/streams/?callback=angular.callbacks._1fn, content-length=-1
[2023-01-23 05:43:24.401][INFO][1][40518xiz] TCP: before dispose resource(HttpConn)(0x7f394028dc70), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-01-23 05:43:24.401][INFO][1][40518xiz] client finished.
[2023-01-23 05:43:24.401][INFO][1][086445j5] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2023-01-23 05:43:24.401][INFO][1][40518xiz] TCP: disposing #0 resource(HttpConn)(0x7f394028dc70), conns=1, disposing=1, zombies=0
[2023-01-23 05:43:25.516][INFO][1][463fft03] Hybrid cpu=2.00%,27MB, cid=1,1, timer=62,0,0, clock=0,47,1,0,0,0,0,0,0, free=1
[2023-01-23 05:43:26.214][INFO][1][905k6971] Process: cpu=2.00%,27MB, threads=2
[2023-01-23 05:43:28.395][INFO][1][65437863] HTTP #0 172.17.0.1:42356 GET http://127.0.0.1:1985/api/v1/streams/?callback=angular.callbacks._1fo, content-length=-1
[2023-01-23 05:43:28.395][INFO][1][65437863] TCP: before dispose resource(HttpConn)(0x7f39402f1250), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-01-23 05:43:28.395][INFO][1][65437863] client finished.
[2023-01-23 05:43:28.395][INFO][1][086445j5] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2023-01-23 05:43:28.395][INFO][1][65437863] TCP: disposing #0 resource(HttpConn)(0x7f39402f1250), conns=1, disposing=1, zombies=0
[2023-01-23 05:43:30.516][INFO][1][463fft03] Hybrid cpu=2.00%,27MB, cid=9,2, timer=62,0,0, clock=0,45,2,0,0,0,0,0,0, free=1, objs=(pkt:0,raw:0,fua:0,msg:505,oth:0,buf:0)
[2023-01-23 05:43:31.217][INFO][1][905k6971] Process: cpu=2.00%,27MB, threads=2
[2023-01-23 05:43:32.398][INFO][1][6326iu3e] HTTP #0 172.17.0.1:42360 GET http://127.0.0.1:1985/api/v1/streams/?callback=angular.callbacks._1fp, content-length=-1
[2023-01-23 05:43:32.398][INFO][1][6326iu3e] TCP: before dispose resource(HttpConn)(0x7f3940296cd0), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-01-23 05:43:32.398][INFO][1][6326iu3e] client finished.
[2023-01-23 05:43:32.398][INFO][1][086445j5] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2023-01-23 05:43:32.398][INFO][1][6326iu3e] TCP: disposing #0 resource(HttpConn)(0x7f3940296cd0), conns=1, disposing=1, zombies=0
[2023-01-23 05:43:32.546][INFO][1][359qs871] <- SRT_CPB Transport Stats # pktRecv=4765, pktRcvLoss=0, pktRcvRetrans=0, pktRcvDrop=0
[2023-01-23 05:43:32.546][INFO][1][359qs871] <- SRT_CPB time=13133, packets=4765, okbps=0,0,0, ikbps=0,0,0
[2023-01-23 05:43:32.547][INFO][1][359qs871] -> HLS time=13133079ms, sno=1, ts=srt_hevc_nvenc-0.ts, dur=12956ms, dva=0p
[2023-01-23 05:43:35.517][INFO][1][463fft03] Hybrid cpu=3.00%,27MB, cid=9,2, timer=62,0,0, clock=0,45,2,0,0,0,0,0,0, free=1, objs=(pkt:0,raw:0,fua:0,msg:505,oth:0,buf:0)
[2023-01-23 05:43:36.221][INFO][1][905k6971] Process: cpu=2.00%,27MB, threads=2
[2023-01-23 05:43:36.404][INFO][1][8n0v451p] HTTP #0 172.17.0.1:37558 GET http://127.0.0.1:1985/api/v1/streams/?callback=angular.callbacks._1fq, content-length=-1
[2023-01-23 05:43:36.404][INFO][1][8n0v451p] TCP: before dispose resource(HttpConn)(0x7f3940294f90), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-01-23 05:43:36.404][INFO][1][8n0v451p] client finished.
[2023-01-23 05:43:36.404][INFO][1][086445j5] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2023-01-23 05:43:36.404][INFO][1][8n0v451p] TCP: disposing #0 resource(HttpConn)(0x7f3940294f90), conns=1, disposing=1, zombies=0
[2023-01-23 05:43:40.405][INFO][1][5g0tuysg] HTTP #0 172.17.0.1:37562 GET http://127.0.0.1:1985/api/v1/streams/?callback=angular.callbacks._1fr, content-length=-1
[2023-01-23 05:43:40.405][INFO][1][5g0tuysg] TCP: before dispose resource(HttpConn)(0x7f39402bb900), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-01-23 05:43:40.405][INFO][1][5g0tuysg] client finished.
[2023-01-23 05:43:40.405][INFO][1][086445j5] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2023-01-23 05:43:40.405][INFO][1][5g0tuysg] TCP: disposing #0 resource(HttpConn)(0x7f39402bb900), conns=1, disposing=1, zombies=0
[2023-01-23 05:43:40.517][INFO][1][463fft03] Hybrid cpu=2.00%,27MB, cid=3,2, timer=62,0,0, clock=0,44,3,0,0,0,0,0,0, free=1, objs=(pkt:0,raw:0,fua:0,msg:695,oth:0,buf:0)
  1. 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;
    }

    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }

    hls {
        enabled         on;
        hls_path        ./objs/nginx/html;
        hls_fragment    10;
        hls_window      60;
    }
}

Replay

Step 1: Clone and build SRS DEV docker

cd ~

rm -r ~/srs

git clone https://github.com/ossrs/srs.git

cd ~/srs/trunk/conf
nano srt_h265.conf

# paste config flags, save, and exit

cd ~/srs/trunk &&
docker run -it --rm -v `pwd`:/srs -w /srs ossrs/srs:dev \
    bash -c "./configure --h265=on --srt=on && make"

cd ~/srs/trunk &&
CID=$(docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 -p 8085:8085 -p 10080:10080/udp\
    --env CANDIDATE=$(wget -qO- ifconfig.me | xargs echo) -p 8000:8000/udp \
     -it -d --rm -v `pwd`:/srs -w /srs ossrs/srs:dev \
    ./objs/srs -c conf/srt_h265.conf)

docker logs $CID -f

Step 2: WORKS - FFmpeg libx265 - start streaming with ffmpeg using libx265 works

ffmpeg -v debug -re -stream_loop -1 -probesize 5000000 -analyzeduration 0 -fflags genpts+flush_packets -f lavfi -i "testsrc=duration=65536:size=1920x1080:rate=30" -f lavfi -i "sine=frequency=1000:sample_rate=48000:duration=65536" -vcodec libx265 -b:v 5M -minrate:v 3M -maxrate:v 5M -bufsize:v 10M -pix_fmt yuv420p -c:a aac -strict -2 -ac 2 -ar 44100 -pkt_size 1316 -flush_packets 0 -f mpegts -pes_payload_size 0 -muxrate 5M 'srt://localhost:10080?streamid=#!::r=live/srt_hevc_libx265,m=publish?pkt_size=1316&transtype=live&latency=120'

Step 3: DOESN'T WORK - FFmpeg nvenc - start streaming with ffmpeg using hevc_nvenc and check the logs on SRS server.

ffmpeg -v debug -re -stream_loop -1 -probesize 5000000 -analyzeduration 0 -fflags genpts+flush_packets -f lavfi -i "testsrc=duration=65536:size=1920x1080:rate=30" -f lavfi -i "sine=frequency=1000:sample_rate=48000:duration=65536" -c:v hevc_nvenc -preset p1 -profile main -level 4.0 -b:v 5M -minrate:v 3M -maxrate:v 5M -bufsize:v 10M -pix_fmt yuv420p -c:a aac -strict -2 -ac 2 -ar 44100 -pkt_size 1316 -flush_packets 0 -f mpegts -pes_payload_size 0 -muxrate 5M 'srt://localhost:10080?streamid=#!::r=live/srt_hevc_nvenc,m=publish?pkt_size=1316&transtype=live&latency=120'

Step 4: DOESN'T WORK - Larix hevc - start streaming with Larix broadcaster app doesn't work

  1. Download the Larix broadcaster app on Google Play or App Store

  2. Import Larix grove stream settings

    • Go to Settings gear icon
    • Select Larix Grove
    • Select Import Grove setting
    • Paste the following command and change the "srs_server_ip" for your SRS IP.
      larix://set/v1?conn[][url]=srt%3A%2F%2Fsrs_server_ip%3A10080&conn[][name]=srt_hevc_larix&conn[][mode]=av&conn[][srtlatency]=120&conn[][srtstreamid]=%23!%3A%3Ar%3Dlive%2Fsrt_hevc_nvenc%2Cm%3Dpublish&conn[][overwrite]=on&enc[vid][res]=1920x1080&enc[vid][fps]=30&enc[vid][background]=on&enc[vid][format]=hevc&deleteConn=1
    • Make sure the connection was added correctly, go to settings --> and select connections ----> select "srt_hevc_larix" and make sure the proper SRS SRT IP and PORT were added correctly.
    • Then start the stream and check the logs on SRS server. image

Expect

All three ways to stream should work since they use the same HEVC codec and the same or similar encoding settings like level, profile, bitrate, etc.

chundonglinlin commented 1 year ago

@johan149 Can you use this #3389 to go? I used your method to test that the publish(SRT or RTMP) stream could pass.

limjoe commented 1 year ago

build the latest code, publish HEVC over RTMP still not work, logs as below

[2023-01-30 07:46:52.562][ERROR][13][4z3nbb43][11] serve error code=4054(CasterTsHevcVps)(Invalid ts HEVC VPS for stream caster) : service cycle : rtmp: stream service : rtmp: receive thread : handle publish message : rtmp: consume message : rtmp: consume video : format consume video : demux hevc SPS/PPS : hevc demux vps sps pps failed : scaling_list_delta_coef : read uev : no bytes for leadingZeroBits=5
thread [13][4z3nbb43]: do_cycle() [./src/app/srs_app_rtmp_conn.cpp:262][errno=11]
thread [13][4z3nbb43]: service_cycle() [./src/app/srs_app_rtmp_conn.cpp:456][errno=11]
thread [13][4z3nbb43]: do_publishing() [./src/app/srs_app_rtmp_conn.cpp:1024][errno=11]
thread [13][4z3nbb43]: consume() [./src/app/srs_app_recv_thread.cpp:380][errno=11]
thread [13][4z3nbb43]: handle_publish_message() [./src/app/srs_app_rtmp_conn.cpp:1161][errno=11]
thread [13][4z3nbb43]: process_publish_message() [./src/app/srs_app_rtmp_conn.cpp:1189][errno=11]
thread [13][4z3nbb43]: on_video_imp() [./src/app/srs_app_source.cpp:2437][errno=11]
thread [13][4z3nbb43]: video_avc_demux() [./src/kernel/srs_kernel_codec.cpp:896][errno=11]
thread [13][4z3nbb43]: hevc_demux_hvcc() [./src/kernel/srs_kernel_codec.cpp:1050][errno=11]
thread [13][4z3nbb43]: hevc_demux_pps_rbsp() [./src/kernel/srs_kernel_codec.cpp:1701][errno=11]
thread [13][4z3nbb43]: read_bits_se() [./src/kernel/srs_kernel_buffer.cpp:511][errno=11]
thread [13][4z3nbb43]: read_bits_ue() [./src/kernel/srs_kernel_buffer.cpp:489][errno=11](Resource temporarily unavailable)
chundonglinlin commented 1 year ago

Yeah, this PR(#3389) still not merge to develop. Can you use my branch chundonglinlin:bugfix/fix-demux-codec-pps-error for test? @limjoe

limjoe commented 1 year ago

@chundonglinlin Your PR(#3389) works