Cameras ip no linux

Cameras ip no linux

This is a short «howto» guide to create a simple NVR (network video recorder) using a bash script on Linux to capture video from one or more network IP cameras. I’ve written this guide using Hikvision cameras and an Arch Linux VM running on ESXi 6.0, however this can easily be adapted to other Linux distributions, *BSD distributions, or other camera manufacturers. This guide assumes low- to moderate-familiarity with bash.

This script will save the video stream from your cameras 24/7. There’s no smart detection, GPU acceleration, or machine learning. If you have a break-in, look at the video files. If you need more features, I highly recommend Blue Iris.

Use at your own risk. This is for educational purposes only.

Software Required

  • Favorite Linux distribution (I’m using Arch, but anything will work)
  • ffmpeg (I have 3.4.1 installed)

High-Level Script Explanation

  1. Log into your camera’s webserver to specify LQ/HQ settings. For Hikvision, I entered the IP of the camera using a browser and could set all of the quality settings needed. This step isn’t strictly necessary, but is useful if you want to increase or decrease your bitrate. In any event, you’ll use the ip address, username and password to access the video feed from your camera.
  2. The scripts are executed using cron (use ‘crontab-e’ to edit).
  3. Cron executes ‘record_hq’ every 15 minutes to capture and store «high quality» video files.
  4. Cron executes ‘record_lq’ every 3 hours to capture and store «low quality» video files.
  5. Cron executes ‘record_delete’ every 3 hours to delete old video captures. I store HQ files for a short period and LQ files for much longer, but you’ll need to calculate depending on your available storage. I store HQ files directly on the NAS and store LQ files locally, and them move them every 3 hours to the NAS.
  6. The following are copied below. Please read to understand how to adapt them to your configuration. This is not «cut and paste» although I’ve tried to make it easy to understand. Hopefully you only need to change the variables.
Читайте также:  Linux virtual hard disk

Cron Job File

0,15,30,45 * * * * /home/USERNAME/record_hq.sh 0 */3 * * * /home/USERNAME/record_lq.sh 45 */3 * * * /home/USERNAME/record_delete.sh

Script 1 — HQ Recording

#!/bin/sh # record_hq.sh # Record ip cam in segments # This will print the current date and time in a format appropriate for storage STARTTIME=$(/bin/date +»%m.%d.%Y»)_»[«$(/bin/date +»%H»)h_$(/bin/date +»%M»)m_$(/bin/date +»%S»)s»]» ## IP Camera Names ## # Creating date stamps for each of the five cameras CAM1D=CAM1D_$STARTTIME CAM2D=CAM2D_$STARTTIME CAM3D=CAM3D_$STARTTIME CAM4D=CAM4D_$STARTTIME CAM5D=CAM5D_$STARTTIME ## Network and Local Storage Locations ## HQDIR=»/path/to/network/storage/for/HQ/files/» #Trailing ‘/’ is necessary here ## Record Time per File ## HQLENGTH=»900″ # (Runtime expressed in seconds) ## Record Settings ## # # -v 0 // Log level = 0 # -i // Input url # -vcidec // Set the video codec. This is an alias for «-codec:v». # -an // Disable audio recording # -t // Stop writing the output after its duration reaches duration # ffmpeg -v 0 -rtsp_transport tcp -i «rtsp://CAM_USERNAME:CAM_PASSWORD@CAM1_IP_ADDRESS:554/Streaming/Channels/1» -vcodec copy -an -t $HQLENGTH $HQDIR$CAM1D.mkv & ffmpeg -v 0 -rtsp_transport tcp -i «rtsp://CAM_USERNAME:CAM_PASSWORD@CAM2_IP_ADDRESS:554/Streaming/Channels/1» -vcodec copy -an -t $HQLENGTH $HQDIR$CAM4D.mkv & ffmpeg -v 0 -rtsp_transport tcp -i «rtsp://CAM_USERNAME:CAM_PASSWORD@CAM3_IP_ADDRESS:554/Streaming/Channels/1» -vcodec copy -an -t $HQLENGTH $HQDIR$CAM2D.mkv & ffmpeg -v 0 -rtsp_transport tcp -i «rtsp://CAM_USERNAME:CAM_PASSWORD@CAM4_IP_ADDRESS:554/Streaming/Channels/1» -vcodec copy -an -t $HQLENGTH $HQDIR$CAM3D.mkv & ffmpeg -v 0 -rtsp_transport tcp -i «rtsp://CAM_USERNAME:CAM_PASSWORD@CAM5_IP_ADDRESS:554/Streaming/Channels/1» -vcodec copy -an -t $HQLENGTH $HQDIR$CAM5D.mkv &

Script 2 — LQ Recording

