bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
12.48k stars 1.55k forks source link

"Illegal temporal ID in RTP/HEVC packet" error from ffmpeg when publishing HEVC stream with SRT and reading with RTSP #3993

Open longnguyen2004 opened 1 day ago

longnguyen2004 commented 1 day ago

Which version are you using?

v1.9.3

Which operating system are you using?

Linux amd64 standard, Windows amd64 standard

Describe how to replicate the issue

Publish an HEVC stream with SRT to the server ffmpeg -re -f lavfi -i testsrc -force_key_frames "expr:gte(t,n_forced*1)" -c:v libx265 -f mpegts srt://localhost:8890/?streamid=publish:test_hevc

then read it with RTSP ffmpeg -i rtsp://localhost:8554/test_hevc -c copy -f null nul

You should see the error happening after a second. It seems to occur on every keyframe, which is why I forced keyframe every second. This also seems to only happen with SRT->RTSP, I tested RTSP->RTSP and there's no problem there.

Server logs

No response

Network dump

No response

MinorityMeaning commented 15 hours ago

I have a similar problem. I'm trying to get an additional reduced hls stream.

My mediamtx.xml:

runOnReady: \
ffmpeg -hide_banner -y -fflags nobuffer -i rtsp://localhost/mystream \
-vf scale=w=640:h=360 -tag:v hvc1 -c:v libx265 -c:a copy -preset veryfast -profile:v main -hls_time 1 -hls_list_size 7 -hls_flags delete_segments -start_number 100 -b:v 300k -maxrate 856k -bufsize 1200k -b:a 60k -hls_segment_type fmp4 -hls_segment_filename /var/www/html/stream/%03d.mp4 /var/www/html/stream/360p.m3u8

Mediamtx logs:

2024/11/30 18:29:53 INF MediaMTX v1.9.3
2024/11/30 18:29:53 INF configuration loaded from /mediamtx.yml
2024/11/30 18:29:53 INF [RTSP] listener opened on :8554 (TCP), :8202 (UDP/RTP), :8203 (UDP/RT                                                          CP)
2024/11/30 18:29:53 INF [RTMP] listener opened on :1935
2024/11/30 18:29:53 INF [HLS] listener opened on :8888
2024/11/30 18:29:53 INF [WebRTC] listener opened on :8889 (HTTP), :8189 (ICE/UDP)
2024/11/30 18:29:53 INF [SRT] listener opened on :8890 (UDP)
2024/11/30 18:30:00 INF [RTMP] [conn 90.154.72.99:12343] opened
2024/11/30 18:30:01 INF [path mystream] runOnReady command started
2024/11/30 18:30:01 INF [RTMP] [conn 90.154.72.99:12343] is publishing to path 'mystream', 2                                                           tracks (H265, MPEG-4 Audio)
2024/11/30 18:30:01 INF [HLS] [muxer mystream] created automatically
2024/11/30 18:30:01 INF [HLS] [muxer mystream] is converting into HLS, 2 tracks (H265, MPEG-4                                                           Audio)
2024/11/30 18:30:01 INF [RTSP] [conn 83.136.233.242:38538] opened
2024/11/30 18:30:01 INF [RTSP] [session 9dc0a882] created by 83.136.233.242:38538
2024/11/30 18:30:01 INF [RTSP] [session 9dc0a882] is reading from path 'mystream', with UDP,                                                           2 tracks (H265, MPEG-4 Audio)
[rtsp @ 0x7fa392adb600] Illegal temporal ID in RTP/HEVC packet
    Last message repeated 7 times
