How to create video from frames and audio file?

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.

답변 (1개)

mako
mako 2014년 6월 9일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

질문:

2014년 6월 8일

답변:

2014년 6월 9일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by