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
11.41k stars 1.45k forks source link

unable to decode AVCC: number of NALUs contained inside a single group (21) is too big (maximum is 20) #1401

Closed jinbe0 closed 1 year ago

jinbe0 commented 1 year ago

Which version are you using?

v0.21.0

Which operating system are you using?

Describe the issue

The following error occurred while trying to connect to RTMP server (hosted on windows 10 latest version) from ffmpeg (running on windows 11 latest version).

Logs:

2023/01/20 02:05:36 INF [RTMP] [conn 192.168.0.107:54484] opened
2023/01/20 02:05:36 INF [RTMP] [conn 192.168.0.107:54484] is publishing to path 'mystream', 1 track (H264)
2023/01/20 02:05:36 INF [RTMP] [conn 192.168.0.107:54484] closed (unable to decode AVCC: number of NALUs contained inside a single group (21) is too big (maximum is 20))

ffmpeg command:

ffmpeg.exe -f gdigrab -r 30 -draw_mouse 1 -i desktop -c:v libx264 -r 30 -preset ultrafast -tune zerolatency -pix_fmt yuv420p -bsf:v h264_mp4toannexb -x264-params "keyint=1:keyint_min=1" -f flv "rtmp://192.168.0.20:1935/mystream"

ffmpeg prints following messages:

ffmpeg version 5.1.2-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
[gdigrab @ 000001feb0714600] Capturing whole desktop as 3840x2160x32 at (0,0)
[gdigrab @ 000001feb0714600] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, gdigrab, from 'desktop':
  Duration: N/A, start: 1674149091.391017, bitrate: 7962636 kb/s
  Stream #0:0: Video: bmp, bgra, 3840x2160, 7962636 kb/s, 30 fps, 1000k tbr, 1000k tbn
Stream mapping:
  Stream #0:0 -> #0:0 (bmp (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 000001feb0717b00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001feb0717b00] profile Constrained Baseline, level 5.1, 4:2:0, 8-bit
[libx264 @ 000001feb0717b00] 264 - core 164 r3099 e067ab0 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=20 lookahead_threads=16 sliced_threads=1 slices=20 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=1 keyint_min=1 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, flv, to 'rtmp://192.168.0.20:1935/mystream':
  Metadata:
    encoder         : Lavf59.27.100
  Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p(tv, progressive), 3840x2160, q=2-31, 30 fps, 1k tbn
    Metadata:
      encoder         : Lavc59.37.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
av_interleaved_write_frame(): Unknown errortime=00:00:00.00 bitrate=11185816.0kbits/s speed=1e+03x
[flv @ 000001feb0716a40] Failed to update header with correct duration.
[flv @ 000001feb0716a40] Failed to update header with correct filesize.
Error writing trailer of rtmp://192.168.0.20:1935/mystream: Error number -10053 occurred
frame=    2 fps=0.0 q=30.0 Lsize=    2069kB time=00:00:00.03 bitrate=498617.2kbits/s speed=0.102x
video:2086kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Error closing file rtmp://192.168.0.20:1935/mystream: Error number -10053 occurred
[libx264 @ 000001feb0717b00] frame I:2     Avg QP:25.00  size:1067483
[libx264 @ 000001feb0717b00] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 000001feb0717b00] coded y,uvDC,uvAC intra: 48.1% 47.5% 40.4%
[libx264 @ 000001feb0717b00] i16 v,h,dc,p: 47% 32% 14%  8%
[libx264 @ 000001feb0717b00] i8c dc,h,v,p: 62% 19% 14%  4%
[libx264 @ 000001feb0717b00] kb/s:256195.91
Conversion failed!

Workaround

Running the following ffmpeg command successfully streams desktop, but this method cannot achieve sufficient fps. I want stream my 4K desktop to rtsp-simple-server without unnecessary conversion!

ffmpeg.exe -f gdigrab -r 30 -draw_mouse 1 -i desktop -vf scale=-1:1080 -c:v libx264 -r 30 -preset ultrafast -tune zerolatency -pix_fmt yuv420p -bsf:v h264_mp4toannexb -x264-params "keyint=1:keyint_min=1" -f flv "rtmp://192.168.0.20:1935/mystream"

Note: -vf scale=-1:1080 is added.

Describe how to replicate the issue

  1. start the server
  2. run the following command from some clients:
    ffmpeg.exe -f gdigrab -r 30 -draw_mouse 1 -i desktop -c:v libx264 -r 30 -preset ultrafast -tune zerolatency -pix_fmt yuv420p -bsf:v h264_mp4toannexb -x264-params "keyint=1:keyint_min=1" -f flv "rtmp://192.168.0.20:1935/mystream"

Did you attach the server logs?

yes

Did you attach a network dump?

no

aler9 commented 1 year ago

Hello, instead of scaling down the video, just set a reasonable bitrate by adding -v:b 1M or any value you want (in the logs there's a bitrate of 11G/s which is unreasonable). Let me know if it works.

aler9 commented 1 year ago

without further comments from the author, this is considered solved.

github-actions[bot] commented 8 months ago

This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.