Input #0, rtsp, from 'rtsp://83.136.233.242:8554/mystream':
  Metadata:
    title           :
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: hevc (Main), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 60 fps, 6                                                          0 tbr, 90k tbn
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> hevc (libx265))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[rtsp @ 0x7fa392adb600] Illegal temporal ID in RTP/HEVC packet
[hevc @ 0x7fa38d8a6940] Could not find ref with POC 34
[hevc @ 0x7fa38d8a6940] Could not find ref with POC 33
[hevc @ 0x7fa38d8a6940] Could not find ref with POC 32
[hevc @ 0x7fa38d8a6940] Could not find ref with POC 31
[rtsp @ 0x7fa392adb600] Illegal temporal ID in RTP/HEVC packet
[hevc @ 0x7fa38d590bc0] Could not find ref with POC 36
[hevc @ 0x7fa38d590bc0] Could not find ref with POC 34
[hevc @ 0x7fa38d590bc0] Could not find ref with POC 33
[hevc @ 0x7fa38d56c880] Could not find ref with POC 38
[hevc @ 0x7fa38d56c880] Could not find ref with POC 36
[hevc @ 0x7fa38d4fc8c0] Could not find ref with POC 38
[hevc @ 0x7fa38d4fc8c0] Could not find ref with POC 36
[rtsp @ 0x7fa392adb600] Illegal temporal ID in RTP/HEVC packet
[hevc @ 0x7fa38d486880] Could not find ref with POC 38
[rtsp @ 0x7fa392adb600] Illegal temporal ID in RTP/HEVC packet
[hevc @ 0x7fa38d457880] Could not find ref with POC 42
[hevc @ 0x7fa38d4488c0] Could not find ref with POC 44
[hevc @ 0x7fa38d4488c0] Could not find ref with POC 42
[rtsp @ 0x7fa392adb600] Illegal temporal ID in RTP/HEVC packet
[hevc @ 0x7fa38d3648c0] Could not find ref with POC 44
[hevc @ 0x7fa38d3648c0] Could not find ref with POC 42
[hevc @ 0x7fa38d35c900] Could not find ref with POC 47
[hevc @ 0x7fa38d35c900] Could not find ref with POC 44
[rtsp @ 0x7fa392adb600] Illegal temporal ID in RTP/HEVC packet
x265 [info]: HEVC encoder version 3.5+1-f0c1022b6
x265 [info]: build info [Linux][GCC 13.2.1][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-3 (Main tier)
x265 [info]: Thread pool created using 8 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 3 / wpp(6 rows)
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
x265 [warning]: Source height < 720p; disabling lookahead-slices
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
set_mempolicy: Operation not permitted
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 1 / 2
x265 [info]: Keyframe min / max / scenecut / bias  : 25 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 15 / 4 / 0
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 2 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : ABR-300 kbps / 0.60
x265 [info]: VBV/HRD buffer / max-rate / init    : 1200 / 856 / 0.750
x265 [info]: tools: rd=2 psy-rd=2.00 early-skip rskip mode=1 signhide tmvp
x265 [info]: tools: fast-intra strong-intra-smoothing deblock sao
[hls @ 0x7fa38d4a80c0] Opening '/var/www/html/stream/init.mp4' for writing
Output #0, hls, to '/var/www/html/stream/360p.m3u8':
  Metadata:
    title           :
    encoder         : Lavf60.16.100
  Stream #0:0: Video: hevc (hvc1 / 0x31637668), yuv420p(tv, bt709, progressive), 640x360 [SAR                                                           1:1 DAR 16:9], q=2-31, 300 kb/s, 60 fps, 15360 tbn
    Metadata:
      encoder         : Lavc60.31.102 libx265
    Side data:
      cpb: bitrate max/min/avg: 856000/0/300000 buffer size: 1200000 vbv_delay: N/A
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 60 kb/s
frame=    6 fps=0.0 q=46.0 size=N/A time=00:00:00.72 bitrate=N/A dup=30 drop=0 speed= 3.8x                                                             [hevc @ 0x7fa38d8a6940] Could not find ref with POC 47
[hevc @ 0x7fa38d590bc0] Could not find ref with POC 50
[hevc @ 0x7fa38d590bc0] Could not find ref with POC 47
[hevc @ 0x7fa38d56c880] Could not find ref with POC 50
[rtsp @ 0x7fa392adb600] Illegal temporal ID in RTP/HEVC packet
[hevc @ 0x7fa38d4fc8c0] Could not find ref with POC 50
[hevc @ 0x7fa38d486880] Could not find ref with POC 50
[rtsp @ 0x7fa392adb600] Illegal temporal ID in RTP/HEVC packet
[hevc @ 0x7fa38d4488c0] Could not find ref with POC 56
[rtsp @ 0x7fa392adb600] Illegal temporal ID in RTP/HEVC packet
[hevc @ 0x7fa38d3648c0] Could not find ref with POC 56
[hevc @ 0x7fa38d35c900] Could not find ref with POC 56
[hevc @ 0x7fa38d8a6940] Could not find ref with POC 60
[rtsp @ 0x7fa392adb600] Illegal temporal ID in RTP/HEVC packet
[hevc @ 0x7fa38d590bc0] Could not find ref with POC 62
[hevc @ 0x7fa38d590bc0] Could not find ref with POC 60
[hevc @ 0x7fa38d56c880] Could not find ref with POC 62
[hevc @ 0x7fa38d56c880] Could not find ref with POC 60
....

hls player output: Снимок экрана 2024-11-30 214509