Code covered by the BSD License  

Highlights from
mmwrite

4.83333

4.8 | 15 ratings Rate this file 90 Downloads (last 30 days) File Size: 111 KB File ID: #15881

mmwrite

by

 

09 Aug 2007 (Updated )

write AVI/ASF/WMV/WMA file from movies read by mmread

| Watch this File

File Information
Description

function list = mmwrite(filename,...options...)

mmwrite is able to write AVI,WMV,WMA,ASF files. For AVI files you can choose from the available codecs to compress the audio and video streams.
For WMV,WMA and ASF the encoding defaults to Windows Media 9 44100Hz 16bit stereo 98% quality for the audio and Windows Media 9 Video with 98
quality. The quality can be specified for both audio and video.
Surround sound only seems to work with AVI and multi-pass encoding is not supported. Writing any other file type is not supported. This uses Windows DirectX infrastructure, so other OSs are out of luck.

INPUT:
  filename: This must be the first parameter and specifies the filename to write.

  video structure: The video structure matches the output of mmread. At a minimum it must have 4 fields "frames", "times", "height" and "width". The "frames" field must be a struct array with a field "cdata" that contains the raw frame data encoded as height by width by color(3) as UINT8s. The "times" field contains the time stamps of the data stored in frames. "times" and "frames.cdata" must be the same length.

  audio structure: The audio structure matches the output of mmread. At a minimum it must have 3 fields "data", "rate" and "times". The "data" field is a matrix nrSamples by nrChannels (the same format was wavread/wavplay). The field "rate" is the sampling rate of the data in Hz, eg. 44100. The field "frames" is used to specify the time that audio should start, the rest of the time is extrapolated based upon the "rate" and the nrSamples.

  AVI config structure:
    videoCompressor Specify which video compressor/codec to use. Use 'ListAviVideoEncoders' to determine what are valid codecs on your machine.
    audioCompressor Specify which audio compressor/codec to use. Use
      'ListAviAudioEncoders' to determine what are valid codecs on your machine.

  WMV/WMA/ASF config structure: can have any of the following fields
    videoQuality the quality of the video, between 0 and 100 default 98.
    audioQuality the quality of the audio, between 0 and 100 default 98.
    outputHeight the height of the video to be generated.
    outputWidth the width of the video to be generated.
    outputFrameRate the frame rate of the video to be generated.
    prxFile Specify a custom encoding file. The settings here overwide the all of the other config options. To create a custom file, use Windows Media Encoder and use the Export feature of the Compression tab.

  'ListAviVideoEncoders': Use this option to list availble video encoders
    Eg. list = mmwrite('','ListAviVideoEncoders');

  'ListAviAudioEncoders': Use this option to list availble audio encoders
    Eg. list = mmwrite('','ListAviAudioEncoders');

  'Continue': Keep the encoding going so that more data can be added by a later call to mmwrite. Defaults to false. To have a usable output file, you must later call mmwrite with only the 'Initialized' option.

  'Initialized': Indicates that mmwrite has already been initialized (by a call with 'Continue') and to just add the data specified. Warning, the order of audio and video structures must be the same as the first 'Continue' command otherwise the streams will get mixed.

  OUTPUT
      list: Only 'ListAviVideoEncoders' and 'ListAviAudioEncoders' have an output, which is the list of encoders installed on the system.

  EXAMPLES:

  % write a simple WMV file with audio and video
  mmwrite('blah.wmv',audio,video);

  % make a WMA file from the audio taken from another video
  [video, audio] = mmread('your movie');
  mmwrite('blah.wma',audio);

  % make a video progressively
  mmwrite('blah.wmv',audio,video,'Continue'); %initialize the movie
  ...
  % the "times" fields for both audio and video must start after the last
  "times" in the previous call to mmwrite.
  mmwrite('blah.wmv',audio2,video2,'Continue','Initialized'); %don't initialize or stop
  ...
  mmwrite('blah.wmv',audio3,video3,'Initialized'); %don't initialize and STOP

  % make an AVI with custom compressors.
  audioList = mmwrite('','ListAviAudioEncoders');
  videoList = mmwrite('','ListAviVideoEncoders');
  if ~any(ismember(list,'ffdshow video encoder'))
    conf.videoCompressor = 'Cinepak Codec by Radius'; % default to this if ffdshow isn't installed...
  else
    conf.videoCompressor = 'ffdshow video encoder';
  end
  mmwrite('balh.avi',audio,video,conf);

  % write just a subsample (the time range 10 to 20s) of a movie using mmread
  [video, audio] = mmread('your file',[],[10 20]);

  subtract 10 seconds off the time stamps so that the audio and video
  will start at the beginning of the movie.
  video.times = video.times - 10;
  audio.times = audio.times - 10;

  mmwrite('blah.wmv',audio,video); % make the movie...

