![]() Print "total frames " + str(frame_counts) Recorded_fps = frame_counts / elapsed_time # Launches the audio recording function using a threadĪudio_thread = threading.Thread(target=self.record)Įlapsed_time = time.time() - video_thread.start_time WaveFile.writeframes(b''.join(dio_frames)) # Finishes the audio recording therefore the thread too Self.stream = (format=self.format,įrames_per_buffer = ames_per_buffer)ĭata = (ames_per_buffer) Video_thread = threading.Thread(target=self.record) # Launches the video recording function using a thread ![]() # Finishes the video recording therefore the thread too # gray = cv2.cvtColor(video_frame, cv2.COLOR_BGR2GRAY) # timer_current = time.time() - timer_start # print str(counter) + " " + str(ame_counts) + " frames written " + str(timer_current) _out = cv2.VideoWriter(_filename, _writer, self.fps, ameSize) _writer = cv2.VideoWriter_fourcc(*self.fourcc) ameSize = (640,480) # video formats and sizes also depend and vary according to the camera used Self.fourcc = "MJPG" # capture images (with no decrease in speed over time testing is required) Self.fps = 6 # fps should be the minimum constant rate at which the camera can So the fps have to be controlled at the level of the code. It is only able to specify in the encoding of the file the desired final fps, but the webcamera usually behaves differently according to specifications and light conditions (I found). Note: opencv is not able to control the fps at which the webcamera does the recording. I have uploaded my code to github and also have included all the essential parts it here. One thread records video, and a second one the audio. To be able to record both simultaneously, I use multithreading. My solution uses pyaudio for audio recording, opencv for video recording, and ffmpeg for muxing the two signals. Un-commenting lines 76, 77 and 78 will make the video to be displayed to screen while recording.It saves the final video/audio file as.Records video + audio from webcam and microphone simultaneously.I got a solution for the problem you present. You have to implement both separately and merge the audio and video signal in a smart way to end up with a video/audio file. There is no single library/solution in python to do video/audio recording simultaneously. The question - is there a video & audio capture library for python?Īnswer: No. kivy - just heard about it, didn't manage to get it working under windows SO FAR.VLC - binding to VideoLAN program into wxPthon - hopefully it will do (still investigating this option).VideoCapture - provide only single frames.PyGame - no simultaneous audio capture (AFAIK).OpenCV - couldn't find audio capture there.So far i've seen code that captures VIDEO only, or individual frames. So far i've done it with an ActiveX component in VB which took care of everything, and i'd like to progress with python (the VB solution is unstable, unreliable). display the video on the screen while recording itĬompression is NOT an issue in my case, and i actually prefer to capture RAW and compress it later. ![]()
0 Comments
Leave a Reply. |