Playing a video with sound
Afficher commentaires plus anciens
Hello all,
I am trying to play a video (with sound) in Matlab R2011b (7.13.0.564) unter Linux (openSUSE, 32bit).
At first I had to rename libstdc++.so.6 and libstdc++.so.6.0.10 according to this link, in order to get rid of an error message.
Now, When I run the following Code, the video is played; however, there is no sound. I tried different file formats, such as mp4, avi, and flv. According to the warning message, there is no sound in the video-files. However, I am sure there is.
Does anyone have an idea of how I can play my video with sound? Thanks in advance!
hvfr = vision.VideoFileReader('test.mp4', 'PlayCount', 1, 'AudioOutputPort', true);
hp = vision.VideoPlayer;
while ~isDone(hvfr)
videoFrame = step(hvfr);
step(hp, videoFrame);
end
release(hp);
release(hvfr);
The warning message is:
Warning: The AudioOutputPort property is not relevant in this configuration of the System object.
> In /home/username/.matlab2011b/toolbox/shared/system/+matlab/+system/pvParse.p>pvParse at 25
In /home/username/.matlab2011b/toolbox/shared/system/+matlab/+system/SystemProp.p>SystemProp.parseInputs at 635
In /home/username/.matlab2011b/toolbox/shared/system/+matlab/+system/SystemProp.p>SystemProp.setProperties at 138
In /home/username/.matlab2011b/toolbox/vision/vision/+vision/VideoFileReader.p>VideoFileReader.VideoFileReader at 140
In realtime_video at 5
2 commentaires
Ernesto
le 8 Avr 2019
Hi, you should use AVI (the audioport does not work with mp4)
Then you get audio frames using:
[ videoFrame, audioframe ] = = step(hvfr);
The code can be like:
videoFReader = vision.VideoFileReader('F.avi','AudioOutputPort',1,'AudioOutputDataType','double');
% Create a video player object to play the video file.
videoPlayer = vision.VideoPlayer;
H = dsp.AudioPlayer(44100);
% Use a while loop to read and play the video and audio frames.
while ~isDone(videoFReader)
[videoFrame,a] = step(videoFReader);
step(H,a);
step(videoPlayer, videoFrame);
end
% Release the objects.
release(videoPlayer);
release(videoFReader);
mochamad habibulloh
le 14 Avr 2019
i have problem using your code like this.
Warning: The queue has underrun by 2258 samples. Try increasing queue duration, buffer size, or throughput rate.
can you help me ?
Réponses (0)
Catégories
En savoir plus sur Audio and Video Data dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!