Acknowledgements

Mmread inspired this file.

MATLAB release MATLAB 6.5 (R13)
Other requirements DirectX 9. Microsoft Windows platforms only. Other OSs are out of luck.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (54)
10 Mar 2014 John

It works ok but there is a hitch. When I changed the audio (from an array) and called mmwrite to write the video, it changed the audio values. I used the values 1:10240 as audio and attempted to write them to a video file. It wrote the video frames but the audio was completely different.

03 Oct 2012 Yang

Hi Micah,

Your code is great, and I want to edit some parts to meet my needs.
But when I install Visual C++ 2010 along with Windows SDK v7.1, it still can't find many header file, and some header file from directshow seems can not compile correctly :(

Can you do me a favor to list the directX version that you used?

Thanks a lot!!
Yang

19 Jan 2012 Howard Schoeberlein

I'm having trouble getting mmwrite to work. I get errors looking for a module in mmwrite.mexw64: "??? Invalid MEX-file 'U:\MATLAB\MovieTest\mmwrite\mmwrite.mexw64': The
specified module could not be found." I added the path via addpath. Any ideas?

Thanks,
Howard

17 Aug 2011 Tsvi  
09 Aug 2011 mrt

mmwrite('bach.asf')

ConfigAsfWriter can not use prx profile

what is this?

08 Aug 2011 mrt

hi everyone
i read asf video wtih "mmreader"
but i dont save the same video with "mmwriter"

vidObj = mmreader('car.asf');
LastFrame = read(vidObj,inf);
vidFrames = read(vidObj);

numFrames = vidObj.NumberOfFrames;

mmwriter ('bath.asf') ERROR
mmwriter ('bath.asf',v) ERROR
mmwriter ('bath.asf',vidObj.Height,vidObjWeight) ERROR

Please help me
i dont understand how i can use mmwriter (matlab 2009a 32 bit)

01 Jun 2011 Shaun

When I use your pi example to create a movie from a figure, it works great. However, when I use the same process from a figure I have created, the wmv is empty. Is it an issue with openGL

23 May 2011 Shahar

I run it on existing avi with
video = mmwrite('mysample.avi') and I get

Warning: In the directory "C:\my\mmwrite", mmwrite.mexw32 now shadows mmwrite.dll.
Please see the MATLAB 7.1 Release Notes.
??? One or more output arguments not assigned during call to "mmwrite".

04 Apr 2011 rakesh bisht

Hi Micah Please help...

I am on a very tight deadline

27 Mar 2011 rakesh bisht

Hi Micah, Need help !!!!
You have done a great work with the functions of mmread() mmwrite().

I am working on Video Summarizing Project using an MPG video.I have to play only the high pitch video frames in the video.As such I have extracted .wav file from the .mpg file,filtered it with the a High Pass Filter in Matlab.
Now I have to retrieve the video relevant to that high pitch audio file(.wav).
Can you please suggest how can this be done.

Please help I am near to my deadline.

Thanks in Advance,

Regards,
Rakesh Bisht

10 Mar 2011 Laurent Nguyen

Hi Micah,

Thanks for your really useful functions.
I am using Matlab 2009a on Windows Vista and I am having a problem with mmwrite. The same error seems to appear randomly:

??? Error using ==> mmwrite unspecified error

When this happens, I need to close Matlab for my script to be able to mmwrite a file again. Do you have any idea of any solution to that ? Thanks.

I am trying to extract short periods (3 sec.) from longer films and save them as new .wmv files.

Laurent

24 Nov 2010 huang

