Making a video by selecting png images
1 次查看(过去 30 天)
显示 更早的评论
How can I make a video by selecting png images from a folder? Also how can I save the video?
the files are: abc_20190304_0001.png to abc_20190304_0095.png
0 个评论
回答(2 个)
Walter Roberson
2021-9-8
Loop over the files by constructing their names. Or read the directory and loop over the files returned by dir().
A common challenge when using information returned by dir() is that numbers are usually sorted in an order people do not expect. abc1.png abc10.png abc11.png abc12.png ... abc19.png abc2.png abc20.png abc21.png and so on. However, I see that in your case the filenames use 4 digit number suffixes with 0 fill, and under that circumstance, you can use the order returned by dir() [though in theory you should sort() the file names, in practice you do not need to if you are using NTFS or any of the common Mac or Linux file systems.]
Use videoWriter() to create a movie object. Read one input file at a time and writeVideo() it to the movie object. https://www.mathworks.com/help/matlab/ref/videowriter.html
0 个评论
Image Analyst
2021-9-8
I do this in the attached example. I take a video and then write all the frame to disk as individual files. Then I reconstruct a new image by reading in all the frames from the disk and making them into a new movie/video.
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!