Re: Question aviread / imwrite



"Christopher " <chris_jones.nospam@xxxxxxxxxxx> wrote in
message <fnsv3v$3o7$1@xxxxxxxxxxxxxxxxxx>...
I am using MATLAB Version:

7.4.0.287 (R2007a)
January 29 20007

on my Intel Mac running Mac OS X 10.5.1

The problem I am having is when I write out an image from
the frame I extracted from an AVI file the output seems
shifted.
I am new to MATLAB, and I am trying to use and understand
someone else code, but I have been able to reduce the
example of my issue to the following few lines:


function X = extract_first_frame(videoClip,savename,fmt)

aviinfo(videoClip)

mov = aviread(videoClip,1);

imwrite (mov.cdata, savename, fmt);

fprintf('\nWrote the first frame of the videoClip: %s to
the file %s\n', videoClip, savename);


Which when I run my function like so:


extract_first_frame ('clips/one_frame.avi',
'/tmp/first_frame.png', 'png');

ans =

Filename: 'clips/one_frame.avi'
FileSize: 238944
FileModDate: '31-Jan-2008 08:23:56'
NumFrames: 1
FramesPerSecond: 15
Width: 320
Height: 240
ImageType: 'truecolor'
VideoCompression: 'none'
Quality: 4.2950e+07
NumColormapEntries: 0
AudioFormat: 'PCM'
AudioRate: 32000
NumAudioChannels: 2


Wrote the first frame of the videoClip:
clips/one_frame.avi to the file /tmp/first_frame.png

The output in /tmp seems to have B and R reversed, which is
not the big issue since I can fix that
the issue is that about one third of the image has been put
onto the left.

I can provide the video and the output image, if someone
tells me how to associate it with this post.
.