Hi Micah,
I didn't use 'continue' because I want to chop up the original video file which is about 3hr long into short pieces. I find it is time-consuming to read frames that are not at the beginning of the video clip. Initially I tried to cut it into pieces of length 10s.

If it takes roughly the same time to read the first frame or the last frame of a long video clip, I would not bother to cut the video into small pieces.

Thanks again for your kind help!

24 Nov 2010 Micah Richert

Hi Huang,

Wow, that is a huge amount of data (about 3.5G of memory). I'll have to research that problem more. But as a work around, why not use the 'continue' option with mmwrite to process smaller blocks, maybe 1 minute long segments?

I hope that helps,
Micah

24 Nov 2010 huang

Hi Micah,
Thanks a lot for your kind help!

I am running MATLAB R2009a 64bit on windows vista 64bit.

MATLAB crashes without anything warning message. It just disappears and a "Microsoft Windows" window pops up, says "MATLAB has stopped working. Windows is collecting more information about the problem..."

I found that MATLAB crashes only when I try to read and write video data which are more than 10min long.

The video I am using has a frame size of 512X384 and 29 fps.

23 Nov 2010 Micah Richert

Hi Huang,

Can you include the actual error message when it crashes? Also, are you using 32 or 64 bit Matlab?

Best,
Micah

23 Nov 2010 huang

MATLAB crashes when I use mmwrite to create a WMV file.

I used mmread to read the video file and the code is like follows:

vid=mmread(mov_filename,f1:f2);
vid.times=vid.times-vid.times(1);
mmwrite(wmv_filename,vid);

My system is Windows Vista 64bit.

Anyone could help me? Thx!

21 Aug 2010 Peng

Hi,Micah,
Thanks for you help.
It works great now.

20 Aug 2010 Micah Richert

Hi Peng,

The audio and video quality parameters only apply to WMV files. To change the quality for AVI files you have to do this manually through ffdshow config.

I hope that helps,
Micah

20 Aug 2010 Peng

Hi,Micah,
Thanks for your work on writing video files using Matlab.
I have tried mmwrite on my machine,but when I use mmwrite to write back an AVI file , I can't change video & audio quality .The output file has no differences between differentvideo & audio quality config.
I already have 'ffdshow' ,and test other encoders.
What a problem can it be?
Thanks.

04 Jun 2010 Tobias Jensen

Hi,

1. Yes, Im in the directory. The funny thing is that if call using
[video audio] = mmread('foreman.avi');
ill get an error saying the file does not exist, and the script is ended. But now Im in the mmread directory......

2. Yeah I thought so. The doc in top of mmwrite was a bit unclear to what "This" refers to in the sentence
"This uses the Windows DirectX infrastructure to generate the movie, so other OSs are out of luck."

Thanks for the fast reply

Tobias

03 Jun 2010 Micah Richert

Hi Tobias,

1. No one else has ever reported your issue before. Have you run "ls" or "dir" from Matlab's command prompt and confirmed that Matlab also thinks that your video is in the current directory?

2. Sorry, mmwrite only works on Windows. I have considered writing a multi-OS version but it would be a complete rewrite.

Best,
Micah

03 Jun 2010 Tobias Jensen

Hi,

This is a piece of software which could be useful for me.

I have tried mmread and mmwrite on my 32bit linux machine, and I have two comments.

1. when I call mmread i have to go one directory back to get it. That is i need to call using [video audio] = mmread('../foreman.avi'); but foreman.avi is in my current directory.

2. when i call mmwrite using mmwrite('foreman_new.avi',audio,video); i get

Attempt to execute SCRIPT mmwrite as a function:

I think matlab only recognizes mmwrite.m, and somehow not mmwrite.mex??? What can I do? Do I need to recompile? I have changed mmwrite.mex?? to executables...

Tobias

14 May 2010 Micah Richert

Hi All,

The problem found by Monte Owens has been fixed and the updated zip should appear hear in a couple days.

Best,
Micah

14 May 2010 Micah Richert

Hi Arash,

You shouldn't have to recreate the mex file. Not to mention it is a huge pain to try to compile the mex files yourself, so I don't recommend it.

What is the problem you are having?

Best,
Micah

13 May 2010 Arash Jalalian

