seydx / homebridge-camera-ui

Homebridge plugin for RTSP Cameras with HSV, motion detection support, Image Rekognition, Web UI to manage/watch streams and WebApp support
MIT License
638 stars 92 forks source link

Unknown encoder 'libfdk_aac' #359

Closed clinderwell closed 2 years ago

clinderwell commented 2 years ago

Describe the bug Everytime recording initiates, even with audio disabled, it tries to use an audio codec not in my ffmpeg installation. It appears the audio selection is unchangeable. As a result, I think it's erroring out my recording.

[1/17/2022, 1:12:50 AM] [CameraUI] Front Camera: Motion ON [1/17/2022, 1:12:51 AM] [CameraUI] Front Camera: Video fragments requested from HSV [1/17/2022, 1:12:51 AM] [CameraUI] Front Camera: Setting prebuffer stream as input [1/17/2022, 1:12:51 AM] [CameraUI] Front Camera: Can not access prebuffer stream, skipping: Error: Prebuffer process not started! [1/17/2022, 1:12:51 AM] [CameraUI] Front Camera: Replacing audio with a dummy track, audio source not found or timed out during probe stream (recording) [1/17/2022, 1:12:51 AM] [CameraUI] Front Camera: Start recording... [1/17/2022, 1:12:51 AM] [CameraUI] Front Camera: Recording command: ffmpeg -hide_banner -rtsp_transport tcp -re -i rtsp://admin:xxxx@xxxxx/cam/realmonitor?channel=1&subtype=0 -f lavfi -i anullsrc=cl=1 -shortest -f mp4 -sn -dn -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level:v 3.1 -b:v 2000k -force_key_frames expr:eq(t,n_forced*4) -r 30 -vf scale=w=1920:h=1080:force_original_aspect_ratio=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2 -bsf:a aac_adtstoasc -acodec libfdk_aac -profile:a aac_low -ar 32k -b:a 64k -ac 1 -movflags frag_keyframe+empty_moov+default_base_moof -max_muxing_queue_size 1024 tcp://127.0.0.1:26394 [1/17/2022, 1:12:55 AM] [CameraUI] Front Camera: Input #0, rtsp, from 'rtsp://admin:xxxx@xxxxx/cam/realmonitor?channel=1&subtype=0': Metadata: title : Server Duration: N/A, start: 0.400000, bitrate: N/A

[1/17/2022, 1:12:55 AM] [CameraUI] Front Camera: Stream #0:0: Video: hevc (Main), yuvj420p(pc, bt709), 2688x1520 [SAR 1:1 DAR 168:95], 5 fps, 5 tbr, 90k tbn, 5 tbc

[1/17/2022, 1:12:55 AM] [CameraUI] Front Camera: Input #1, lavfi, from 'anullsrc=cl=1': Duration: N/A, start: 0.000000, bitrate: 352 kb/s Stream #1:0: Audio: pcm_u8, 44100 Hz, 1 channels (FL), u8, 352 kb/s [1/17/2022, 1:12:55 AM] [CameraUI] Front Camera:

[1/17/2022, 1:12:55 AM] [CameraUI] Front Camera: Unknown encoder 'libfdk_aac'

[1/17/2022, 1:12:55 AM] [CameraUI] Front Camera: FFmpeg recording process exited with error! (null) [1/17/2022, 1:13:00 AM] [CameraUI] Front Camera: Closing recording process [1/17/2022, 1:13:00 AM] [CameraUI] Resetting motion state because HSV closed recording with reason "3" [1/17/2022, 1:13:00 AM] [CameraUI] Front Camera: Motion OFF - Motion handler timeout.

==> /root/.pm2/logs/homebridge-error.log <== [HDS ::ffff:192.168.1.28] Recording download stream 1 is still awaiting generator although stream was closed 10s ago!

Environment

seydx commented 2 years ago

your ffmpeg is not compiled with the audio codec libfdk_aac which is required for audio to work. You can use the internal ffmpeg which provides all required codecs for camera.ui

Did you define the videoProcessor in config.json like this ?

"options": {
  "videoProcessor": "ffmpeg"
}

If yes, remove the entire "options" block from config.json and restart homebridge

clinderwell commented 2 years ago

