Motion - Support Question 2015x 05x 06x 013406

motion segfaults in ffmpeg

Question

I've compiled motion against my ffmpeg and it segfaults on detecting motion. I'm not quite sure it's motion's fault, but mpv plays videos fine.

(gdb) run
Starting program: /usr/bin/motion -n
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[0] Processing thread 0 - config file /etc/motion.conf
[0] Unknown config option "sql_log_image"
[0] Unknown config option "sql_log_snapshot"
[0] Unknown config option "sql_log_mpeg"
[0] Unknown config option "sql_log_timelapse"
[0] Unknown config option "sql_query"
[0] Motion 3.2.12 Started
[0] ffmpeg LIBAVCODEC_BUILD 3676772 LIBAVFORMAT_BUILD 3676517
[0] Thread 1 is from /etc/motion.conf
[New Thread 0x39db34ab700 (LWP 11513)]
[1] Thread 1 started
[New Thread 0x39db2caa700 (LWP 11514)]
[1] cap.driver: "uvcvideo"
[1] cap.card: "CNF7051"
[1] cap.bus_info: "usb-0000:00:14.0-4"
[1] cap.capabilities=0x84200001
[1] - VIDEO_CAPTURE
[1] - STREAMING
[0] motion-httpd/3.2.12 running, accepting connections
[0] motion-httpd: waiting for data on port TCP 8080
[1] Config palette index 8 (YU12) doesn't work.
[1] Supported palettes:
[1] 0: YUYV (YUV 4:2:2 (YUYV))
[1] Selected palette YUYV
[1] Test palette YUYV (640x480)
[1] Using palette YUYV (640x480) bytesperlines 1280 sizeimage 614400 colorspace 00000008
[1] found control 0x00980900, "Brightness", range -64,64 
[1]    "Brightness", default 0, current 0
[1] found control 0x00980901, "Contrast", range 0,95 
[1]    "Contrast", default 25, current 25
[1] found control 0x00980902, "Saturation", range 0,128 
[1]    "Saturation", default 64, current 64
[1] found control 0x00980903, "Hue", range -40,40 
[1]    "Hue", default 0, current 0
[1] found control 0x00980910, "Gamma", range 72,500 
[1]    "Gamma", default 100, current 100
[1] mmap information:
[1] frames=4
[1] 0 length=614400
[1] 1 length=614400
[1] 2 length=614400
[1] 3 length=614400
[1] Using V4L2
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 8081

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x39db34ab700 (LWP 11513)]
0x0000039db74bd4b9 in avformat_new_stream () from /usr/lib64/libavformat.so.56
(gdb) bt
#0  0x0000039db74bd4b9 in avformat_new_stream () from /usr/lib64/libavformat.so.56
#1  0x0000000000423201 in ffmpeg_open (ffmpeg_video_codec=0x2beee10 "mpeg4", 
    filename=0x2bebd88 "/var/log/motion/01-20150506042644.avi", 
    y=0x39db23a3010 "\n\n\b\n\n\n\n\n\n\b\v\v\v\v\n\n\a\v\n\n\n\n\b\b\b\n\b\a\b\b\n\n\n\006\006\a\006\b\b\n\v\v\n\v\a\006\006\n\b\b\a\a\a\b\b\a\b\a\006\a\a\b\b\a\a\b\a\a\a\a\a\b\b\b\a\006\006\006\006\006\006\a\b\b\b\006\006\a\a\a\b\b\a\b\a\a\a\006\006\006\a\a\a\006\a\a\a\006\006\006\005\006\005\006\006\a\a\006\006\a\006\006\005\005\006\005\006\006\005\006\a\a\006\006\005\005\005\005\005\003\005\005", '\006' <repeats 15 times>, "\a\a\006\a\006\a\a\a\006\006\005\003\005\005\005\005\005\006\006\006\006\005\005\005\006\005\005\003\003\005\005\006\006\005\005\005\005\005\003\005\005\005\006"..., 
    u=0x39db23ee010 "\213\214\214\211\206\206\207\211\213\213\212\211\207\207\207\210\212\214\212\210\207\210\211\210\211\211\211\212\211\211\212\212\210\206\206\206\206\207\207\207\207\210\210\207\207\210\207\210\211\211\210\207\211\213\212\210\210\210\210\210\211\212\211\207\206\206\207\211\210\207\207\207\207\207\210\210\210\207\207\210\210\207\210\207\207\207\207\211\212\212\210\207\210\210\210\207\207\207\210\210\207\207\206\206\205\206\210\210\210\210\207\207\206\207\211\211\207\207\210\211\211\210\207\210\207\207\210\210\210\207\207\206\206\207\210\210\207\207\206\206\205\205\206\206\206\206\206\210\207\206\207\210\210\210\207\206\206\206\206\206\206\205\205\203\202\203\205\206\206\206\207\210\210\207\207\210\207\206\206\207\207\206\206\205\205\206\207\207\207\210\210\211\211\210\210\210\207\206\206\210"..., 
    v=0x39db2400c10 "\201\201\201\201\201\201\201\200\200\200\200\200\200\200\201\202\202\203\201\200\177\200\201\200\177\177\200\200\201\201\201\201\201\201\201\202\200\177\177~}~\177\200\201\201\201\200\201\201\200\201\201\200\177\177\177\177\200\201\201\200\177\177\200\200\177\177\177~~~\177\200\200\200\200\200\177\177\177\177\177~~~\177\200\200\200\177\177\177\177\177\177\177\177\177\200\200\177\177\200\177\177\177\200\200\177\177\177\200\200\200\177~~\177\200\200\200\200\177\177\177~\177\177\200\200\---Type <return> to continue, or q <return> to quit---