Thanks, Monte Owens

13 May 2010 Arash Jalalian

Does anyone know how I can recreate the mex files for winXP 64bit? Because the provided file doesn't work for me!

14 Apr 2010 Micah Richert

Hi Monte,

Here is a quote from the Windows Media Encoder FAQ "The setting you specify represents the maximum value; if you are encoding low-motion video, the frame rate or bit rate of the encoded content might be lower. Other factors that may reduce the frame rate or bit rate include a high video quality setting..."

So, Microsoft is trying to be "too smart" for you... The only way that I know of to get every frame to be in the video is to switch to AVI instead of WMV.

Best,
Micah

13 Apr 2010 Monte Owens

When I make wmv files with higher frame rates (30 fps, 60 fps, etc.) the resulting file seems to have dropped frames. If I set the frame rate to something like 10 fps then all frames are preserved in the resulting wmv file. When I make a movie I would really like to preserve all the frames I'm sending for encoding. Is there any way to change this behavior?

01 Apr 2010 Monte Owens

On 64 bit systems, also make sure you have the 64 bit Windows Media encoder installed. I had the following error too until installed it

Invalid MEX-file '...MATLAB Path...\mmwrite\mmwrite.mexw64': The specified module could not be found.

http://www.microsoft.com/downloads/details.aspx?FamilyId=CC41218D-7E37-4546-BF0B-1276959EE3EF&displaylang=en

03 Dec 2009 Dean

Thanks Micah,
Unfortunately the 64-bit version still seems to have issues with Server 2003 R2 even if I'm sure DirectX is installed. You probably don't have a computer with that OS to try, so if I ever make it work I'll let you know. Otherwise I'll just have to save AVI's with Matlab's function in 64-bit and go into a 32-bit Matlab and convert them.

01 Dec 2009 Micah Richert

Hi Dean and Caglayan,

You need to make sure that DirectX is installed on your system. Please download the newest version. This is the only dependency that mmwrite has. Caglayan, you probably downloaded a 32bit version of the library and it is not installed correctly; delete it and download the DirectX installer.

Also, make sure to use: list=mmwrite('','ListAviVideoEncoders')
NOT: list=mmwrite('ListAviVideoEncoders')

Best,
Micah

01 Dec 2009 Dean

Also, I am trying to run the function and keep getting similar error to Caglayan:
Invalid MEX-file '...MATLAB Path...\mmwrite\mmwrite.mexw64': The specified module could not be found.
For me I get this same error when I run either mmwrite('blah.wmv',mov) or list=mmwrite('ListAviVideoEncoders')

I tried installing ffdshow (supposedly 64-bit version of klite) but to no avail. I'm not sure where this depend.exe file can be found, but is it possible I'm missing a file or a codec still?

Thanks again!

30 Nov 2009 Dean

Micah,
Thanks for your work on writing video files using Matlab. I was wondering if you have any further insights into making mmwrite work with 64-bit windows? I am running 2009a 64-bit Matlab on a Windows Server 2003 R2 64-bit OS. Also, is there any possibility of including MPEG capabilites, or am I out of luck.

Thanks so much!

13 Nov 2009 Micah Richert

Hi Caglayan,

The second error message is pretty strange. It seems that somehow Matlab is calling the win64 version of mmwrite as if it were win32. I don't know how this could happen. I'll take a look at it in the next few days.

Best,
Micah

06 Oct 2009 Caglayan Dicle

Hi,

I can not run mmwrite/mmread on a 64-bit windows and a 64-bit Matlab 2009a.

The steps I followed are
1) Install klite codec pack.
2) Make sure they are in the system path
3) ran
list = mmwrite('ListAviVideoEncoders');

I got:

??? Invalid MEX-file F:\mmwrite\mmwrite.mexw64': The specified module could not be found.

4) I checked mmwrite.mexw64 dependencies with depend.exe downloaded the missing dlls and ran

list = mmwrite('ListAviVideoEncoders');

I got:

??? Invalid MEX-file 'F:\mmwrite\mmwrite.mexw64':
F:\mmwrite\mmwrite.mexw64 is not a valid Win32 application.

can you help me? can i run the 32-bit version on 64-bit windows and 64-bit matlab?