Thanks for the quick response. I also realized that my ffmpeg (just the standard package) didn't have that codec. I'm not sure why we need it if I'm disabling audio perhaps some HSV thing. I tried compiling it myself but failed...it's not as simple.

Also, I tried installing the npm package ffmpeg-for-homebridge but it doesn't seem to be pointed to it or matter.

Any other suggestions?

Here is my config -

{ "name": "CameraUI", "port": 8181, "debug": true, "mqtt": { "active": false }, "http": { "active": false, "localhttp": false }, "smtp": { "active": false }, "ftp": { "active": false }, "ssl": { "active": false }, "cameras": [ { "name": "Garage Camera", "manufacturer": "Amcrest", "model": "IP4M-1026", "motion": true, "doorbell": true, "switches": true, "useInterfaceTimer": true, "motionTimeout": 15, "unbridge": true, "hsv": true, "prebuffering": true, "forcePrebuffering": false, "prebufferLength": 4000, "videoConfig": { "source": "-rtsp_transport tcp -re -i rtsp://admin:xxxx@xxxx/cam/realmonitor?channel=1&subtype=0", "subSource": "-rtsp_transport tcp -re -i rtsp://admin:xxxx@xxxx/cam/realmonitor?channel=1&subtype=0", "stillImageSource": "-i http://admin:xxxx@xxxx/cgi-bin/snapshot.cgi?chn=0&u=admin&p=xxxxx", "rtspTransport": "tcp", "maxStreams": 2, "maxWidth": 2688, "maxHeight": 1520, "maxBitrate": 2048, "vcodec": "libx264", "packetSize": 1316, "stimeout": 0, "encoderOptions": "-preset ultrafast", "audio": false, "debug": false }, "videoanalysis": { "active": true } }, { "name": "Back Patio Cam", "manufacturer": "Amcrest", "model": "IP4M-1026", "motion": true, "motionTimeout": 15, "unbridge": true, "hsv": true, "prebuffering": true, "prebufferLength": 4000, "videoConfig": { "source": "-rtsp_transport tcp -re -i rtsp://admin:xxxx@xxxx/cam/realmonitor?channel=1&subtype=0", "subSource": "-rtsp_transport tcp -re -i rtsp://admin:xxxx@xxxx/cam/realmonitor?channel=1&subtype=0", "stillImageSource": "-i http://admin:xxxx@xxxx/cgi-bin/snapshot.cgi?chn=0&u=admin&p=xxx", "rtspTransport": "tcp", "maxStreams": 2, "maxWidth": 2688, "maxHeight": 1520, "maxBitrate": 2048, "vcodec": "libx264", "packetSize": 1316, "stimeout": 0, "encoderOptions": "-preset ultrafast", "audio": false, "debug": false }, "videoanalysis": { "active": true } }, { "name": "Side Yard Camera", "manufacturer": "Amcrest", "model": "IP4M-1026", "motion": true, "motionTimeout": 15, "unbridge": true, "hsv": true, "prebuffering": true, "prebufferLength": 4000, "videoConfig": { "source": "-rtsp_transport tcp -re -i rtsp://admin:xxxx@xxxx/cam/realmonitor?channel=1&subtype=0", "subSource": "-rtsp_transport tcp -re -i rtsp://admin:xxxx@xxxx/cam/realmonitor?channel=1&subtype=0", "stillImageSource": "-i http://admin:xxxx@xxxx/cgi-bin/snapshot.cgi?chn=0&u=admin&p=xxx", "rtspTransport": "tcp", "maxStreams": 2, "maxWidth": 2688, "maxHeight": 1520, "maxBitrate": 2048, "vcodec": "libx264", "packetSize": 1316, "stimeout": 0, "encoderOptions": "-preset ultrafast", "audio": false, "debug": false }, "videoanalysis": { "active": true } }, { "name": "Front Camera", "manufacturer": "Amcrest", "model": "IP4M-1026", "motion": true, "doorbell": true, "switches": true, "useInterfaceTimer": true, "motionTimeout": 15, "unbridge": true, "hsv": true, "prebuffering": true, "prebufferLength": 4000, "videoConfig": { "source": "-rtsp_transport tcp -re -i rtsp://admin:xxxx@xxxx/cam/realmonitor?channel=1&subtype=0", "subSource": "-rtsp_transport tcp -re -i rtsp://admin:xxxx@xxxx/cam/realmonitor?channel=1&subtype=0", "stillImageSource": "-i http://admin:xxxx@xxxx/cgi-bin/snapshot.cgi?chn=0&u=admin&p=xxx", "rtspTransport": "tcp", "maxStreams": 2, "maxWidth": 2688, "maxHeight": 1520, "maxBitrate": 2048, "vcodec": "libx264", "packetSize": 1316, "stimeout": 0, "encoderOptions": "-preset ultrafast", "audio": false, "debug": true }, "videoanalysis": { "active": true } } ] }

