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

[noBUG] - Can't get ffmpeg to work propperly #27

Open
x23piracy opened this issue Mar 7, 2019 · 25 comments
Open

[noBUG] - Can't get ffmpeg to work propperly #27

x23piracy opened this issue Mar 7, 2019 · 25 comments

Comments

@x23piracy
Copy link

Hi,

i am on a rpi 3 and ffmpeg is always exiting with error code 1 when i try to stream, one frame snapshots are no problem it's only when streaming should start and ffmpeg gets used.

First i tried to install ffmpeg this way: http://jollejolles.com/installing-ffmpeg-with-h264-support-on-raspberry-pi/

Then i decided to try ffmpeg from apt-get but with both no go.
homebridge is running under pi user context, is there something i need to adjust?

Also i really would like to try to install ffmpeg with brew like suggested in this project but i can'T get linuxbrew to run, i followed their instruction but i cannot type brew in command line, command not found.

Can someone help me to get ffmpeg running propper?
Is someone here were it's working with an rpi?

Regards Jens

@renedivx
Copy link

renedivx commented Mar 8, 2019

Hi, i have same problem like you before. This solves my problem

  1. install build tools
    sudo apt-get install pkg-config autoconf automake libtool libx264-dev

  2. download and build fdk-aac
    git clone https://github.com/mstorsjo/fdk-aac.git
    cd fdk-aac
    ./autogen.sh
    ./configure --prefix=/usr/local --enable-shared --enable-static
    make -j4
    sudo make install
    sudo ldconfig
    cd ..

  3. download and build ffmpeg
    git clone https://github.com/FFmpeg/FFmpeg.git
    cd FFmpeg
    ./configure --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
    make -j4
    sudo make install

It takes some times.

Than make sure that your dafang video and audo settings are correct.

video settings
video format: FixedQp
Size: 1280x720
FrameRate: 21
BitRate 299

Audio settings
audio format: mp3
filter: filter 2
in rate 16000
out rate 16000

with this settings all works fine for me, maybe it will solve your problem too.

best regards rene

@x23piracy
Copy link
Author

x23piracy commented Mar 8, 2019

Hey good morning,

thank you for the detailed answer :)
I am currently trying these steps.

Since i already compiled my own ffmpeg and also installed it by at-get, is there something i need to uninstall first?

Before i tried the apt-get ffmpeg i triggered "sudo make uninstall" for both lib h264 and ffmpeg after that i installed ffmpeg by apt-get and its currently installed.

Should i remove ffmpeg with apt-get first?

The video settings you are talking about need to be applied to config.json?
EDIT: Ok got it, webcam webif settings for AV... ;)

idk why but rene sounds german? :)

Regards X23

@renedivx
Copy link

renedivx commented Mar 8, 2019

No problem ;-)

That is also a good question for me. I am also not expert with this things. I search and try different things to solve my problem. What i write before works great for me.

But i think its no problem if you install it without remove the old install. If you use a Raspberry for it, you can make with PiBaker a backup. If you make this frist you can test, if not working you can flash your sd card back with the backup. Like this i do it many times until all works ;-)

Yes i am german, you too?

Best regards rene

@x23piracy
Copy link
Author

Hi,

ok i applied all and now i can stream but its not really running smooth, not really moving pictures ;) and then it stucks somehow and breaks or is just insanely bad perfoming but hey thats more then before :)

I am a german too. Prost

Regards X23

@renedivx
Copy link

renedivx commented Mar 8, 2019

Here is my Config. Maybe that help you too. But htere i use a own MQTT Server. If you dont have, you must change this settings.

{
"platform": "Dafang",
"mqtt": {
"hostBroker": false,
"port": 1883,
"host": "192.168.22.104",
"debug": true
},
"cameras": [
{
"cameraName": "terrasse",
"cameraRTSPStreamUrl": "rtsp://192.168.22.69:8554/unicast",
"mqttTopic": "haus/terrasse/#",
"folder": "/home/pi/kamera/",
"recordingDirectoryPathFormat": "DD-MM-YYYY",
"recordingFilenameFormat": "DD-MM-YYYY-kk-mm-ss",
"accessories": [
{
"name": "Bewegungssensor",
"type": "richMotionSensor",
"threshold": 100000
},
{
"name": "Auto Bewegung",
"type": "autoMotionTrackingSwitch"
},
{
"name": "Nachtsichtsensor",
"type": "nightVisionSensor",
"threshold": 0
},
{
"name": "Nachtsicht",
"type": "nightVisionSwitch"
},
{
"name": "Auto Nachtsicht",
"type": "autoNightVisionSwitch"
},
{
"name": "Links",
"type": "moveCamera",
"axis": "horizontal",
"direction": "left"
},
{
"name": "Rechts",
"type": "moveCamera",
"axis": "horizontal",
"direction": "right"
},
{
"name": "Hoch",
"type": "moveCamera",
"axis": "vertical",
"direction": "up"
},
{
"name": "Runter",
"type": "moveCamera",
"axis": "vertical",
"direction": "down"
},
{
"name": "Video aufnehmen",
"type": "recordVideo"
},
{
"name": "Audio aufnehmen",
"type": "recordAudio"
},
{
"name": "Bild aufnehmen",
"type": "captureImage"
},
{
"name": "RPi Speicher",
"type": "storageSensor"
},
{
"name": "Speicher bereinigen",
"type": "clearStorage"
},
{
"name": "Stream zurücksetzen",
"type": "resetFFMPEG"
},
{
"name": "Helligkeit",
"type": "brightness"
},
{
"name": "Neustarten",
"type": "restartSwitch"
},
{
"name": "Kalibrieren",
"type": "recalibrateSwitch"
}
],
"videoConfig": {
"source": "-rtsp_transport tcp -re -i rtsp://192.168.22.69:8554/unicast",
"stillImageSource": "-i http://root:[email protected]/cgi-bin/currentpic.cgi",
"maxStreams": 2,
"maxWidth": 1280,
"maxHeight": 720,
"maxFPS": 21,
"maxBitrate": 299,
"vcodec": "h264_omx",
"audio": false,
"packetSize": 188
}
}
]
},

