How to create video from frames and audio file?
Show older comments
I used this code but the output video has a faster rate than the original video
hmfr=video.MultimediaFileReader('video.avi','AudioOutputPort',true,'VideoOutputPort',true);
writer=video.MultimediaFileWriter('out.avi','AudioInputPort',true,'VideoInputPort',true);
for i=1:300
videoFrame=step(hmfr);
[i,audio]=step(hmfr);
step(writer,videoFrame,audio);
end
close(hmfr);
close(writer);
Need help please! Thanks in advance.
Answers (1)
mako
on 9 Jun 2014
0 votes
Hi, I've been using vision.VideoFileReader and vision.VideoFileWriter in order to create the video with audio and there I can pass a parameter named 'FrameRate' to the writer function, and it is like this:
videoFWriter = vision.VideoFileWriter('video.avi','FrameRate',videoFReader.info.VideoFrameRate);
Maybe you can change to these two functions or maybe the one you are using also has the 'FrameRate' parameter.
I hope this helps.
By the way, please, if you have a minute, take a look at the question I asked yesterday and help me out there, it is related to this matter, just a doubt with the audio. This is the link: http://www.mathworks.com/matlabcentral/answers/133137-problem-adding-audio-to-video-file
Thanks in advance.
Categories
Find more on Video Formats and Interfaces in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!