Image to Video Conversion Error

조회 수: 3 (최근 30일)
DeLaina McDonald
DeLaina McDonald 2019년 4월 12일
댓글: DeLaina McDonald 2019년 4월 12일
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?

답변 (1개)

Image Analyst
Image Analyst 2019년 4월 12일
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
DeLaina McDonald
DeLaina McDonald 2019년 4월 12일
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 2019년 4월 12일
I got it to work. Thanks

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by