Here is my ffmpeg which confirms --disable-libfdk-aac root@Homebridge02:~ # ffmpeg ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers built with FreeBSD clang version 10.0.1 (git@github.com:llvm/llvm-project.git llvmorg-10.0.1-0-gef32c611aa2) configuration: --prefix=/usr/local --mandir=/usr/local/man --datadir=/usr/local/share/ffmpeg --pkgconfigdir=/usr/local/libdata/pkgconfig --disable-static --disable-libcelt --enable-shared --enable-pic --enable-gpl --enable-avresample --cc=cc --cxx=c++ --disable-alsa --disable-libopencore-amrnb --disable-libopencore-amrwb --enable-libaom --disable-libaribb24 --enable-asm --enable-libass --disable-libbs2b --disable-libcaca --disable-libcdio --disable-libcodec2 --enable-libdav1d --disable-libdavs2 --disable-libdc1394 --disable-debug --enable-htmlpages --enable-libdrm --disable-libfdk-aac --disable-libflite --enable-fontconfig --enable-libfreetype --enable-frei0r --disable-libfribidi --disable-gcrypt --disable-libglslang --disable-libgme --enable-gmp --enable-gnutls --enable-version3 --disable-libgsm --enable-iconv --disable-libilbc --disable-libjack --disable-libklvanc --disable-libkvazaar --disable-ladspa --enable-libmp3lame --disable-liblensfun --disable-libbluray --disable-librsvg --disable-librtmp --enable-libxml2 --disable-lto --disable-lv2 --disable-mbedtls --disable-libmfx --disable-libmodplug --disable-libmysofa --disable-nonfree --disable-openal --disable-opencl --disable-opengl --disable-libopenh264 --disable-libopenjpeg --disable-libopenmpt --disable-openssl --disable-libopenvino --enable-optimizations --enable-libopus --disable-pocketsphinx --disable-libpulse --disable-librabbitmq --disable-librav1e --disable-librist --enable-runtime-cpudetect --disable-librubberband --disable-sdl2 --disable-libsmbclient --disable-libsnappy --disable-sndio --disable-libsoxr --disable-libspeex --disable-libsrt --disable-libssh --disable-libtensorflow --disable-libtesseract --enable-libtheora --disable-libtwolame --disable-libuavs3d --enable-libv4l2 --enable-vaapi --disable-vapoursynth --enable-vdpau --disable-libvidstab --enable-libvmaf --enable-libvorbis --disable-libvo-amrwbenc --enable-libvpx --disable-vulkan --disable-libwebp --enable-libx264 --enable-libx265 --disable-libxavs2 --enable-libxcb --enable-libxvid --disable-outdev=xv --disable-libzimg --disable-libzmq --disable-libzvbi libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 Hyper fast Audio and Video encoder

clinderwell commented 2 years ago

Is there a way to use a different compiled ffmpeg for this?

seydx commented 2 years ago

Sure, you can use your own, you just need enter the path to ffmpeg in your config.json, e.g

"options": {
  "videoProcessor": "/usr/bin/ffmpeg"
}
clinderwell commented 2 years ago

Sorry - I meant is there another compiled version I can point to that would already be installed with this program?

I tried to compile myself twice and was unsuccessful (hit errors both time).

Looking for another option if it exists :)

seydx commented 2 years ago

@clinderwell

I'm afraid I don't know about TrueNAS, but you could try this?

https://www.truenas.com/community/threads/how-to-install-ffmpeg-in-a-jail.39818/

clinderwell commented 2 years ago

Ended up figuring out how to do it from Ports.

cd /usr/ports/multimedia/ffmpeg make install clean

had to uninstall some preinstall pkgs so it could be installed from ports.

cameron33 commented 1 year ago

This bug appears to have reappeared if running CameraUI inside a child bridge.