Page 1 of 1

how to record video using webcam in pi sd card

Posted: Tue Apr 12, 2016 3:07 pm
by MomuuBhaii
hi everybody. this is my first time to ask question here.
first of all excuse my English :P
let me tell u about my concept.
i am trying to record video using webcam, starting at specific time ( like 11:00am and stopping at 12:00pm ) and save it automatically in the specific folder on the desktop.
i have pi-2 with Raspbian installed and a webcam.
plz help me ,i tried to follow many tutorials on youtube.com and other sites but failed.
thanks in advance :)

Re: how to record video using webcam in pi sd card

Posted: Thu Apr 14, 2016 8:30 am
by MarcScott
Can you post the make and model of the webcam please.

Re: how to record video using webcam in pi sd card

Posted: Thu Apr 14, 2016 11:22 am
by MomuuBhaii
this is the webcam i have.
product of DANY.

Re: how to record video using webcam in pi sd card

Posted: Thu Apr 14, 2016 12:37 pm
by MarcScott
Can you try this for me?

Code: Select all

sudo apt-get update && sudo apt-get install fswebcam
cd ~/
fswebcam -r 640x480 --jpeg 85 -D 1 web-cam-shot.jpg
You should see an image called web-cam-shot.jpg in your home directory

Re: how to record video using webcam in pi sd card

Posted: Thu Apr 14, 2016 6:13 pm
by MomuuBhaii
Thank you sir :)
Will you please also tell me , how to record video for 2mins using webcam ???
Your help will solve my problem :)

Re: how to record video using webcam in pi sd card

Posted: Fri Apr 15, 2016 3:46 am
by kolban
For recording a video for a period of time, I use:

Code: Select all

ffmpeg -t 120 -f v4l2 -framerate 25 -video_size 640x80 -i /dev/video0 output.mkv
The "-t time" flag specifies the duration of the recording in seconds.

Re: how to record video using webcam in pi sd card

Posted: Fri Apr 15, 2016 11:56 am
by MomuuBhaii
Bash error :(
sir i am working in python IDLE medium and want to record video e.g at 9:00am for 2 mins (every day). so what would be the code for this process ?

Re: how to record video using webcam in pi sd card

Posted: Fri Apr 15, 2016 12:27 pm
by MarcScott
Sorry, I didn't read your post properly. Though you wanted images.
kolbans command can be used in Python

Make sure you have ffmpeg

Code: Select all

sudo apt-get install ffmpeg
Then in Python:

Code: Select all

import os
os.system('ffmpeg -t 120 -f v4l2 -framerate 25 -video_size 640x80 -i /dev/video0 -t 300 output.mkv')

Re: how to record video using webcam in pi sd card

Posted: Sat Apr 16, 2016 7:23 am
by MomuuBhaii
sir thanks for the reply :) but the code still not working :(
when i execute it, a command window appears for a quarter of a second and then disappears in the shell.

Re: how to record video using webcam in pi sd card

Posted: Wed Apr 27, 2016 6:35 am
by MarcScott
Is there no video file in the directory that holds your python script?

Re: how to record video using webcam in pi sd card

Posted: Tue Mar 21, 2017 6:16 pm
by YuvrajSandip
Sir,it says no ffmpeg library exist..
Could you please tell us an alternate library to install or how to get the library installed?

Re: how to record video using webcam in pi sd card

Posted: Tue Apr 18, 2017 6:50 pm
by tsteles
You can use

Code: Select all

sudo apt-get install libav-tools
and then write "avconv" instead of "ffmpeg" or create a alias.

See this viewtopic.php?t=125367

Re: how to record video using webcam in pi sd card

Posted: Tue Apr 18, 2017 7:24 pm
by tsteles
Example:

Code: Select all

avconv -t 10 -f video4linux2 -i /dev/video0 video0.avi

Re: how to record video using webcam in pi sd card

Posted: Tue Jun 20, 2017 12:04 am
by OutsourcedGuru
Keep in mind that the 8MP Pi NoIR v2 camera at its highest resolution probably eats 1GB of memory every 8 minutes of video. So in perhaps 24 minutes or so you could fill your partition if you have a 4GB card.