Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming Taking Long Time to Start #69

Closed
shnhrrsn opened this issue Aug 13, 2020 · 9 comments
Closed

Streaming Taking Long Time to Start #69

shnhrrsn opened this issue Aug 13, 2020 · 9 comments
Labels
ffmpeg Issue with ffmpeg, not the plugin itself

Comments

@shnhrrsn
Copy link

Describe the bug

I'm opening this separate from #62 because it doesn't actually seem to be an issue with ffmpeg.

Basically, after I open the request in Home.app (on either iOS or macOS), it seems to take 30+ seconds before the plugin even acknowledges there was a request to open.

I've previously used a different UniFi plugin without this issue (migrated when upgrading to Protect) and my Ring doesn't have the problem either -- it seems specific to this plugin.

This may or may not be a dupe of #58, but sounds like a similar issue.

Specifications
What hardware and OS is your Homebridge running on?: Tested with homebridge running on macOS and Debian
What Unifi hardware are you using: UDM-Pro, 3x G3, 1x G3 Dome, 1x G4 Doorbell

@beele
Copy link
Owner

beele commented Aug 17, 2020

I use the same logic as the base homebridge camera ffmpeg plugin.
My video streams load anywhere between 5-15 seconds, which I would deem acceptable.
Please provide a detailed log with the debug flag enabled so the ffmpeg debug output is visible.

@beele beele added the ffmpeg Issue with ffmpeg, not the plugin itself label Aug 17, 2020
@JJJ
Copy link
Contributor

JJJ commented Aug 17, 2020

It takes about 2 seconds on my Raspberry Pi 4 4GB, running the Homebridge OS image.

@shnhrrsn
Copy link
Author

shnhrrsn commented Aug 17, 2020

@beele there’s really nothing useful in the logs which is why I didn't include them. If I clear logs before opening the stream in Home.app, the logs will be empty for 20-30s after I tap the camera in Home.app before finally kicking off the ffmpeg request. At that point, assuming the app hasn’t given up, everything works fine.

@JJJ
Copy link
Contributor

JJJ commented Aug 18, 2020

Back when I was seeing slow ffmpeg times on my old Raspberry Pi 3 with Nest cameras, it was related to the order with which I had compiled and set everything up. Namely that I ended up with multiple versions of it installed in different directories because I had followed different tutorials and instructions, one of which was not configured to take advantage of hardware acceleration on the Raspberry Pi, using the wrong protocol, was missing libfdk-aac, and more.

Can you confirm that this plugin is finding and using the correct copy of ffmpeg, and can you copy its configuration here. You can get it via the command line simply by typing:

ffmpeg

Mine looks like this:

ffmpeg version 4.2.git-47773f7 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
  configuration:
    --pkgconfigdir=/build/workspace/lib/pkgconfig
    --prefix=/build/workspace
    --pkg-config-flags=--static
    --extra-cflags=-I/build/workspace/include
    --extra-ldflags=-L/build/workspace/lib
    --extra-libs='-lpthread -lm'
    --enable-static
    --disable-debug
    --disable-shared
    --disable-ffplay
    --disable-doc
    --enable-openssl
    --enable-gpl
    --enable-version3
    --enable-nonfree
    --enable-pthreads
    --enable-libvpx
    --enable-libmp3lame
    --enable-libopus
    --enable-libtheora
    --enable-libvorbis
    --enable-libx264
    --enable-runtime-cpudetect
    --enable-libfdk-aac
    --enable-avfilter
    --enable-libopencore_amrwb
    --enable-libopencore_amrnb
    --enable-filters
    --enable-decoder=h264
    --enable-network
    --enable-protocol=tcp
    --enable-demuxer=rtsp
    --enable-omx-rpi
    --enable-mmal
  libavutil      56. 40.100 / 56. 40.100
  libavcodec     58. 68.102 / 58. 68.102
  libavformat    58. 38.100 / 58. 38.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 75.100 /  7. 75.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

@janthony6
Copy link

janthony6 commented Aug 18, 2020

I'm having trouble streaming on my Pi4 on my UDMP. My ffmpeg shows this:

ffmpeg version N-94452-g9af8ce754b Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Raspbian 8.3.0-6+rpi1)
  configuration: --prefix=/usr/local --arch=armel --target-os=linux --enable-omx-rpi --enable-nonfree --enable-gpl --enable-libfdk-aac --enable-mmal --enable-libx264 --enable-decoder=h264 --enable-network --enable-protocol=tcp --enable-demuxer=rtsp
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.100 / 58. 55.100
  libavformat    58. 30.100 / 58. 30.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.100 /  7. 58.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

@janthony6
Copy link

Recompiled with:

ffmpeg version N-98757-ge8a88a16f7 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 8 (Raspbian 8.3.0-6+rpi1) configuration: --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --extra-libs='-lpthread -lm -latomic' --arch=armel --enable-gmp --enable-gpl --enable-libaom --enable-libass --enable-libdav1d --enable-libdrm --enable-libfdk-aac --enable-libfreetype --enable-libkvazaar --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libssh --enable-libvorbis --enable-libvpx --enable-libzimg --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-mmal --enable-nonfree --enable-omx --enable-omx-rpi --enable-version3 --target-os=linux --enable-pthreads --enable-openssl --enable-hardcoded-tables libavutil 56. 58.100 / 56. 58.100 libavcodec 58.100.100 / 58.100.100 libavformat 58. 51.100 / 58. 51.100 libavdevice 58. 11.101 / 58. 11.101 libavfilter 7. 87.100 / 7. 87.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

@beele
Copy link
Owner

beele commented Aug 21, 2020

If you start homebridge, the plugin should print out the path of the ffmpeg binary that is being used. Can you confirm this is using your compiled version.
Also the latest beta: [email protected] has some changes in the way video & snapshots are handled.
sudo npm i -g [email protected] --unsafe-perm=true

The video config section for the plugin should be adjusted to this:

"videoConfig": {
    "audio": true,
    "maxFPS": 30,
    "maxBitrate": 3000
}

@janthony6
Copy link

The new beta fixed all the ffmpeg issues. It now streams and works correctly. Sound works perfect too.

@shnhrrsn
Copy link
Author

shnhrrsn commented Aug 24, 2020

@beele closing this out -- not your fault, I figured out the issue though for others who may experience this:

HomeKit seems to load everything sequentially (unsure if this is a HAP/Homebridge issue or HomeKit itself). If you open a section in Home.app like favorites with 6 cameras on it and immediately open a stream, the plugin doesn't get the request for
the stream until after all 6 snapshots have loaded.

In my case, one of my cameras is slow, which added to the delay.

Interestingly, this seems to be hub-specific (which may mean it's a HAP/Homebridge limitation?). My ring plugin wasn't suffering this because I have it in a separate homebridge instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ffmpeg Issue with ffmpeg, not the plugin itself
Projects
None yet
Development

No branches or pull requests

4 participants