30 Apr 2009 Micah Richert

Hi Hassan,

First of all, mmwrite only supports making AVI,WMV,WMA or ASF files not MPG.

Second, the error message that you received can also be caused by specifying too high of a frame rate (greater than approximately 45 frames per second I think). Try specifying a slower frame rate.

Also, try making the movie size a multiple of 4 instead of just 2.

I hope that helps,
Micah

29 Apr 2009 hassan noura

hi for all,Sire i try to write a video in format .mpg
but i have error "??? Error using ==> mmwrite
WMProfileManager can not load prx profile. If you aren't loading a custom prx file, this most likely means that your
video size isn't a multiple of 2. Make sure both the width and height are even."?BUT THE WIDTH AND HEIGHT IS EVEN ?CAN YOU EXPLAIN PLZ WHAT SHOULD DO ...

HASSAN

22 Jan 2009 Baosheng Ma

The problem I have solved. The code like these:
...
conf.videoQuality = 50;
for index=1:idx
if index == 1
load('M_1.mat')
mmwrite('Animation.wmv',M,conf,'Continue');
pause(60)
elseif index < idx
fn=sprintf('M_%d.mat',index);
load(fn)
pause(30)
M.times=M.times+200/33*(index-1);
mmwrite('Animation.wmv',M,conf,'Continue','Initialized');
pause(80)
else
fn=sprintf('M_%d.mat',index);
load(fn)
pause(30)
M.times=M.times+200/33*(index-1);
pause(80)
mmwrite('Animation.wmv',M,conf,'Initialized');
end
end
...

That is, I must wait for some time, until read and write do not work at the same time. If the raw data is very large, then the waiting time should be correspondly langer. With this method the programm works. But it costs many time. For me even hours lang only to wait.

19 Jan 2009 Baosheng Ma

Hi, Micah, I have tried a lot and found something.

I have wrote some codes like this:

the first one:
load('M_1.mat')
mmwrite('Animation.wma',M,'Continue');

load('M_2.mat')
M.times=M.times+6.0606;
mmwrite('Animation.wma',M,'Continue','Initialized');

load('M_3.mat')
M.times=M.times+6.0606*2;
mmwrite('Animation.wma',M,'Continue','Initialized');

load('M_4.mat')
M.times=M.times+6.0606*3;
mmwrite('Animation.wma',M,'Continue','Initialized');

load('M_5.mat')
M.times=M.times+6.0606*4;
mmwrite('Animation.wma',M,'Continue','Initialized');

mmwrite('Animation.wma',M,'Initialized');

I run this code not automatic, but manneuly one after another. And it works.

the other one:

load('M_1.mat')
mmwrite('Animation.wma',M,'Continue');

for index=2:6
fn=sprintf('M_%d.mat',index);
load(fn)
M.times=M.times+6.0606*(index-1);
mmwrite('Animation.wma',M,'Continue','Initialized');
end

mmwrite('Animation.wma',M,'Initialized');

I run these codes automatically. Unfortunely, it doesn't work. I get always this error:

Matlab.exe-Error in application
the command in "0x12bc5038" point to store in "0x53fb3000". the Prosess "read" can not be done.

In other words, so far as I have tried, it cann't connect many files to one automatically. But I have to many these files. I cann't do it maneully one after another. How can I solve this problem?

Maybe it is a problem about sychronization. but in matlab there is nolikewise command as in Java, say, synchron.

19 Jan 2009 Baosheng Ma

Hi Micah,

thank you for your reply. The problem about the data structure I have already solved. But I have met another problem about making a video progressively:
I have wrote a programm like this:

idx=1; & the filenumber how many file I need to store the raw data
i_movie=1;
interval=0.1;
for t1=0:interval:1180
...
...
draw the picture
drawnow
...
%% create the data structure to store the data
M.frames(i_movie)=getframe(gcf);
M.times(i_movie)=i_movie/33;
if mod(i_movie,200)==0
M.width=size(M.frames(1).cdata,2);
M.height=size(M.frames(1).cdata,1);
fn=sprintf('M_%d.mat', idx);
save(fn,'M');
clear M;
i_movie=1;
idx=idx+1;
else
i_movie=i_movie+1;
end
end

