如何通过“Motion”从我的 IP 摄像机访问 H264 流?

emp*_*les 5 command-line camera 14.04 15.04 motion

什么是 Motion?: Motion 是一个守护程序应用程序,它允许 Linux 用户根据运动检测或时间设置记录网络摄像头和网络摄像头的图片。可以在此处找到如何设置稳定版本的教程。这是Motion 开发人员网站和文档

我的设置:我使用的是便宜的海康威视 2032 IP 摄像机,它设置为 IP 192.168.1.199。它的主流(H264)是:

rtsp://192.168.1.199:554/ISAPI/streaming/channels/101?auth=YWRtaW46MTIzNDU=

(它在 VLC 中工作正常)

据我所知,很遗憾 Motion 在其当前的稳定版本 (3.2.12) 中不支持 H264。但是最新的开发人员构建有一些集成,并且有一个针对它优化的分支。

虽然构建的安装非常复杂,但我尝试收集我在下面的帖子中的分步说明中获得的提示:

编辑: 在这个阶段,我已经下载了 MrDave 在下面推荐我的 Git 版本,我想我有所有的依赖项。按照我收集的说明中的步骤操作后,它最终可以在 1080x720 分辨率下运行。

使用 1920x1080 时,将文件保存到我的图像文件夹时遇到问题:

nuc@nuc:/usr/local/etc$ motion
[0] [NTC] [ALL] conf_load: Processing thread 0 - config file /usr/local/etc/motion.conf
[0] [ALR] [ALL] conf_cmdparse: Unknown config option "sdl_threadnr"
[0] [NTC] [ALL] motion_startup: Motion trunkREVUNKNOWN Started
[0] [NTC] [ALL] motion_startup: Logging to syslog
[0] [NTC] [ALL] motion_startup: Using log type (ALL) log level (NTC)
[0] [NTC] [ENC] ffmpeg_init: ffmpeg LIBAVCODEC_BUILD 3562596 LIBAVFORMAT_BUILD 3555176
[0] [NTC] [ALL] main: Thread 1 is from /usr/local/etc/motion.conf
[0] [NTC] [ALL] main: Thread 1 is device: rtsp://192.168.1.199:554/ISAPI/streaming/channels/101?auth=YWRtaW46MTIzNDU= input -1
[0] [NTC] [ALL] main: Stream port 8081
[0] [NTC] [ALL] main: Waiting for threads to finish, pid: 9028
[1] [NTC] [ALL] motion_init: Thread 1 started , motion detection Enabled
[1] [ALR] [NET] netcam_start: Network Camera thread starting... for url (rtsp://192.168.1.199:554/ISAPI/streaming/channels/101?auth=YWRtaW46MTIzNDU=)
[0] [NTC] [STR] httpd_run: motion-httpd testing : IPV4 addr: 127.0.0.1 port: 8080
[0] [NTC] [STR] httpd_run: motion-httpd Bound : IPV4 addr: 127.0.0.1 port: 8080
[0] [NTC] [STR] httpd_run: motion-httpd/trunkREVUNKNOWN running, accepting connections
[0] [NTC] [STR] httpd_run: motion-httpd: waiting for data on 127.0.0.1 port TCP 8080
[1] [NTC] [NET] netcam_rtsp_open_context: Using tcp transport
[1] [NTC] [NET] netcam_connect_rtsp: Camera connected
[1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 1 items
[1] [ALR] [NET] netcam_handler_loop: Camera handler thread [2] started
[1] [NTC] [STR] http_bindsock: motion-stream testing : IPV4 addr: 127.0.0.1 port: 8081
[1] [NTC] [STR] http_bindsock: motion-stream Bound : IPV4 addr: 127.0.0.1 port: 8081
[1] [NTC] [ALL] motion_init: Started motion-stream server in port 8081 auth Disabled
Memoryaccesserror (core image written).
Run Code Online (Sandbox Code Playgroud)

如果我尝试打开,全分辨率的 avi 和 jpg 为空或不可用。

小智 4

为了获得 rtsp 和 H264 支持,您需要从源代码构建应用程序。源的主要版本位于https://github.com/sackmotion。然而,该源有许多分支实现了各种功能,包括 RTSP/H264。如果您查看 git 中的图表/网络选项卡,您可以看到这些版本并确定哪个最适合您的情况。如果您不熟悉从源代码构建,可以在安装文件中的以下分支https://github.com/Mr-Dave/motion中找到编译和构建运动的基本说明。这些指令已在 12.04 中得到验证,但可能需要稍作修改才能在 14.04 中使用。

请注意,对于您引用的相机,您引用的命令行可能不正确。我观察到的该摄像机的格式是rtsp://user:pwd@ipaddress:554/streaming/channels/1(对于主要流)或rtsp://user:pwd@ipaddress:554/streaming/channels/2对于辅助流。在设置运动相机之前,您应该使用 VLC 或 avplay 验证连接字符串。一旦确认它可以在这些应用程序中工作,您可以将连接字符串motion.conf作为网络摄像头 URL 直接复制到文件中。

最后,如果您想节省此摄像机的 CPU 资源,最好将运动设置为监视较小的 SD 次流,并在运动时使用配置选项触发外部录制应用程序以本机格式录制主 HD 流发生。