Image to Video Conversion Error

3 views (last 30 days)
DeLaina McDonald
DeLaina McDonald on 12 Apr 2019
Commented: DeLaina McDonald on 12 Apr 2019
I am trying to convert one image into a video or motion jpeg using this code.
A = imread('joshheadshot2.jpg');
v = VideoWriter('myFile','Motion JPEG AVI');
open(v)
writeVideo(v,A)
I do not get any errors in the command window; however, when I try to open 'myFile.avi' a dialog box pops up that says "Cannot import from an empty input file." Any suggestions on how I can get this to work?

Answers (1)

Image Analyst
Image Analyst on 12 Apr 2019
I presume you are trying to open an avi file with VideoReader(), extract one frame from it, and write lots of the same frame to another output video that you're creating with VideoWriter(). Provide VideoReader() an input file that is not empty. It thinks your avi file is empty for some reason. How many bytes is it? If it's small, attach it to your post above.
  2 Comments
DeLaina McDonald
DeLaina McDonald on 12 Apr 2019
I was not using VideoReader() to open. I was just double clicking on the file in the Current Folder window. When I use VideoReader()
A = imread('joshheadshot2.jpg');
v = VideoWriter('myFile','Motion JPEG AVI');
open(v)
writeVideo(v,A)
VideoReader('myFile.avi')
I get these errors in the comman window:
Error using VideoReader/init (line 611)
The file does not appear to have any video data.
Error in VideoReader (line 176)
obj.init(fileName);
Error in FaceTracking (line 30)
VideoReader('myFile.avi')
If I am wanting to make a video of just one image to later use for something else, is there a better way to go about doing so?
DeLaina McDonald
DeLaina McDonald on 12 Apr 2019
I got it to work. Thanks

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!