@x23piracy
Copy link
Author

x23piracy commented Mar 8, 2019

Thanks :) i have my own mosquitto ;) having sonoffs and other stuff like that.
Do you have the 360 one? I first bought the cheaper dafang without movement.

@renedivx
Copy link

renedivx commented Mar 8, 2019

Hi,

ok i applied all and now i can stream but its not really running smooth, not really moving pictures ;) and then it stucks somehow and breaks or is just insanely bad perfoming but hey thats more then before :)

I am a german too. Prost

Regards X23

Ok great to hear that you can start now the stream. Have you add videoconfig like this to the config.json

"videoConfig": {
"source": "-rtsp_transport tcp -re -i rtsp://192.168.22.69:8554/unicast",
"stillImageSource": "-i http://root:[email protected]/cgi-bin/currentpic.cgi",
"maxStreams": 2,
"maxWidth": 1280,
"maxHeight": 720,
"maxFPS": 21,
"maxBitrate": 299,
"vcodec": "h264_omx",
"audio": false,
"packetSize": 188

My complete settings included this you can above
best regards rene

@x23piracy
Copy link
Author

Hi,

not yet, i adjusted the settings you told me initally to the cameras webif settings, was that wrong or is that videoconfig part also needed?

@renedivx
Copy link

renedivx commented Mar 8, 2019

Thanks :) i have my own mosquitto ;) having sonoffs and other stuff like that.
Do you have the 360 one? I first bought the cheaper dafang without movement.

Yes i have the dafang with 360 view.

@renedivx
Copy link

renedivx commented Mar 8, 2019

Hi,

not yet, i adjusted the settings you told me initally to the cameras webif settings, was that wrong or is that videoconfig part also needed?

Ok correct. you need to add this seetings in config.json too. Like this works great for me.

@x23piracy
Copy link
Author

Ok i will add this and try :)

@renedivx
Copy link

renedivx commented Mar 8, 2019

Ok great that i can help you. ;-)
Best regards rene

@x23piracy
Copy link
Author

x23piracy commented Mar 8, 2019

Btw. i am always messing up with the hard formatting needs of the config.json when i try to add stuff. I really hate it...meh :)

@renedivx
Copy link

renedivx commented Mar 8, 2019

Have you install homebridge-config-ui-x v3.9.6? There you can easy edit the confirm and see also directly if something is wrong. Its help me a lot

@x23piracy
Copy link
Author

Erm no didnt knew its existing hehe ;)

@x23piracy
Copy link
Author

Danke für den Tip :)

@renedivx
Copy link

renedivx commented Mar 8, 2019

Danke für den Tip :)

Gerne ;-)

@x23piracy
Copy link
Author

but i can't get it to work smoothly, i can see movement from time to time but then it stucks, i console i have seen another exit code 1, i removed ffmpeg from repository and installed again from source, lets see if this helps.

@x23piracy
Copy link
Author

x23piracy commented Mar 8, 2019

Its working for some time but in something like slomo then it stops and homekit is telling me no answer from camera... the camera is then useless with home until i reboot it while the webif is normally responding to the camera, strange.

@renedivx
Copy link

renedivx commented Mar 8, 2019

Ok sorry to hear. maybe you need for your camera other settings like me with the Dafang 360 view. Play something with the settings. maybe this will help.

@x23piracy
Copy link
Author

ok i found out that the rtsp server of the cam is crashing, stream to vlc wasn't working until reboot that means the service crashed.

@x23piracy
Copy link
Author

x23piracy commented Mar 8, 2019

hmm i dont understand this, vlc is eating everything applied to the video stream settings (webif) of the camera, why is home such a she-goat ;P regarding to video streams or is this still a ffmpeg issue?

is there anything i can do to debug this to find the problem?

Regards X23

@x23piracy
Copy link
Author

x23piracy commented Mar 8, 2019

Hi,

fun fact, streaming works very good with camera-ffmpeg with the same ffmpeg binary causing problems when trying to stream with dafang plugin.

fun fact two, streaming works but not stillImage :) hehe now i need to combine both plugins.
It gets stranger and stranger...

@tradziej
Copy link

tradziej commented Jan 7, 2020

For people with a similar problem:

You have to remove -rtsp_transport tcp from video configuration, and have it like:

"videoConfig": {
              "source": "-i rtsp://192.168.0.15:8554/unicast",
              "stillImageSource": "-i rtsp://192.168.0.15:8554/unicast -vframes 1 -r 1",
              "maxFPS": 30,
              "maxWidth": 1280,
              "maxHeight": 720,
              "videoFilter": "none",
              "maxBitrate": 1024,
              "packetSize": 188,
              "maxStreams": 2,
              "vcodec": "h264_omx",
              "audio": true,
              "debug": true
          }

@Cocco17
Copy link

Cocco17 commented Aug 4, 2020

FYI - for installations on Raspberry Pi's use:

    sudo apt install ffmpeg -y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants