PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Record An IP Cam Network Stream In Linux

Go down

Record An IP Cam Network Stream In Linux Empty Record An IP Cam Network Stream In Linux

Post by jamied_uk 21st November 2016, 20:39





Code:
ffmpeg -i rtsp://192.168.241.1:62156 -acodec copy -vcodec copy output.mp4


For Linux Mint 18.1 Update:


Code:
#!/bin/bash
if ping -c 1 192.168.0.34 &> /dev/null
then
 echo "Host Up... Recording Stream"

# recordCam.sh AKA test.sh AkA Run.sh
#
# Function Cam will also work if you have set that up!
#
# ------------
# 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 (typically 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/Documents/Scripts/IP-Cam_Stream_Recorder/'
#
cd $BASEpath
# 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.0.34:554 -r 30 -vcodec copy -an -t 60 $BASEpath/video/cam01/$name.mp4
#
name="`date +%Y-%m-%d_%H.%M`"

else
 echo "No Cam Stream Available"
fi


Bash RC Function


Code:
sudo gedit .bashrc




Code:
function Cam (){

sudo /home/jay/Stream_Recorder/loop_test.sh
Cam
}


Last edited by jamied_uk on 12th February 2018, 18:13; edited 4 times in total
jamied_uk
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Record An IP Cam Network Stream In Linux Empty Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk 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
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Record An IP Cam Network Stream In Linux Empty Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk 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
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Record An IP Cam Network Stream In Linux Empty Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk 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:
name="`date +%Y-%m-%d_%H.%M`"ffmpeg -i rtsp://admin:password@192.168.0.34:554 -r 30 -vcodec copy -an -t 60 $RECpath/cam01/$name.mp4


Last edited by jamied_uk on 12th February 2018, 17:55; edited 2 times in total
jamied_uk
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Record An IP Cam Network Stream In Linux Empty Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk 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
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Record An IP Cam Network Stream In Linux Empty Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk 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
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Record An IP Cam Network Stream In Linux Empty Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk 29th April 2017, 18:37

jamied_uk
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Record An IP Cam Network Stream In Linux Empty Re: Record An IP Cam Network Stream In Linux

Post by jamied_uk 29th April 2017, 22:10

Make sure the folders you need are created if you get errors that they dont exist make sure you create them Smile
jamied_uk
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Record An IP Cam Network Stream In Linux Empty Re: Record An IP Cam Network Stream In Linux

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

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