M.width=size(M.frames(1).cdata,2);
M.height=size(M.frames(1).cdata,1);
fn=sprintf('M_%d.mat', idx);
save(fn,'M');

______________________________________________________
%% make the video from many pieces of files
load('M_1.mat')
mmwrite('Animation.wmv',M,'Continue');

for index=2:idx-1
fn=sprintf('M_%d.mat',index);
load(fn)
mmwrite('Animation.wmv',M,'Continue','Initialized');
clear M;
end

fn=sprintf('M_%d.mat',idx);
load(fn)
mmwrite('Animation.wmv',M,'Initialized');
clear M;

The raw data I have all stored in my files named M_1.mat, M_2.mat,...,M_idx.mat
But I simply cann't create the video from these files. Th first file M_1.mat is OK, but after that I load the next file M_2.mat then to call the commando:

mmwrite('Animation.wmv',M,'Continue','Initialized');

It doesn't work. It doesn't add the new data to my already created WMV file. What's the problem can it be?

17 Jan 2009 Micah Richert

Hi Baosheng Ma,

Yes the data structures returned by mmread and mmreader are different. Matlab incuded mmreader after I made mmread...

What are the width and height of the video you made? If they are not a multiple of 2 (as in even) then mmwrite will most likely fail. If they are not a multiple of 2 you will either have to resize the frames or remove a row or column so that the width and height are a multiple of 2.

I hope that is more clear.

Micah

16 Jan 2009 Baosheng Ma

I'm working with this problem. hope success.

16 Jan 2009 Baosheng Ma

Hi, thanks for the wonderful work. I want to use this programm to convert a big avi-file to a small mpg-file. The avi-file I have made with the troditional matlab conmmando like avifile, getframe und addframe. during this way I hava got my avi-file, then I have tried to convert this avi-file with mmwrite like this:

[audio video]=mmreader('myavifile.avi');
mmwrite('mympegfile.mpeg',video);

But unfortunately it doesn't work.
I get error like this:

??? Error using ==> mmwrite
mmwrite: unrecognized struct format, it must be a video or audio struct, or a configuration struct. Type
'help mmwrite' for more details.

First I didn't use the function 'mmread' but 'mmreader' of matlab. Then the data structure is different.

After that I have tried your last example for making a movie. But it doesn't work either. The error like this:

??? Error using ==> mmwrite
WMProfileManager can not load prx profile. If you aren't loading a custom prx file, this most likely means
that your video size isn't a multiple of 2. Make sure both the width and height are even.

What a problem can it be?

Thanks.
B. Ma

08 May 2008 Rudolph Shieh

What a wonderful program! It helps a lot! I want to make sure that whether the mmwrite program has limitation on the output frame rate or not? I input an avi file with frame rate=80 with mmread, and the "rate" field in the struct in Matlab workspace is 80 correctly. But after i use mmwrite to write out the video struct, i got a video file playing with rate slower than the original file (since the file information is correct.) I already set up the config structure with videoQuality=100, outputHeigh,Width,FrameRate equals to the input video. This problem doesn't happen when the input video has lower frame rate (for exmaple, 30 or 24.) The avi I used is http://videoprocessing.ucsd.edu/personal/sharnoy/IEEETranLCD/clips/Stock_original.avi.

24 Apr 2008 Micah Richert

Hi Zhu,

For your "??? Undefined command/function 'mmwrite'" problem, make sure that Matlab hasn't crashed before you call mmwrite and also that mmwrite is in your path (either current directory, or adding it to your path).

As for the crash, what was the code that you ran that caused the crash? It is hard for me to figure out what the problem is just from the crash.

Feel free to email me directly.

Micah

24 Apr 2008 songhao Zhu

Hi,thanks for your great work. I have meet some issues when using it.
First is when making an avi with custom compressors:
% make an AVI with custom compressors.
audioList = mmwrite('','ListAviAudioEncoders');
videoList = mmwrite('','ListAviVideoEncoders');
if ~any(ismember(list,'ffdshow video encoder'))
conf.videoCompressor = 'Cinepak Codec by Radius'; % default to this if ffdshow isn't installed...
else
conf.videoCompressor = 'ffdshow video encoder';
end
mmwrite('balh.avi',audio,video,conf);
The system gave following message:
??? Undefined command/function 'mmwrite'
What do you think?
Thanks. zhu

