Record An IP Cam Network Stream In Linux

View previous topic View next topic Go down

Record An IP Cam Network Stream In Linux

Post by jamied_uk on 21st November 2016, 20:39





Code:
ffmpeg -i rtsp://@192.168.241.1:62156 -acodec copy -vcodec copy c:/abc.mp4


Last edited by jamied_uk on 21st November 2016, 22:16; edited 1 time in total

jamied_uk
Admin

Posts : 1981
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk on 21st November 2016, 21:35

Script



Code:
#!/bin/bash
# recordCam.sh  AKA test.sh
# ------------
# This script saves the live video from the Foscam IP camera to a full-quality mp4 file.
# I chose to split the files every 15 minutes (900 seconds), to quickly find the time I need.
# Note: audio is not saved as my cameras don't have a microphone connected to them.
# -----------
# Author: @LucaTNT
# License: BSD

# Uncomment this line if you're having trouble with zero-sized files (tipically happens on low end cameras), thanks Eric! (https://lucatnt.com/2014/08/record-and-archive-video-from-ip-cameras/#comment-48019)
# killall -INT ffmpeg

# The file name. I use the date to make finding files easier.
name="`date +%Y-%m-%d_%H.%M`"

# Where the videos will be saved
BASEpath='/home/jay/scripts/Stream_Recorder'
RECpath=$BASEpath'/video'

# Save the streams using ffmpeg at 30 fps, stopping the capture after 900 seconds (15 minutes). Add more lines if you have more than 2 cameras
ffmpeg -i rtsp://admin:password@192.168.100.10:554 -r 30 -vcodec copy -an -t 900 $RECpath/cam01/$name.mp4


lucatnt.com/2014/08/record-and-archive-video-from-ip-cameras/


Last edited by jamied_uk on 21st November 2016, 22:55; edited 1 time in total

jamied_uk
Admin

Posts : 1981
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk on 21st November 2016, 22:40

Record Stream Function For Linux




Code:
function Cam (){
cd /home/jay/scripts/Stream_Recorder
sudo ./test.sh

}




add to your .bashrc file (via sudo) then start a new terminal window and type Cam


(also change to your own folder names etc! aLSO MAKE SURE FOLDER EXISTS > video/cam01

Example:
/home/jay/scripts/Stream_Recorder/video/cam01 )

After it runs once it wont run again, it has a time limit (900) with -t tag

you can use crontab or cronjobs to choose when to record Very Happy  or maybe even use a call to the function after it finishes so it loops that way Smile

jamied_uk
Admin

Posts : 1981
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk on 21st November 2016, 23:47

Looping



Code:
function Cam (){
cd /home/jay/scripts/Stream_Recorder

sudo ./loop_test.sh
Cam

}


and the updated example for looping 60 = seconds change to what you wish to loop must be at least 1 minute!


Code:
ffmpeg -i rtsp://admin:password@192.168.0.34:554 -r 30 -vcodec copy -an -t 60 $RECpath/cam01/$name.mp4
name="`date +%Y-%m-%d_%H.%M`"


Last edited by jamied_uk on 24th November 2016, 12:09; edited 1 time in total

jamied_uk
Admin

Posts : 1981
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk on 22nd November 2016, 00:25

Motion Detection




Code:
sudo apt-get install -y gdebi-core motion




Code:
mkdir .motion



(Note: This will create a hidden folder .motion in your Home directory.)

Code:
cp /etc/motion/motion-dist.conf ~/.motion/motion.conf



(Note: This command will copy the original motion configuration file to its location.)

Now can open the configuration file for editing:

Code:
sudo nano ~/.motion/motion.conf



After you you have made all the appropriate adjustments to the configuration file, close it. Then start motion in the terminal simply by typing:

motion


Or
Code:
use Git



Code:
cd ~



Code:
git clone https://github.com/Motion-Project/motion.git

Code:
cd motion

Code:
autoreconf -fiv

Code:
./configure

Code:
make

Code:
make install

htmlpreview.github.io/?https://github.com/Motion-Project/motion/blob/master/motion_guide.html#Install_Build


lavrsen.dk/foswiki/bin/view/Motion/WebHome


Last edited by jamied_uk on 23rd November 2016, 16:47; edited 2 times in total

jamied_uk
Admin

Posts : 1981
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk on 22nd November 2016, 00:34

Other Alternatives
encrypted.google.com/search?q=how+to+identafie+mp4+files+that+have+movement

encrypted.google.com/search?q=how+to+detect+motion+using+linux+and+a+network+ip+cam+stream

jamied_uk
Admin

Posts : 1981
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Record An IP Cam Network Stream In Linux

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum