Python webcam record
<p>I want to create a webcam streaming app that records webcam stream for, say about 30 seconds, and save it as <code>myFile.wmv</code>. Now To get live camera feed I know this code :-</p>

<pre><code>import cv2
import numpy as np
c = cv2.VideoCapture(0)

while(1):
    _,f = c.read()
    cv2.imshow('e2',f)
    if cv2.waitKey(5)==27:
        break
cv2.destroyAllWindows()
</code></pre>

<p>But I have no idea off how to record for a given number of seconds and save it as a file in its current directory,</p>

<p>Please someone point me to the right direction</p>

<p>Thanks</p>

<p><em>ABOUT TIME</em></p>

<p>Why do not use the python <a href="https://docs.python.org/2/library/time.html" rel="nofollow">time function</a>? In particular <code>time.time()</code> Look at this <a href="http://stackoverflow.com/a/23197503/6564973">answer about time in python</a></p>

<p>NB OpenCV should have (or had) its own timer but I can not tell you for sure if it works in current versions. </p>

<p><em>ABOUT RECORDING/SAVING</em></p>

<p>Look at this <a href="http://stackoverflow.com/a/29317298/6564973">other answer</a></p>

python python-2.7 opencv video webcam