24 Apr 2008 songhao Zhu

I meet the same issue as Yannick. I have download the new version of 'ffdshow'.
The crash message is as below:
---------------------------------------------
Segmentation violation detected at Thu Apr 24 22:08:09 2008
---------------------------

Configuration:
MATLAB Version: 7.1.0.246 (R14) Service Pack 3
MATLAB License: 254509
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 2)
Processor ID: x86 Family 15 Model 4 Stepping 1, GenuineIntel
Virtual Machine: Java 1.5.0 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
Default Charset: GBK

Register State:
EAX = 00000000 EBX = 0c472420
ECX = 00000001 EDX = 199a7274
ESI = 199e05e0 EDI = 00cddccc
EBP = 00cdc76c ESP = 00cdc76c
EIP = 78502f16 FLG = 00010216

Stack Trace:
[0] libmx.dll:_mxGetPr(0, 0x00cde660, 0, 12) + 6 bytes
[1] mmwrite.mexw32:0x199c2260(0, 0x00cde660, 5, 0x00cde6c0)
[2] libmex.dll:_mexRunMexFile(0, 0x00cde660, 5, 0x00cde6c0) + 103 bytes
[3] libmex.dll:private: void __thiscall Mfh_mex::runMexFileWithSignalProtection(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00cde660, 5, 0x00cde6c0) + 73 bytes
[4] libmex.dll:public: virtual void __thiscall Mfh_mex::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00cde660, 5, 0x00cde6c0) + 169 bytes
[5] m_dispatcher.dll:public: virtual void __thiscall Mfh_file::dispatch_fh(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00cde660, 5, 0x00cde6c0) + 271 bytes
[6] m_interpreter.dll:int __cdecl mdDispatch(int,char const *,int,struct mxArray_tag * *,int,struct mxArray_tag * *,class Mfh_MATLAB_fn * *)(545, 0x0c474528 "mmwrite", 0, 0x00cde660) + 88 bytes
[7] m_interpreter.dll:_inDispatchFromStack(545, 0x0c474528 "mmwrite", 0, 5) + 800 bytes
[8] m_interpreter.dll:enum opcodes __cdecl inDispatchCall(char const *,int,int,int,int *,int *)(0x0c474528 "mmwrite", 545, 0, 5) + 145 bytes
[9] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag volatile *,int *)(2, 0, 0, 0) + 2534 bytes
[10] m_interpreter.dll:int __cdecl inInterPcodeSJ(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag *,int *)(2, 0, 0, 0) + 282 bytes
[11] m_interpreter.dll:_inInterPcode(2, 0x784d6e7c, 0, 0) + 81 bytes
[12] m_interpreter.dll:enum inExecutionStatus __cdecl in_local_call_eval_function(int *,struct _pcodeheader *,int *,struct mxArray_tag * * const,enum inDebugCheck)(0x00cdf278, 0x00cdf370, 2, 1) + 153 bytes
[13] m_interpreter.dll:$L74683(0x784d6e7c, 0x0c02bb20 "mmwrite('my_video1.avi',aud4,mov..", 0, 0) + 184 bytes
[14] m_interpreter.dll:enum inExecutionStatus __cdecl inEvalCmdWithLocalReturnandtype(char const *,int *,enum inDebugCheck)(0x0c02bb20 "mmwrite('my_video1.avi',aud4,mov..", 0, 2, 0x00cdf3bc "D?") + 69 bytes
[15] m_interpreter.dll:_inEvalCmdNoEnd(0x0c02bb20 "mmwrite('my_video1.avi',aud4,mov..", 1, 255, 0) + 16 bytes
[16] bridge.dll:enum inExecutionStatus __cdecl ThrowSignal(char const *)(0x0c02bb20 "mmwrite('my_video1.avi',aud4,mov..", 0x7c80b6a1, 0x01207520, 0x01207520) + 60 bytes
[17] bridge.dll:$L86781(0, 0, 0x784d6e58, 0x7c36b71f) + 432 bytes
[18] mcr.dll:public: void __thiscall mcrInstance::mnParser(void)(271289, 0x505c3a44, 0x72676f72, 0x46206d61) + 93 bytes
[19] MATLAB.exe:0x00401ca9(4194304, 0, 271289, 0x01207520)
[20] MATLAB.exe:0x00403d9f(0x0362cef0, 0x7c93056d, 0x7ffde000, 0x805512fa)
[21] kernel32.dll:0x7c816fd7(0x00403c1a, 0, 0, 0)

