How can I create a video from a folder of images and add audio?
5 次查看(过去 30 天)
显示 更早的评论
I took each frame from a video in color and modified the images and saved them in a folder, but now I want to combine these images from my folder into a new video with the same framerate as the original video and add the sound back in. How can I do that? I was successfully able to write these images into a new video without sound using the below code:
v = VideoReader('sample.mp4'); % Read the original video
shuttleVideo=v;
info = get(v);
framerate = v.FrameRate;
%%image processing was done here
writerObj = VideoWriter('YourAVI.avi'); % new video
writerObj.FrameRate = framerate;
open(writerObj);
for K = 1 : i
filename = sprintf('a%04d.tif', K);
thisimage = imread(filename);
writeVideo(writerObj, thisimage);
end
close(writerObj);
However, how can I do this while keeping my audio? From looking at other codes online, it seems I'm supposed to use the vision.VideoFileWriter function instead so that I can write both video and audio into a file, but I'm confused on how this function works?
0 个评论
回答(1 个)
Walter Roberson
2018-3-11
Use vision.VideoFileWriter() . When you use the step() method, you pass in the audio as the parameter after the video information.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!