How can I create a video from a folder of images and add audio?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Walter Roberson
el 11 de Mzo. de 2018
Use vision.VideoFileWriter() . When you use the step() method, you pass in the audio as the parameter after the video information.
0 comentarios
Ver también
Categorías
Más información sobre Audio and Video Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!