Video and audio acquisition
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Rahul
el 22 de Nov. de 2024 a las 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 comentarios
Ver también
Categorías
Más información sobre Audio and Video Data en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!