How can I create a video from a folder of images and add audio?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 11 Mär. 2018
Use vision.VideoFileWriter() . When you use the step() method, you pass in the audio as the parameter after the video information.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Audio and Video Data finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!