[Feature] srt_to_rtmp fails if stream contains scte-35 stream
Opened this issue · 6 comments
Describe the bug
I have an srt stream that containers scte-35 markings for ad mid-roll insertion.
Stream #0:0[0x101]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn
Stream #0:1[0x102]: Audio: aac_latm (LC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Stream #0:2[0x119]: Data: scte_35
I'd like to convert them to rtmp and forward to other srs for processing. But apparently I can't use RTMP when there's this data stream present.
Version
7.0.95
To Reproduce
I can provide a 30s mpegts file that contains this stream, if you want.
Here's a tsanalyze (from tsduck) on this stream:
===============================================================================
| TRANSPORT STREAM ANALYSIS REPORT |
|=============================================================================|
| Transport Stream Id: .......... 0x0001 (1) | Services: .............. 1 |
| Bytes: ........................ 47,982,676 | PID's: Total: .......... 7 |
| TS packets: ...................... 255,227 | Clear: .......... 7 |
| With invalid sync: .................. 0 | Scrambled: ...... 0 |
| With transport error: ............... 0 | With PCR's: ..... 1 |
| Suspect and ignored: ................ 0 | Unreferenced: ... 0 |
|-----------------------------------------------------------------------------|
| Transport stream bitrate, based on ....... 188 bytes/pkt 204 bytes/pkt |
| User-specified: ................................... None None |
| Estimated based on PCR's: ............... 10,200,000 b/s 11,068,085 b/s |
| Selected reference bitrate: ............. 10,200,000 b/s 11,068,085 b/s |
|-----------------------------------------------------------------------------|
| Broadcast time: ................................... 37 sec (0 min 37 sec) |
|-----------------------------------------------------------------------------|
| Srv Id Service Name Access Bitrate |
| 0x0001 XXXXX ........................................ C 9,489,992 b/s |
| |
| Note 1: C=Clear, S=Scrambled |
| Note 2: Unless specified otherwise, bitrates are based on 188 bytes/pkt |
===============================================================================
===============================================================================
| SERVICES ANALYSIS REPORT |
|=============================================================================|
| Global PID's |
| TS packets: 17,766, PID's: 3 (clear: 3, scrambled: 0) |
|-----------------------------------------------------------------------------|
| PID Usage Access Bitrate |
| Total Global PID's ................................. C 710,008 b/s |
| Subt. Global PSI/SI PID's (0x00-0x1F) .............. C 18,024 b/s |
| 0x0000 PAT .......................................... C 15,027 b/s |
| 0x0011 SDT/BAT ...................................... C 2,997 b/s |
| 0x1FFF Stuffing ..................................... C 691,984 b/s |
|=============================================================================|
| Service: 0x0001 (1), TS: 0x0001 (1), Original Netw: 0xFF01 (65281) |
| Service name: XXXX, provider: XXXX |
| Service type: 0x01 (Digital television service) |
| TS packets: 237,461, PID's: 5 (clear: 5, scrambled: 0) |
| PMT PID: 0x0106 (262), PCR PID: 0x0107 (263) |
|-----------------------------------------------------------------------------|
| PID Usage Access Bitrate |
| Total Digital television service ................... C 9,489,992 b/s |
| 0x0101 AVC video (1920x1080, main profile, level 4.0 C 9,362,346 b/s |
| 0x0102 MPEG-4 AAC Audio ............................. C 74,973 b/s |
| 0x0106 PMT .......................................... C 15,027 b/s |
| 0x0107 PCR (not otherwise referenced) ............... C 37,646 b/s |
| 0x0119 SCTE 35 Splice Info .......................... C 0 b/s |
| (C=Clear, S=Scrambled, +=Shared) |
===============================================================================
===============================================================================
| PIDS ANALYSIS REPORT |
|=============================================================================|
| PID: 0x0000 (0) PAT |
|-----------------------------------------------------------------------------|
| Global PID Transport: Discontinuities: |
| Bitrate: .... 15,027 b/s Packets: ........... 376 Expected: ......... 0 |
| Access: .......... Clear Adapt.F.: ............ 0 Unexpect: ......... 0 |
| Duplicated: .......... 0 Sections: |
| Unit start: ..... 376 |
|=============================================================================|
| PID: 0x0011 (17) SDT/BAT |
|-----------------------------------------------------------------------------|
| Global PID Transport: Discontinuities: |
| Bitrate: ..... 2,997 b/s Packets: ............ 75 Expected: ......... 0 |
| Access: .......... Clear Adapt.F.: ............ 0 Unexpect: ......... 0 |
| Duplicated: .......... 0 Sections: |
| Unit start: ...... 75 |
|=============================================================================|
| PID: 0x0101 (257) AVC video |
| PES stream id: 0xE0 (Video 0) |
| 1920x1080, main profile, level 4.0, 4:2:0 |
| Service: 0x0001 (1) XXXX |
|-----------------------------------------------------------------------------|
| Single Service PID Transport: Discontinuities: |
| Bitrate: . 9,362,346 b/s Packets: ....... 234,267 Expected: ......... 0 |
| Access: .......... Clear Adapt.F.: ........ 1,139 Unexpect: ......... 0 |
| Duplicated: .......... 0 PES: |
| Packets: ...... 1,130 |
| Inv.Start: ........ 0 |
| Clock values range: |
| PTS: ............. 1,130 DTS: ............ 396 |
| from ........ 97,065,933 from ..... 97,068,936 |
| to ......... 100,465,329 to ...... 100,456,320 |
| Leaps: ............... 0 Leaps: ............ 0 |
|=============================================================================|
| PID: 0x0102 (258) MPEG-4 AAC Audio |
| PES stream id: 0xC0 (Audio 0) |
| Service: 0x0001 (1) XXXX |
|-----------------------------------------------------------------------------|
| Single Service PID Transport: Discontinuities: |
| Bitrate: .... 74,973 b/s Packets: ......... 1,876 Expected: ......... 0 |
| Access: .......... Clear Adapt.F.: .......... 700 Unexpect: ......... 0 |
| Duplicated: .......... 0 PES: |
| Packets: ........ 353 |
| Inv.Start: ........ 0 |
| Clock values range: |
| PTS: ............... 353 |
| from ........ 97,062,232 |
| to ......... 100,441,351 |
| Leaps: ............... 0 |
|=============================================================================|
| PID: 0x0106 (262) PMT |
| Service: 0x0001 (1) XXXX |
|-----------------------------------------------------------------------------|
| Single Service PID Transport: Discontinuities: |
| Bitrate: .... 15,027 b/s Packets: ........... 376 Expected: ......... 0 |
| Access: .......... Clear Adapt.F.: ............ 0 Unexpect: ......... 0 |
| Duplicated: .......... 0 Sections: |
| Unit start: ..... 376 |
|=============================================================================|
| PID: 0x0107 (263) PCR (not otherwise referenced) |
| Service: 0x0001 (1) XXXX |
|-----------------------------------------------------------------------------|
| Single Service PID Transport: Discontinuities: |
| Bitrate: .... 37,646 b/s Packets: ........... 942 Expected: ......... 0 |
| Access: .......... Clear Adapt.F.: .......... 942 Unexpect: ......... 0 |
| Duplicated: .......... 0 Sections: |
| TSrate: . 10,200,000 b/s Unit start: ....... 0 |
| |
| Clock values range: |
| PCR: ............... 942 |
| from .... 29,116,228,384 |
| to ...... 30,131,472,176 |
| Leaps: ............... 0 |
|=============================================================================|
| PID: 0x1FFF (8191) Stuffing |
|-----------------------------------------------------------------------------|
| Global PID Transport: Discontinuities: |
| Bitrate: ... 691,984 b/s Packets: ........ 17,315 Expected: ......... 0 |
| Access: .......... Clear Adapt.F.: ............ 0 Unexpect: ......... 0 |
| Duplicated: .......... 0 Sections: |
| Unit start: ....... 0 |
===============================================================================
===============================================================================
| TABLES & SECTIONS ANALYSIS REPORT |
|=============================================================================|
| PID: 0x0000 (0) PAT |
|-----------------------------------------------------------------------------|
| 0x00 (0, PAT), TID ext: 0x0001 (1) |
| Repetition: ..... 100 ms Section cnt: ...... 376 |
| Min repet.: ..... 100 ms Table cnt: ........ 376 |
| Max repet.: ..... 100 ms Version: ............ 0 |
|=============================================================================|
| PID: 0x0011 (17) SDT/BAT |
|-----------------------------------------------------------------------------|
| 0x42 (66, SDT Actual), TID ext: 0x0001 (1) |
| Repetition: ..... 500 ms Section cnt: ....... 75 |
| Min repet.: ..... 500 ms Table cnt: ......... 75 |
| Max repet.: ..... 500 ms Version: ............ 0 |
|=============================================================================|
| PID: 0x0106 (262) PMT |
| Service: 0x0001 (1) XXXX |
|-----------------------------------------------------------------------------|
| 0x02 (2, PMT), TID ext: 0x0001 (1) |
| Repetition: ..... 100 ms Section cnt: ...... 376 |
| Min repet.: ..... 100 ms Table cnt: ........ 376 |
| Max repet.: ..... 100 ms Version: ............ 0 |
===============================================================================
When I try and connect to the RTMP client I get this. The RTMP client freezes in limbo (ffprobe is stuck waiting):
[2025-10-16 12:43:16.260][INFO][450388][98887e7o] RTMP client transport=plaintext, ip=127.0.0.1:55548, fd=12
[2025-10-16 12:43:16.261][INFO][450388][98887e7o] complex handshake success
[2025-10-16 12:43:16.302][INFO][450388][98887e7o] connect app, tcUrl=rtmp://127.0.0.1:1955/live, pageUrl=, swfUrl=, schema=rtmp, vhost=127.0.0.1, port=1955, app=live, args=null
[2025-10-16 12:43:16.302][INFO][450388][98887e7o] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2025-10-16 12:43:16.384][INFO][450388][98887e7o] ignore AMF0/AMF3 command message.
[2025-10-16 12:43:16.424][INFO][450388][98887e7o] ignore AMF0/AMF3 command message.
[2025-10-16 12:43:16.425][INFO][450388][98887e7o] client identified, type=rtmp-play, vhost=127.0.0.1, app=live, stream=0199ed65-2981-727f-b8a9-c21053e9c2ee, param=, duration=-1ms
[2025-10-16 12:43:16.425][INFO][450388][98887e7o] connected stream, tcUrl=rtmp://127.0.0.1:1955/live, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=1955, app=live, stream=0199ed65-2981-727f-b8a9-c21053e9c2ee, param=, args=null
[2025-10-16 12:43:16.425][INFO][450388][98887e7o] source url=/live/0199ed65-2981-727f-b8a9-c21053e9c2ee, ip=127.0.0.1, cache=0/2500, is_edge=0, source_id=/
[2025-10-16 12:43:16.425][INFO][450388][98887e7o] create consumer, active=0, queue_size=10000ms, jitter=1
[2025-10-16 12:43:16.425][INFO][450388][98887e7o] set fd=12, SO_SNDBUF=2626560=>175000, buffer=350ms
[2025-10-16 12:43:16.425][INFO][450388][98887e7o] start play smi=10ms, mw_sleep=350, mw_msgs=8, realtime=0, tcp_nodelay=0
[2025-10-16 12:43:16.425][INFO][450388][98887e7o] -> PLA time=0, msgs=0, okbps=0,0,0, ikbps=0,0,0, mw=350/8
[2025-10-16 12:43:16.923][INFO][450388][os72296f] SRS: cpu=6.00%,32MB, cid=3,1, timer=62,0,0, clock=0,46,2,0,0,0,0,0,0, free=1, objs=(pkt:0,raw:0,fua:0,msg:1937,oth:0,buf:0)
[2025-10-16 12:43:17.573][INFO][450388][7618520n] <- SRT_CPB Transport Stats # pktRecv=9701, pktRcvLoss=0, pktRcvRetrans=0, pktRcvDrop=0
[2025-10-16 12:43:17.573][INFO][450388][7618520n] <- SRT_CPB time=1288946, packets=9700, okbps=0,0,0, ikbps=0,10201,10199
[2025-10-16 12:43:20.430][INFO][450388][9e898pf6] -> SRT_PLA Transport Stats # pktSent=9711, pktSndLoss=2, pktRetrans=2, pktSndDrop=0
[2025-10-16 12:43:20.430][INFO][450388][9e898pf6] -> SRT_PLA time=1086457, packets=9709, okbps=0,10202,10199, ikbps=0,0,0
[2025-10-16 12:43:21.927][INFO][450388][os72296f] SRS: cpu=5.99%,32MB, cid=3,1, timer=62,0,0, clock=0,46,2,0,0,0,0,0,0, free=1, objs=(pkt:0,raw:0,fua:0,msg:1937,oth:0,buf:0)
[2025-10-16 12:43:26.930][INFO][450388][os72296f] SRS: cpu=5.99%,32MB, cid=3,1, timer=62,0,0, clock=0,46,2,0,0,0,0,0,0, free=1, objs=(pkt:0,raw:0,fua:0,msg:1937,oth:0,buf:0)
[2025-10-16 12:43:27.579][INFO][450388][7618520n] <- SRT_CPB Transport Stats # pktRecv=9692, pktRcvLoss=0, pktRcvRetrans=0, pktRcvDrop=0
[2025-10-16 12:43:27.579][INFO][450388][7618520n] <- SRT_CPB time=1298954, packets=9705, okbps=0,0,0, ikbps=0,10197,10199
[2025-10-16 12:43:30.442][INFO][450388][9e898pf6] -> SRT_PLA Transport Stats # pktSent=9697, pktSndLoss=0, pktRetrans=0, pktSndDrop=0
[2025-10-16 12:43:30.442][INFO][450388][9e898pf6] -> SRT_PLA time=1096468, packets=9697, okbps=0,10202,10199, ikbps=0,0,0
Since srs can't process scte-35 like these and generate the HLS output, I'd like to use the same signal converted to RTMP in order to use my current pipeline to transcode this stream and insert the markings.
Are you hoping for SRS to support forwarding this track, or should it simply be disregarded?
Please provide a video clip.
@duiniuluantanqin Thanks for the quick reply!
Ideally I'd like to read and forward this stream using RTMP.
I recorded a 10min clip here (mpegts), with tsduck as a srt connector:
https://drive.google.com/file/d/1DGvP11lEfj9s31gnvektCCOLvePXMGgj/view?usp=sharing
I'd be totally ok with srs dropping the non-compatible PID in order to make it work with RTMP...I think it's better than not having any stream whatsoever.
It appears to be a compatibility issue. Could you transcode with ffmpeg before pushing stream? It might not be resolved in the short term.
@duiniuluantanqin Sure can, just wanted to take advantage of the automatic conversion.
Should I leave this ticket open for future implementation or should I close it?