Clear Filters
Clear Filters

error while writing a video

12 views (last 30 days)
kash on 11 Apr 2013
I have a seven second video,i converted to frames and used imwrite to save all files in a folder and then i tried to convert frames to video,finally wen using videowriter my video was only 3 sec,plz tell why i get like this
[Merged from duplicate]
i have a code in which the frames per second changes and also the duration of video
clear all
vidObj = VideoReader('foreman.avi');
numFrames = vidObj.NumberOfFrames;
if (exist(f1) == 0)
mkdir (f1);
for k = 1:numFrames
a=read( Frames,k);
path ='E:\rr1ames\' ;
files = dir( [path '*.bmp'] );
writerObj = VideoWriter('rnewd2.avi');
for k = 1:numFrames
image = ((imread(fullfile(path,files(k).name))));
vidObj = VideoReader('rnewd2.avi');
the result i get for foreman is
Video Parameters: 14.99 frames per second, RGB24 176x144.
for rnewd2.avi is
Video Parameters: 30 frames per second, RGB24 176x144.
plz help

Answers (2)

Jan on 11 Apr 2013
Edited: Jan on 11 Apr 2013
Without seeing the code, it is impossible to guess, what you are doing exactly. Perhaps there is a bug, which ignores the last 4 seconds, or the first 4 seconds, or some frames in certain intervals, or the frame rate has been set incorrectly. There could be a bunch of problems, which can be found by using the debugger easily, but guessing them is a hard work.
kash, you have asked hundreds of questions now. You have been instructed many times to read your questions again and estimate, if they contain enough information to be answered efficiently or if an answer is possible at all. I cannot see any reason to ignore such recommendations.
Jan on 12 Apr 2013
  1. Omit the clear all. It prevents the debugging by removing all breakpoints, and this is a really bad idea.
  2. exist(f1) is dangerous, because it checks for files, folders, variables java classes etc. Use exist(f1, 'file') instead.
Image Analyst
Image Analyst on 12 Apr 2013
I know it says "clear removes debugging breakpoints in MATLAB files." in the help but it's not entirely true, as a simple test will show. Make a script with clear or clear all at the top, set a breakpoint further down, and run it. It will stop at the breakpoint. If you do clear all from the command line, it will remove breakpoints in the script, but not if the clear is in the script itself. Just wanted to clarify.

Sign in to comment.

Walter Roberson
Walter Roberson on 12 Apr 2013
Where do you configure your frame-rate for your VideoWriter object?


Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!