This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.

If it is an official MathWorks function, please
follow these steps in reporting this problem to The MathWorks so
that we have the best chance of correcting it:

1. Send this crash report to segv@mathworks.com for automated analysis.
For your convenience, this information has been recorded in:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\matlab_crash_dump.1028

2. Also, if the problem is reproducible, send the crash report to
support@mathworks.com along with:
- A specific list of steps that will reproduce the problem
- Any M, MEX, MDL or other files required to reproduce the problem
- Any error messages displayed to the command window
A technical support engineer will contact you with further information.

Thank you for your assistance. Please save your workspace and restart
MATLAB before continuing your work.

What do you think this problem?

Thanks.

22 Apr 2008 Micah Richert

Hi Yannick,

Buggy codecs can cause a problem. So, make sure that everything is up to date.

If you send me example code which causes the problem I can take a look at it.

Micah

19 Apr 2008 Yannick Maret

mmread and mmwrite are two nifty pieces of software! I just have problem with mmwrite. When I use mmwrite('blah.wmv',video,'Continue'), matlab crashes at the third or fourth mmwrite('blah.wmv',video2,'Continue','Initialized'). Actually, the crash message come up and matlab continue to run as long I don't clikc on the message (once I click, matlab is closed). When I click details, it shows that the cause of the crashe was mmwrite...

15 Apr 2008 Himanshu Vajaria

Works well almost most of the time. Fairly fast.

05 Dec 2007 Micah Richert

Hi Tim,

You will need to do something like this:
startTime = min(video.times(1),audio.times(1));
video.times = video.times - startTime;
audio.times = audio.times - startTime;

and then call mmwrite.

Best,
Micah

05 Dec 2007 Tim Student

Hi. I want a couple of frames to be writed to a file. I used the following commands:
[video, audio] = mmread(movie.mpg',60:190) and mmwrite('movie.wmv',audio,video);

After this, the movie.wmv is writed and it works. Except this file just as long as movie.mpg. Frame 60 to 190 only play, the rest is a frozen image.

With which command do I solve this, to remove the frames ( 1:59 and 190:end) ?

Thanks in advance. Nice program by the way!

15 Nov 2007 philippe bouttefroy

Hi there,

First of all, congrats for this function that is ... just awesome: saves me so much time and it is really user-friendly. I just want to raise a couple of bugs/issues I found when using it. The most important is the introduction of an additional frame everytime one wants to use the option 'Initialized'. After analysis, I am pretty sure this bug comes from the function and not my code. It gives the illusion of freezing everytime the structure is written in the file. For example, I created a function that loads the structure with the frames as much as it can (before the memory is full). Then, the structure is copied into a .avi file through mmwrite. And the process starts all over again. This is much faster than loading the structure for every single frame. It is interesting to note that the freezing also occurs when writing frame by frame. The second issue I had (and actually, it's more a question) regard the compression: is it possible to create a file with a lossless compression. Indeed, I need to run experiments for my research where I need the exact values of a pixel. I'm afraid a compression would slightly modify this values and thus, jeopardize the results.
I hope this e-mail is clear. So, to summarize, 2 issues: freezing effect and lossless compression. Thanks a lot.
P.S: I am willing to have a look at the code and possibly fix the bugs if it can save you time.

Thanks a lot,

Philippe

16 Aug 2007 Tim Streeter

Great! Thanks for saving me the time of writing this myself. Attempts at using Simulink's "To Multimedia File" were getting frustrating.

Updates
10 Aug 2007

Updated commented and included source.

12 Feb 2008

Added a warning about the width or height not being a multiple of 2; this seems to break WMV files now.

14 May 2010

Fixed the reduced frame rate issue mentioned by Monte Owens

Contact us