ZoneMinder / zoneminder

ZoneMinder is a free, open source Closed-circuit television software application developed for Linux which supports IP, USB and Analog cameras.
http://www.zoneminder.com/
GNU General Public License v2.0
5.04k stars 1.21k forks source link

mpeg stream instead of jpeg is crashing (seg fault) on 1.26.4 [$10] #247

Closed nzbtuxnews closed 7 years ago

nzbtuxnews commented 10 years ago

Upon switching the stream playback to mpeg instead of jpeg, zoneminder appears to hard crash and the monitors status becomes red.

The logs are showing:

getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused Monitor-1: 4161000 - Capturing at 14.93 fps getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused Monitor-1: 4156000 - Processing at 14.93 fps socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused - checkStreamForErrors() socket_sendto( /var/run/zm/zms-345613s.sock ) failed: Connection refused Signal address is 0xa0, from 0x7f7c0c350af7 Got signal 11 (Segmentation fault), crashing Signal address is 0xa0, from 0x7fab20d48af7 Got signal 11 (Segmentation fault), crashing

Switching back to jpeg and restarting causes zoneminder to work OK. what I find strange is the presence of messages such as "Processing at XXfps" and "Capturing at XXfps" which IMO indicates that not all has crashed...

There is a $10 open bounty on this issue. Add to the bounty at Bountysource.

mastertheknife commented 10 years ago

Did you compile zoneminder with crashtrace disabled? Its very difficult to know where is the issue without a backtrace.

lselinger commented 10 years ago

FWIW I can confirm in the debian/ubuntu packages that crashtrace appears to have been disabled (configure line): "./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --sysconfdir=/etc/zm --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --with-mysql=/usr --with-webdir=/usr/share/zoneminder --with-ffmpeg=/usr --with-cgidir=/usr/lib/cgi-bin --with-webuser=www-data --with-webgroup=www-data --enable-crashtrace=no --enable-mmap=yes"

Is there any other way (strace etc) we might be able to grab some valid info for you?

nzbtuxnews commented 10 years ago

Yes I may very well have compiled ZM with crashtrace disabled... Let me recompile and reinstall it with enabled and try that again....

nzbtuxnews commented 10 years ago

Stack trace:

root@server:~# addr2line -e /srv/httpd/cgi-bin/nph-zms 0x4be451 0x7f8fb249f4e0 0x7f8fb4ba8af7 0x7f8fb4c63a12 0x7f8fb4c12037 0x478d48 0x46e8e1 0x46f669 0x407373 0x7f8fb11a9a95 0x407c2d /root/ZoneMinder-1.26.4/src/zm_signal.cpp:89 ??:0 ??:0 ??:0 ??:0 /root/ZoneMinder-1.26.4/src/zm_mpeg.cpp:198 /root/ZoneMinder-1.26.4/src/zm_monitor.cpp:3684 /root/ZoneMinder-1.26.4/src/zm_monitor.cpp:3937 /root/ZoneMinder-1.26.4/src/zm_monitor.h:419 ??:0 /glibc-tmp-1efe086f9214c39528a05e54478eda49/glibc-2.15/csu/../sysdeps/x86_64/elf/start.S:116

Also the relevant zoneminder's log entries at:

http://pastebin.com/aZiLtPTE

mastertheknife commented 10 years ago

Very useful, thank you.

It crashes in the call to avformat_write_header at zm_mpeg.cpp line 198. Now we just have to investigate why.

chriswiggins commented 10 years ago

If the codec hasn't been initialised properly then this will happen

Sent from my iPhone

On 12/11/2013, at 7:48 pm, "Kfir Itzhak" notifications@github.com<mailto:notifications@github.com> wrote:

Very useful, thank you.

It crashes in the call to avformat_write_header at zm_mpeg.cpp line 198. Now we just have to investigate why.

— Reply to this email directly or view it on GitHubhttps://github.com/ZoneMinder/ZoneMinder/issues/247#issuecomment-28272265.

nzbtuxnews commented 10 years ago

Testing to do on the codec?

Why wouldn't it initialize properly?

fri-K commented 10 years ago

ZoneMinder v1.26.5-1 (deb from ppa:iconnor/zoneminder) Ubuntu 12.04.3 x86_64 libavformat53: /usr/lib/x86_64-linux-gnu/libavformat.so.53.21.1 Running mpeg stream (event or live) causes crash:

