Discussion:
Problem adding audio to video file
(too old to reply)
mako
2014-06-09 17:56:15 UTC
Permalink
Hi, I am counting cars in a video and I am trying to make a sound each time I count one of the cars. In each video frame loop, I mark the cars with a 3x3 blue zone and add the frame to video, but it is not clear to me how to add the sound to the frame.

I am working with vision.VideoFileReader and vision.VideoFileWriter since those are the ones that allow me to make the video with audio.

I have read the help and googled a lot, but I still cant' find out how to add the audio.

If I go to the properties of the created video, it shows that there is no audio sample rate.

In addition, I can have the audio written to wav file, but I can't put it into the video.

I think the problem is related to the fact that the audio in the wav file is sampled, and the audio in my Matlab variable isn't...

Help, please. Thanks.
Mohammad Khan
2014-06-09 20:00:00 UTC
Permalink
Here is an example:

hVideoFileWriter = vision.VideoFileWriter('myAudioVideo.avi',
'AudioInputPort', true);
% create 'video' frame, 'audio' frame and then invoke step method.
step(hVideoFileWriter, video, audio);

Here you don't need to specify audio sampling rate. From documentation: For
videos which also contain audio data, the rate of the audio data will be
determined as the rate of the video multiplied by the number of audio
samples passed in each invocation of the step method. For details see:
http://www.mathworks.com/help/vision/ref/vision.videofilewriter-class.html

Thanks,
Mohammad
Post by mako
Hi, I am counting cars in a video and I am trying to make a sound each
time I count one of the cars. In each video frame loop, I mark the cars
with a 3x3 blue zone and add the frame to video, but it is not clear to me
how to add the sound to the frame.
I am working with vision.VideoFileReader and vision.VideoFileWriter since
those are the ones that allow me to make the video with audio.
I have read the help and googled a lot, but I still cant' find out how to add the audio.
If I go to the properties of the created video, it shows that there is no
audio sample rate.
In addition, I can have the audio written to wav file, but I can't put it into the video.
I think the problem is related to the fact that the audio in the wav file
is sampled, and the audio in my Matlab variable isn't...
Help, please. Thanks.
e***@gmail.com
2014-06-27 23:37:53 UTC
Permalink
thanks Mohammad, it is odd, I didn't received your reply, I have just accidentally found it.

thanks again.

Loading...