MomuuBhaii
Posts: 9
Joined: Tue Apr 12, 2016 2:40 pm

how to record video using webcam in pi sd card

Tue Apr 12, 2016 3:07 pm

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 :)

MarcScott
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 81
Joined: Sat Aug 08, 2015 11:30 am

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

Thu Apr 14, 2016 8:30 am

Can you post the make and model of the webcam please.

MomuuBhaii
Posts: 9
Joined: Tue Apr 12, 2016 2:40 pm

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

Thu Apr 14, 2016 11:22 am

this is the webcam i have.
product of DANY.
Attachments
128_PC-1220.jpg
128_PC-1220.jpg (41.22 KiB) Viewed 22351 times

MarcScott
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 81
Joined: Sat Aug 08, 2015 11:30 am

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

Thu Apr 14, 2016 12:37 pm

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

MomuuBhaii
Posts: 9
Joined: Tue Apr 12, 2016 2:40 pm

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

Thu Apr 14, 2016 6:13 pm

Thank you sir :)
Will you please also tell me , how to record video for 2mins using webcam ???
Your help will solve my problem :)

User avatar
kolban
Posts: 152
Joined: Fri Dec 04, 2015 1:45 am
Location: Texas, USA

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

Fri Apr 15, 2016 3:46 am

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.
FREE book on Raspberry Pi usage and programming

https://leanpub.com/pi

MomuuBhaii
Posts: 9
Joined: Tue Apr 12, 2016 2:40 pm

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

Fri Apr 15, 2016 11:56 am

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 ?

MarcScott
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 81
Joined: Sat Aug 08, 2015 11:30 am

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

Fri Apr 15, 2016 12:27 pm

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')

MomuuBhaii
Posts: 9
Joined: Tue Apr 12, 2016 2:40 pm

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

Sat Apr 16, 2016 7:23 am

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.

MarcScott
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 81
Joined: Sat Aug 08, 2015 11:30 am

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

Wed Apr 27, 2016 6:35 am

Is there no video file in the directory that holds your python script?

YuvrajSandip
Posts: 1
Joined: Tue Mar 21, 2017 6:12 pm

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

Tue Mar 21, 2017 6:16 pm

Sir,it says no ffmpeg library exist..
Could you please tell us an alternate library to install or how to get the library installed?

tsteles
Posts: 2
Joined: Tue Apr 18, 2017 6:41 pm

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

Tue Apr 18, 2017 6:50 pm

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

tsteles
Posts: 2
Joined: Tue Apr 18, 2017 6:41 pm

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

Tue Apr 18, 2017 7:24 pm

Example:

Code: Select all

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

OutsourcedGuru
Posts: 40
Joined: Mon Jun 19, 2017 11:15 pm

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

Tue Jun 20, 2017 12:04 am

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.

Return to “Staffroom, classroom and projects”

Who is online

Users browsing this forum: No registered users and 2 guests