200\200\200\200\200\200\200\177\177\177\200\200\200\200\177\177\200\200~~~\177\177\177\200\177\177\177\177\177\177\177\200\200\200\200\177\177~~\200\200\177\177\177~\177\177\177\177\200\200\201\200\177\177\200\200\201\200\200\177\177\200\200\200\177\177\177"..., width=640, height=<optimized out>, rate=-1304502256, bps=<optimized out>, 
    vbr=<optimized out>) at ffmpeg.c:412
#2  0x000000000041aeac in event_ffmpeg_newfile (cnt=0x2be8490, 
    type=<optimized out>, 
    img=0x39db23a3010 "\n\n\b\n\n\n\n\n\n\b\v\v\v\v\n\n\a\v\n\n\n\n\b\b\b\n\b\a\b\b\n\n\n\006\006\a\006\b\b\n\v\v\n\v\a\006\006\n\b\b\a\a\a\b\b\a\b\a\006\a\a\b\b\a\a\b\a\a\a\a\a\b\b\b\a\006\006\006\006\006\006\a\b\b\b\006\006\a\a\a\b\b\a\b\a\a\a\006\006\006\a\a\a\006\a\a\a\006\006\006\005\006\005\006\006\a\a\006\006\a\006\006\005\005\006\005\006\006\005\006\a\a\006\006\005\005\005\005\005\003\005\005", '\006' <repeats 15 times>, "\a\a\006\a\006\a\a\a\006\006\005\003\005\005\005\005\005\006\006\006\006\005\005\005\006\005\005\003\003\005\005\006\006\005\005\005\005\005\003\005\005\005\006"..., dummy1=<optimized out>, dummy2=<optimized out>, currenttime_tm=<optimized out>)
    at event.c:413
#3  0x000000000041b626 in event (cnt=0x2be8490, type=4, 
    image=0x39db23a3010 "\n\n\b\n\n\n\n\n\n\b\v\v\v\v\n\n\a\v\n\n\n\n\b\b\b\n\b\a\b\b\n\n\n\006\006\a\006\b\b\n\v\v\n\v\a\006\006\n\b\b\a\a\a\b\b\a\b\a\006\a\a\b\b\a\a\b\a\a\a\a\a\b\b\b\a\006\006\006\006\006\006\a\b\b\b\006\006\a\a\a\b\b\a\b\a\a\a\006\006\006\a\a\a\006\a\a\a\006\006\006\005\006\005\006\006\a\a\006\006\a\006\006\005\005\006\005\006\006\005\006\a\a\006\006\005\005\005\005\005\003\005\005", '\006' <repeats 15 times>, "\a\a\006\a\006\a\a\a\006\006\005\003\005\005\005\005\005\006\006\006\006\005\005\005\006\005\005\003\003\005\005\006\006\005\005\005\005\005\003\005\005\005\006"..., filename=0x0, eventdata=0x0, tm=0x39dac000ea8) at event.c:713
#4  0x0000000000407d4b in motion_detected (cnt=0x2be8490, dev=5, img=0x39dac000e90)
    at motion.c:417
---Type <return> to continue, or q <return> to quit---
#5  0x0000000000406e7b in motion_loop (arg=<optimized out>) at motion.c:1545
#6  0x0000039db79af2c4 in start_thread () from /lib64/libpthread.so.0
#7  0x0000039db5e10ead in clone () from /lib64/libc.so.6

Environment

Motion version: 3.2.12
ffmpeg version: 2.6.2
Libraries: ffmpeg
Server OS: Gentoo Linux, kernel 3.19.5-grsec
-- L29Ah - 06 May 2015

Answer

Actually, the ebuild for media-video/motion-3.2.12-r2 is broken. Gentoo introduced some patches to support newer versions of ffmpeg, however the maintainer apparently forgot to regenerate configure script, which effectively nullifies a part of them. As a result, AVFormatContext structure is improperly initialized, causing segfault. See https://bugs.gentoo.org/show_bug.cgi?id=552224 for details.

So, you have to either:
  1. Downgrade your ffmpeg to 1.x version and recompile motion, it will work just fine,
  2. Recompile the package using ebuild from gentoo bugzilla,
  3. Wait for package maintainer to fix the problem.
Topic revision: r2 - 15 Jun 2015, MarcinJurkowski
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.