2013-12-18 21:33:09.887744 zms 1985 ERR Backtrace 11: /usr/lib/cgi-bin/nph-zms() [0x406679] zm_signal.cpp 96 2013-12-18 21:33:09.854358 zms 1985 ERR Backtrace 10: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f7d9c24c76d] zm_signal.cpp 96 2013-12-18 21:33:09.820996 zms 1985 ERR Backtrace 9: /usr/lib/cgi-bin/nph-zms() [0x40765e] zm_signal.cpp 96 2013-12-18 21:33:09.787640 zms 1985 ERR Backtrace 8: /usr/lib/cgi-bin/nph-zms() [0x44d60d] zm_signal.cpp 96 2013-12-18 21:33:09.754243 zms 1985 ERR Backtrace 7: /usr/lib/cgi-bin/nph-zms() [0x44c2ac] zm_signal.cpp 96 2013-12-18 21:33:09.720858 zms 1985 ERR Backtrace 6: /usr/lib/cgi-bin/nph-zms() [0x451d7e] zm_signal.cpp 96 2013-12-18 21:33:09.687503 zms 1985 ERR Backtrace 5: /usr/lib/cgi-bin/nph-zms() [0x451717] zm_signal.cpp 96 2013-12-18 21:33:09.646200 zms 1985 ERR Backtrace 4: /usr/lib/x86_64-linux-gnu/libavformat.so.53(avformat_write_header+0x3a6) [0x7f7d9ef62c36] zm_signal.cpp 96 2013-12-18 21:33:09.618113 zms 1985 ERR Backtrace 3: /usr/lib/x86_64-linux-gnu/libavformat.so.53(+0x3e93f) [0x7f7d9eeee93f] zm_signal.cpp 96 2013-12-18 21:33:09.576378 zms 1985 ERR Backtrace 2: /usr/lib/x86_64-linux-gnu/libavformat.so.53(avio_write+0x2a) [0x7f7d9eedf83a] zm_signal.cpp 96 2013-12-18 21:33:09.543010 zms 1985 ERR Backtrace 1: /lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0) [0x7f7d9d5a2cb0] zm_signal.cpp 96 2013-12-18 21:33:09.509725 zms 1985 ERR Backtrace 0: /usr/lib/cgi-bin/nph-zms() [0x46f3a2] zm_signal.cpp 96 2013-12-18 21:33:09.484567 zms 1985 ERR Signal address is 0x10, from 0x7f7d9eedf83a zm_signal.cpp 75 2013-12-18 21:33:09.398851 zms 1985 ERR Got signal 11 (Segmentation fault), crashing

What can be wrong? What else should I try? I thing that debug doesn't produce more information.

Sune1337 commented 10 years ago

Reading the 1.27 code; it seems the headers are written differently if using any of the following formats: mp4, mov, or 3gp. Could this be the cause?

I get the crashes too if trying to use mpeg as format (or the default swf); but if i try mp4 it doesnt crash. Unfortunately my browser does not support that !

fri-K commented 10 years ago

@Sune1337 so you are able to view stream in ex totem video player using url: http://hostname/zm/cgi-bin/nph-zms?mode=mpeg&monitor=X&format=mp4&auth=############ My zm segfaults if I use such url.

Sune1337 commented 10 years ago

I made a mistake when i tested it. What i did was that i changed format to mp4 in Options -> MPEG_LIVE_FORMAT and MPEG_REPLAY_FORMAT to mp4, and then Options -> Medium B/W -> WEB_M_STREAM_METHOD to mpeg.

This caused my browser to display a "plugin needed" box; so i assumed stuff worked :D

Now that i play the URL in VLC, I can see it crash. I did verify VLC by changing back to default jpeg; and that worked.

Sorry for the confusion.

Sune1337 commented 10 years ago

I tested with an older ffmpeg too; it crashes on the same location. ffmpeg-version: ffmpeg 0.8.10-6:0.8.10-1 libavutil 51. 22. 2 / 51. 22. 2 libavcodec 53. 35. 0 / 53. 35. 0 libavformat 53. 21. 1 / 53. 21. 1 libavdevice 53. 2. 0 / 53. 2. 0 libavfilter 2. 15. 0 / 2. 15. 0 libswscale 2. 1. 0 / 2. 1. 0 libpostproc 52. 0. 0 / 52. 0. 0

2014-04-03 17_03_02-crunchbang - vmware player non-commercial use only

Sune1337 commented 10 years ago

I also built ffmpeg with debug symbols, so i could get abit more stacktrace. This was done with ffmpeg: built on Apr 1 2014 22:16:08 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4) configuration: --extra-libs=-ldl --enable-shared --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --disable-optimizations --disable-stripping libavutil 52. 71.100 / 52. 71.100 libavcodec 55. 56.107 / 55. 56.107 libavformat 55. 36.100 / 55. 36.100 libavdevice 55. 11.100 / 55. 11.100 libavfilter 4. 3.100 / 4. 3.100 libswscale 2. 5.102 / 2. 5.102 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100

stacktrace: 2014-04-03 17_09_47-crunchbang - vmware player non-commercial use only

