Video and audio acquisition
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello all, Could you please tell me how can I record audio and video simultaneously??
I found vision tool box supports separate acquisition of audio and video and then writing to a single file. But I want to acquire audio and video from same device. No need to write to a single file.
Thank you.
댓글 수: 0
답변 (1개)
Rahul
2024년 11월 22일 7:51
In order to achieve the desired result of recording audio and video simultanteously, consider using 'videoinput' and 'audiorecorder' functions. The 'start', 'stop' functions for the 'videoinput' object and 'record', 'stop' functions for the 'audiorecorder' object can be used simultaneously.
If the video is to be recorded using webcam of a Windows device, the 'Image Acquisition Toolbox Support Package for OS Generic Video Interface' will need to be installed. Here is an example of how to set up the 'videoinput' and 'audiorecorder':
vid = videoinput('winvideo', 1);
vid.FramesPerTrigger = Inf;
vid.LoggingMode = 'memory'
Fs = 44100;
nBits = 16;
nChannels = 1;
% These values can be adjusted
recObj = audiorecorder(Fs, nBits, nChannels);
The 'getdata' and 'getaudiodata' functions can be used to obtain the data from the 'videoinput' and 'audiorecorder' functions respectively.
In order to play the audio and video, you can use the 'sound' and 'implay' functions respectively. Here is an example:
videoFrames = getdata(vid);
audioData = getaudiodata(recObj);
sound(audioData, Fs); % Play audio using 'sound' function
implay(videoFrames); % Play video using 'implay' function
Refer to the following MathWorks documentations to know more:
'Image Acquisition Toolbox Support Package for OS Generic Video Interface': https://www.mathworks.com/matlabcentral/fileexchange/45183-image-acquisition-toolbox-support-package-for-os-generic-video-interface
Thanks.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!