homebridge-camera-ffmpeg: Video Stream not working: iSlices >= MAX_SLICES Stop!

I’m having an issue streaming to any devices. I’m able to open the camera stream in VLC, and it appears that the video stream is being created properly. Here is the ffmpeg output, which looks (to me) normal:

[12/22/2018, 11:25:28 AM] [Camera-ffmpeg] Start streaming video from Garage Cam with 1280x720@200kBit
ffmpeg -rtsp_transport tcp -re -i rtsp://admin:xxx@192.168.1.21:554/Streaming/Channels/103/ -map 0:0 -vcodec libx264 -pix_fmt yuv420p -r 30 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 200k -bufsize 200k -payload_type 99 -ssrc 731600 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params m8vVsRiOg55ZYSt04Z+2wDj8i6q14JOFYaSQdtl3 srtp://192.168.1.45:50754?rtcpport=50754&localrtcpport=50754&pkt_size=188
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma

  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100

Input #0, rtsp, from 'rtsp://admin:xxx@192.168.1.21:554/Streaming/Channels/103/':
  Metadata:
    title           : Media Presentation

  Duration: N/A, start: 0.383333, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 15 fps, 20 tbr, 90k tbn, 30 tbc

Stream mapping:

  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help

frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
[swscaler @ 0x7ffb1e210c00] deprecated pixel format used, make sure you did set range correctly

[libx264 @ 0x7ffb1b80c200] VBV maxrate unspecified, assuming CBR
[libx264 @ 0x7ffb1b80c200] 
using SAR=1/1

[libx264 @ 0x7ffb1b80c200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX

[libx264 @ 0x7ffb1b80c200] profile High, level 3.1

Output #0, rtp, to 'srtp://192.168.1.45:50754?rtcpport=50754&localrtcpport=50754&pkt_size=188':
  Metadata:
    title           : Media Presentation
    encoder         : Lavf58.12.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 200 kb/s, 30 fps, 90k tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.18.100 libx264
    Side data:
      
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 200000 vbv_delay: -1

frame=    2 fps=2.0 q=62.0 size=       6kB time=00:00:00.03 bitrate=1443.1kbits/s dup=0 drop=5 speed=0.0329x    
frame=   15 fps=9.9 q=44.0 size=      16kB time=00:00:00.46 bitrate= 283.4kbits/s dup=6 drop=5 speed=0.307x    
frame=   32 fps= 16 q=43.0 size=      27kB time=00:00:01.03 bitrate= 214.5kbits/s dup=15 drop=5 speed=0.509x    
frame=   47 fps= 18 q=44.0 size=      46kB time=00:00:01.53 bitrate= 246.7kbits/s dup=22 drop=5 speed=0.602x    
frame=   62 fps= 20 q=43.0 size=      52kB time=00:00:02.03 bitrate= 211.3kbits/s dup=30 drop=5 speed=0.665x    
frame=   77 fps= 22 q=41.0 size=      64kB time=00:00:02.53 bitrate= 208.0kbits/s dup=37 drop=5 speed=0.709x    
frame=   91 fps= 22 q=42.0 size=      76kB time=00:00:03.00 bitrate= 207.9kbits/s dup=44 drop=5 speed=0.736x   

I grabbed HomeKit logs from the Console app and found some things that look suspicious. A bunch of these appear while the stream tries to load:

default	11:25:37.624443 -0600	avconferenced	 [WARNING] AssembleFrame_H264:1184 *** BAD FRAME -- 8: iSlices >= MAX_SLICES  Stop!
default	11:25:37.627099 -0600	avconferenced	 [WARNING] AssembleFrame_H264:1184 *** BAD FRAME -- 8: iSlices >= MAX_SLICES  Stop!
default	11:25:37.722414 -0600	avconferenced	 [WARNING] AssembleFrame_H264:1184 *** BAD FRAME -- 8: iSlices >= MAX_SLICES  Stop!
default	11:25:37.725916 -0600	avconferenced	 [WARNING] AssembleFrame_H264:1184 *** BAD FRAME -- 8: iSlices >= MAX_SLICES  Stop!
default	11:25:37.772133 -0600	avconferenced	 [WARNING] AssembleFrame_H264:1184 *** BAD FRAME -- 8: iSlices >= MAX_SLICES  Stop!
default	11:25:37.812770 -0600	avconferenced	 [WARNING] AssembleFrame_H264:1184 *** BAD FRAME -- 8: iSlices >= MAX_SLICES  Stop!
default	11:25:37.816847 -0600	avconferenced	 [WARNING] AssembleFrame_H264:1184 *** BAD FRAME -- 8: iSlices >= MAX_SLICES  Stop!
default	11:25:37.817019 -0600	avconferenced	 [WARNING] AssembleFrame_H264:1184 *** BAD FRAME -- 8: iSlices >= MAX_SLICES  Stop!
default	11:25:37.896356 -0600	avconferenced	VCMediaStream [INFO] -[VCMediaStream rtcpSendHeartbeat]:955 RTCP HeartBeat intervalElapsed:1 remainingInterval:0.00000
default	11:25:37.896356 -0600	avconferenced	_myPeriodicTask: Started RT periodic task
default	11:25:37.896456 -0600	avconferenced	 [INFO] -[VCVideoStreamRateAdaptation runVideoStreamRateAdaptation]:80 packetsExpectedForInterval:90 packetsLostForInterval:0
default	11:25:37.896522 -0600	avconferenced	 [NOTICE] -[VCVideoStreamReceiver gatherRealtimeStats:]:1013 VideoStreamStats - Rx - framerate:0.000000, bitrate:0kbps
error	11:25:37.896616 -0600	avconferenced	 [ERROR] -[VCVideoStreamRateAdaptation runVideoStreamRateAdaptation]:89 <private>:89 - Failed to receive TMMBN!

It seems like the frames being generated have too many slices. Unfortunately I don’t know what a slice is or how to adjust it. I tried doing some obvious things like lowing the bitrate and packet size but that didn’t help. This is a 720p stream at 30fps which seems pretty standard.

Anyone have some expertise on this?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 25 (7 by maintainers)

Most upvoted comments

Actually you don’t need to modify code, try add "additionalCommandline": "-x264-params \"intra-refresh=1:bframes=0\"" to your videoConfig section in config.json and switch back to libx264 and see if that solves your issue.

Final config will look like this

{
	"platform": "Camera-ffmpeg",
	"cameras": [{
		"name": "Camera Name",
		"videoConfig": {
			"source": "-re -i rtsp://myfancy_rtsp_stream",
			"stillImageSource": "-i http://faster_still_image_grab_url/this_is_optional.jpg",
			"maxStreams": 2,
			"maxWidth": 1280,
			"maxHeight": 720,
			"maxFPS": 30,
			"additionalCommandline": "-x264-params \"intra-refresh=1:bframes=0\""
		}
	}]
}