homebridge / docker-homebridge

Homebridge Docker. HomeKit support for the impatient using Docker on x86_64, Raspberry Pi (armhf) and ARM64. Includes ffmpeg + libfdk-aac.
https://hub.docker.com/r/homebridge/homebridge/
GNU General Public License v3.0
2.58k stars 242 forks source link

FFmpeg exited with code 1 #132

Closed Veldkornet closed 6 years ago

Veldkornet commented 6 years ago

I keep getting the problem with that the homebridge-camera-ffmpeg package camera stream won’t start (keeps loading and eventually times out) and outputs the error: FFmpeg exited with code 1 in the logs.

FYI, I'm using the debian release on my Synology NAS

I added it to the PACKAGES=ffmpeg list, but no success. I didn’t do anything special in the setup. Homebridge literally consists of this camera accessory and nothing else. Is it working for anyone?

Similar to https://github.com/KhaosT/homebridge-camera-ffmpeg/issues/163

Veldkornet commented 6 years ago

I have discovered that, on my RaspberryPi, I always used the ffmepg from https://github.com/legotheboss/homebridge-camera-ffmpeg-omx, however now if docker, the package architecture is amd64 where the package was built for armhf....

The default ffmpeg doesn't seem to be working. Any ideas?

Veldkornet commented 6 years ago

So when I checked the debug, I found the following:

[2018-9-28 16:45:06] [Camera-ffmpeg] Start streaming video from Back with 1280x720@299kBit
ffmpeg -rtsp_transport tcp -re -i rtsp://username:password@192.168.1.50:88/videoSub -map 0:0 -vcodec h264_omx -pix_fmt yuv420p -r 10 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 299k -payload_type 99 -ssrc 1096090 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params ....................... srtp://192.168.1.50:50130?rtcpport=50130&localrtcpport=50130&pkt_size=1316
ffmpeg version N-92078-g179ed2d2e0 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --arch=amd64 --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree --disable-x86asm
  libavutil      56. 19.101 / 56. 19.101
  libavcodec     58. 31.101 / 58. 31.101
  libavformat    58. 18.103 / 58. 18.103
  libavdevice    58.  4.104 / 58.  4.104
  libavfilter     7. 33.100 /  7. 33.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Unrecognized option 'tune'.
Error splitting the argument list: 
Option not found
[2018-9-28 16:45:06] [Camera-ffmpeg] ERROR: FFmpeg exited with code 1

Right, so I decided to build my own ffmpeg with the following:

apt-get install wget

wget http://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.xz

tar -xf nasm-2.13.03.tar.xz --strip-components=1
sed -e '/seg_init/d' -e 's/pure_func seg_alloc/seg_alloc/' -i include/nasmlib.h
./configure --prefix=/usr &&
make
make install
cd ..

apt-get remove x264
git clone git://git.videolan.org/x264.git
cd x264
./configure --enable-static --enable-shared
make && make install
ldconfig
cd .. 

apt-get install libomxil-bellagio-dev -y
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/src/x264/libx264.a

./configure --arch=amd64 --target-os=linux --enable-gpl --enable-nonfree --enable-libx264 --enable-postproc --enable-swscale --enable-pthreads --enable-version3 --enable-omx --enable-omx-rpi
make -j4
make install`

After this, I tried the stream again and I got the following:

[2018-9-28 17:57:57] [Camera-ffmpeg] Start streaming video from Back with 1280x720@299kBit

ffmpeg -rtsp_transport tcp -re -i rtsp://username:password@192.168.1.50:88/videoSub -map 0:0 -vcodec h264_omx -pix_fmt yuv420p -r 10 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 299k -payload_type 99 -ssrc 13182735 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params ............ srtp://192.168.134.20:53305?rtcpport=53305&localrtcpport=53305&pkt_size=1316

ffmpeg version N-92078-g179ed2d2e0 Copyright (c) 2000-2018 the FFmpeg developers

  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516

  configuration: --arch=amd64 --target-os=linux --enable-gpl --enable-nonfree --enable-libx264 --enable-postproc --enable-swscale --enable-pthreads --enable-version3 --enable-omx --enable-omx-rpi

  libavutil      56. 19.101 / 56. 19.101

  libavcodec     58. 31.101 / 58. 31.101

  libavformat    58. 18.103 / 58. 18.103

  libavdevice    58.  4.104 / 58.  4.104

  libavfilter     7. 33.100 /  7. 33.100

  libswscale      5.  2.100 /  5.  2.100

  libswresample   3.  2.100 /  3.  2.100

  libpostproc    55.  2.100 / 55.  2.100

Guessed Channel Layout for Input Stream #0.1 : mono

Input #0, rtsp, from 'rtsp://username:password;X@192.168.1.50:88/videoSub':

  Metadata:

    title           : IP Camera Video

    comment         : videoSub

  Duration: N/A, start: 0.000000, bitrate: N/A

    Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 90k tbr, 90k tbn, 3520886.88 tbc

    Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s

Codec AVOption tune (Tune the encoding params (cf. x264 --fullhelp)) specified for output file #0 (srtp://192.168.1.20:53305?rtcpport=53305&localrtcpport=53305&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.

Stream mapping:

  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_omx))

Press [q] to stop, [?] for help

[h264_omx @ 0x7f43f44d3000] /opt/vc/lib/libopenmaxil.so not found

Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Conversion failed!

So after this, I just changed my homebridge config from: "vcodec": "h264_omx" to: "vcodec": "h264"

And now everything works.

I'm not sure if the default ffmpeg has x264 on by default, if so, that would have been a much easier fix to just change the video codec :) Too late now though.

iRayanKhan commented 6 years ago

Didn't work for me :(