mux.c:325 2014-04-03 17_12_49-crunchbang - vmware player non-commercial use only

I checked the value of 's-internal', and it's 0; so i guess that's why the crash happens.

Sune1337 commented 10 years ago

I noticed there was a recommended version of ffmpeg for ZoneMinder according to ZM wiki; so i tested that too. zms crashes in the same place.

ffmpeg version N-62063-g0965670 built on Apr 3 2014 17:32:33 with gcc 4.7 (Debian 4.7.2-5) configuration: --enable-gpl --enable-shared --enable-pthreads --enable-libx264 --disable-optimizations --disable-stripping libavutil 52. 72.100 / 52. 72.100 libavcodec 55. 56.107 / 55. 56.107 libavformat 55. 36.101 / 55. 36.101 libavdevice 55. 11.100 / 55. 11.100 libavfilter 4. 3.100 / 4. 3.100 libswscale 2. 6.100 / 2. 6.100 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100

Sune1337 commented 10 years ago

I've create a branch to improve the ffmpeg support when streaming with zms, please look at https://github.com/Sune1337/ZoneMinder/tree/zms/ffmpeg if you're interested. I will create a pull-request for this branch after some more testing and feedback. Specifically it would be nice with input from you guys.

Features:

Note; which format/codec combos that work is pretty much up to what version of FFmpeg you're using. If something doesn't work I've found it really helpful to run...

LOG_FLUSH=1 LOG_PRINT=1 QUERY_STRING="mode=mpeg&monitor=3&scale=100&bitrate=750000&maxfps=30&format=mpegts/h264" src/zms > /tmp/test.ts

...to get helpful debug-text from FFmpeg.

Sune1337 commented 10 years ago

What works best for me right now is VLC + format=mpegts/mpeg4 + bitrate=75 AVI has generally worked really well too.

tazeat commented 10 years ago

Were you able to test this any more? I tried to locally merge your branch in to the main master to attempt to build it, but I'm getting a few conflicts on zm_mpeg.cpp I haven't tried to resolve. Otherwise using mpeg causes segfaults as described above. Thanks!

Sune1337 commented 10 years ago

Hi.

Ive been swamped with work, but its cooling down and im soon going to finish this. On 27 Jun 2014 20:00, "tazeat" notifications@github.com wrote:

Were you able to test this any more? I tried to locally merge your branch in to the main master to attempt to build it, but I'm getting a few conflicts on zm_mpeg.cpp I haven't tried to resolve. Otherwise using mpeg causes segfaults as described above. Thanks!

— Reply to this email directly or view it on GitHub https://github.com/ZoneMinder/ZoneMinder/issues/247#issuecomment-47381093 .

Sune1337 commented 9 years ago

I noticed i referenced some old branch a few posts up. The branch is really https://github.com/Sune1337/ZoneMinder/tree/zms/videostream-improvements

Sune1337 commented 9 years ago

check out https://github.com/ZoneMinder/ZoneMinder/pull/404 for details on how to resolve conflicts.

nzbtuxnews commented 9 years ago

FYI, not sure how I supposedly added a bounty to this bug report or even changed the title on the 27th of june.....

connortechnology commented 9 years ago

bump, @Sune1337 should we be looking at merging the videostream-improvements branch? Did it fix this crash?

Sune1337 commented 9 years ago

I'm not sure if the videostream-improvements fixed this issue for Ipallard1. I suggested it because the errors reminded me of my experience with video-streaming from ZM.

My conclusion from streaming video from ZM is that it basically does not work in the current code. I couldn't get it working and i didnt find anyone claiming that it worked for them. the branch works, but can be improved with support for variable framerate; one can probably optimize ffmpeg settings, and so on and so forth :) but it WORKS :)

Sune1337 commented 9 years ago

I think the current code (in master branch) can only generate MPEG2 video at certain framerates. i think that was the bottom issue with me not being able to stream from my 5fps cameras.

Sune1337 commented 9 years ago

hmm. Was it perhaps the mpeg video stream that was used before the mjpeg streaming was implemented?

Sune1337 commented 9 years ago

also @Ipallard1, im not looking for a bounty, so dont worry about that.

connortechnology commented 9 years ago

Can you test current master branch to see if I have fixed this crash?

kk7ds commented 9 years ago

As of commit 2671e71e33543b17ef727994c8beddce0a6ce45e, I no longer see the crash (Ubuntu 12.04). However, it's still not working. I get about 500ms of moving video and then it freezes. Each refresh gets me another 500ms or so, but I can never "stream". I assume that's a different bug though.

SteveGilvarry commented 7 years ago

Closing as part of 2017 cleanup, not saying not valid, just no one is working on this and don't believe anyone is planning on doing so.