#!/bin/sh # record_lq.sh # Record ip cam in segments STARTTIME=$(/bin/date +»%m.%d.%Y»)_»[«$(/bin/date +»%H»)h_$(/bin/date +»%M»)m_$(/bin/date +»%S»)s»]» ## IP Camera Names ## CAM1D=CAM1D_$STARTTIME CAM2D=CAM2D_$STARTTIME CAM3D=CAM3D_$STARTTIME CAM4D=CAM4D_$STARTTIME CAM5D=CAM5D_$STARTTIME ## Network and Local Storage Locations ## # Pay attending to when a trailing ‘/’ is used and when it is not LQDIR=»/path/to/network/storage/for/LQ/files/» LOCALFILES=»/LocalCAM/*» LOCALSTORE=»/LocalCAM/» LOCALSTOREF=»/LocalCAM» ## Record Time per File ## LQLENGTH=»10800″ # (Runtime expressed in seconds) ## Store LQ files locally first, then move to NAS ## Move files in local storage older than 190 minutes find $LOCALSTOREF -maxdepth 1 -type f -mmin +190 -exec mv ‘<>‘ $LQDIR \; ## Record Settings ## # # -v 0 // Log level = 0 # -i // Input url # -vcidec // Set the video codec. This is an alias for «-codec:v». # -an // Disable audio recording # -t // Stop writing the output after its duration reaches duration # ffmpeg -v 0 -rtsp_transport tcp -i «rtsp://CAM_USERNAME:CAM_PASSWORD@CAM1_IP_ADDRESS:554/Streaming/Channels/2» -vcodec copy -an -t $LQLENGTH $LOCALSTORE$CAM1D.mkv & ffmpeg -v 0 -rtsp_transport tcp -i «rtsp://CAM_USERNAME:CAM_PASSWORD@CAM2_IP_ADDRESS:554/Streaming/Channels/2» -vcodec copy -an -t $LQLENGTH $LOCALSTORE$CAM4D.mkv & ffmpeg -v 0 -rtsp_transport tcp -i «rtsp://CAM_USERNAME:CAM_PASSWORD@CAM3_IP_ADDRESS:554/Streaming/Channels/2» -vcodec copy -an -t $LQLENGTH $LOCALSTORE$CAM2D.mkv & ffmpeg -v 0 -rtsp_transport tcp -i «rtsp://CAM_USERNAME:CAM_PASSWORD@CAM4_IP_ADDRESS:554/Streaming/Channels/2» -vcodec copy -an -t $LQLENGTH $LOCALSTORE$CAM3D.mkv & ffmpeg -v 0 -rtsp_transport tcp -i «rtsp://CAM_USERNAME:CAM_PASSWORD@CAM5_IP_ADDRESS:554/Streaming/Channels/2» -vcodec copy -an -t $LQLENGTH $LOCALSTORE$CAM5D.mkv &

Читайте также:  Linux удаленные виртуальные машины

Script 3 — Delete Old Files

#!/bin/sh # record_delete.sh # Record ip cam in segments LQDIR=»/path/to/network/storage/for/LQ/files» # Do not include tail ‘/’ (bash ‘find’ command will not execute property) HQDIR=»/path/to/network/storage/for/HQ/files» # Do not include tail ‘/’ LOCALSTOREF=»/LocalCAM» # Do not include tail ‘/’ ## Delete LQ files older than 90 days find $LQDIR -maxdepth 1 -type f -mtime 90 -exec rm <> \; ## Delete HQ files older than 3 days find $HQDIR -maxdepth 1 -type f -mtime 3 -exec rm <> \; ## Delete local LQ files older than 240 min; record_lq.sh should move at 190min mark find $LOCALSTOREF -maxdepth 1 -type f -mmin +240 -exec rm <> \;

Источник

How to know ip camera address

Read device documentation if it is initial setup or scan your network with nmap if it is already in use.

Welcome on StackExchange. You don’t provide enough information! It’s really difficult for people to help you if you don’t explain what is the structure of your network, what is specifically the problem you’re trying to solve, what linux distribution do you use. Please read the FAQ and have a look to high-ranted questions to see the best practices of this site.

2 Answers 2

If it has a static IP address preset and not configured to use DHCP by default, it probably still has. In this case, you should connect it to a private network (just a computer and your camera for example) with the same network and netmask to configure it.

If it uses DHCP, you can ping all your network and look in your ARP cache for the MAC address of your camera. For example:

nmap -sP 192.168.0.0/24 arp | grep

EDIT: (considering the information provided)

Читайте также:  Linux для xbox freeboot

If you connect your camera directly to your notebook, you are able to access the camera configuration (it may be a web page, or a simple telnet menu. ). In the manual of your camera, you can figure out what is your default camera’s IP. You have to configure your notebook by setting a static address in the same network.

For example, if your camera’s address is 192.168.0.1 , you can configure your notebook with ifconfig 192.168.0.2/24 up . You should then be able to ping your camera and modify its configuration (static IP address, DHCP setting, etc.). You’ll then be able to connect your camera in the network you want.

Источник

Как можно найти ip камеры?

Есть на руках камера с неизвестным IP адресом. Как к ней подключиться, по всему диапазону ip искать что-ли?

nmap попробуй использовать

А есть вариант, чтобы не сканить всё подряд?

Подключить камеру непосредственно к компу, запустить tcpdump и включить камеру. Наверняка она о себе чем-то вякнет в сеть.

А в гугле про эту модель ничего нет ?

Попробуй использовать ONVIF.

сходить на сайт производителя?

Возможно внутри корпуса камеры есть кнопка сброса как на домашних роутерах.

Я для такого arp-scan по примерному диапазону использовал. Работает шустро даже для /16. Правда зависит от загруженности сети, нужный пакет может дропнуться.

nmap -P0 -p80 твоясеть/маска займет секунд 5 для удобства можно два раза — до подключения камеры и после, потом дифнуть

Может она его по dhcp получает? Что за камера-то?

Ты что не можешь запустить wireshark и подключить камеру напрямую к компьютеру? При включении она на 99% начнет стучать в сеть.

Quick configuration tool can search current IP address, modify IP address. At the same time, you can use it to upgrade the device.
Please note the tool only applies to the IP addresses in the same segment.
.
Network camera default IP address is 192.168.1.108. Subnet mask is 255.255.255.0. Gateway is 192.168.1.1
.
Please click RESET button for at least five seconds to restore factory default setup.

Источник

Оцените статью
Adblock
detector