File Exchange

image thumbnail

mpgread

version 1.3.0.1 (494 KB) by

The MPEG converter takes a MATLAB movie matrix and writes the movie to disk as an MPEG file.

4.05882
17 Ratings

8 Downloads

Updated

View License

MPEG is an ISO standard movie encoding format. The MPEG converter for MATLAB takes a MATLAB movie matrix and writes the movie to disk as an MPEG file with file extension '.mpg' (MPGWRITE). It also takes an MPEG file and converts it into a MATLAB matrix (MPGREAD).

Comments and Ratings (40)

Phuc Nguyen

arun

arun (view profile)

hello everyone,can anyone over here tell me the procedure to which frame is a i,p,or b frame.i have extracted the frames from a mpeg-4 video.but,not getting how to detect the frmes.please help.

Philip

Philip (view profile)

Tips:
-you have to "make" before using. I made sure there were no mex or dll's in my MPGREAD directory, then ran makedll.m. All I believe is needed is mpgread.mex32.
-you have to remove audio, as others said, from your MPEG-1 for MPGREAD to read it. in Pinnacle Studio this can be done by selecting "settings" and unchecking include audio.

Rami

Rami (view profile)

Hi David, Thanks for nice program. I am using this as follow:
mpg_mov= mpgread('tumor1.mpg','indexed');
video = {mpg_mov.cdata}

Got error "??? Attempt to reference field of non-structure array."

Could you please help me resolve this problem. What alternative I should you to get cdata? Thanks

very nice programmm

Hi. I'm Jorge from Spain. I'm working in a academic proyect to finish my
Egineering degree. I'm trying to use mpgwrite and mpwread to design an
aplication about quality control in digital videos. My problem is with
mpgread. Whem I use mpgread I obtein one sequece of frames in a matlab
structure but in this structure frame 1 and frame 2 is the same frame than
frame 1 in the original video and I lost last frame. For example:

Compressed Video, frames: 1 2 3 4 5 6 7 8 9 10 Total number of frames: 10
Uncompressed Video, frames: 1 1 2 3 4 5 6 7 8 9 Total number of frames: 10

What can I do to resolve this problem? Thank's so
much in advance.

I have 7.6.0 matlab version. I'd like to know how I can obtain an mpeg video made also of B-frame. Because using mpgwrite (and then mpgread) I obtain an mpeg video made only of I- and P-frames. Can anyone help me?

saleh mohmed

how to change video to picture

dee smith

Does anyone know how to read mpeg-2 file using mpgread? MPEG-1 stram works fine, but mpeg-2 stream results in an error:
 "Segmentation violation detected at Fri Sep 21 15:59:49 2007 ..............."

Can anyone help?
thanks.

john m

I will answer my own question in order for others to benefit as well.

If you encounter the problems described in my previous post, it is likely that the mpgread mex file for your architecture is missing. for my linux installation, i had to compile the sources in the src/ folder. For this, i had to edit the make file and change cmex into mex (cmex was not found, mex is in the matlab bin folder). after calling make, a file called mpgread.mexglx was produced. i copied this into the mpgread folder and was able to call mpgread() from matlab with success.

best wishes,
john

john m

Dear all,

how can mpgread be used? The mpgread.m file only contains comments (for the help call), and calling mpgread like described in the documentation:

>> [movie, map] = mpgread('movie.mpg');

results in the error:

??? Attempt to execute SCRIPT mpgread as a function:
../mpgread.m

where .. denotes the path of the mpgread.m file (and all other files in the same dir)

does anybody know how to solve this?

thanks alot,
john

Samuel R

It works, just having trouble converting the movie into an width x Height x Length matrix so that I can compare to the uncompressed original data. Any ideas?

Balvinder Kaur

Excellent! I am glad to find it on Mathworks site!

insect Z

It's really neat! Is it possible to also put a mpginfo function? Return things like aviinfo?

David Zeng

Very Excellent!

Zhijun Wang

Very good

Thuy Than

How come it keeps on saying
Error in ==> c:\matlab6p5\mpgread\mpgread.dll
I did compile the file makedll and there is no problem with this. Can anyone give me a hand. Thank your very much for your kindness and have a good day!

Hua Zhang

I have separated video and audio by TMPGEnc. Still doesn't work, the error message is "Improper or missing sequence end code in MPEG file" Anyone know how to solve it? Thanks!

Muharram Mansoorizadeh

This tool may help to extract video only:
http://download1.pegasys-inc.com/download_files/TMPGEnc-2.524.63.181-Free.zip
file -> mpeg tools -> simple demultiplex.

I'think it needs an improvement to support audio + video encoded files for both wide range support and audio/video applications

Eugene Pretorius

The mpeg files contain an audio stream. If you remove it using some software encoding program mpgread works just fine

bai hongliang

i can use the mpgread in matlab6.5, release 13. I think many people may meet with the same problem, fistly system gives error message as "This is not an MPEG file" even if video is in MPEG. i solve the problem by changing the video format to MPEG-1 Video.
you can use the Ulead VideoStudio8.
may help to you.

Aimee Monteiro

what do we have to do after downloading the .zip file? we are clueless...

Sudhir Porwal

It is not working properly. It gives error message as "This is not an MPEG file" even if video is in MPEG. It also gives segmentation fault for some video files. It read a single video file successfully but the matrix contains only zeros. Finally, I could not use it. It reads MPEG-1 or MPEG-2 video?

ding ding

Is anyone willing to tell me how to use it via Matlab 6.0?

CW Ko

Hi I've tried to separate video and audio by TMPGEnc. But it still doesn't work and shows: "Segmentation violation" and crashed. My Matlab is R13. Does anyone know how to solve it? Thanks!

CW Ko

Have anyone encountered such a problem?

I cannot use mpgread at all. but I am sure the file is of MPEG format. So what's wrong?
Here is the message:
>> M = mpgread('d:\Studies\120V_cm_MPEG1.mpg');
??? This is not an MPEG stream.

Error in ==> D:\Matlab_Program\mpgread\mpgread.dll

Andreas -

Is there another way to get a grayscale frame?

[R G B] = mpgread('my_movie.m1v',1:1); % take frame 1
movie = (R + G + B) / 3; % graysacele it
frame1 = movie(1:567,1:720); % PAL framesize

Andreas

Dinh Q. Phung

There are a couples of emails sent to me asking for further help on video/audio separation issue, so I think it's helpful to briefly describe it here.

1. download the software - you only need to free demo version

2. Say "file.mpg" is your mpeg file with both video and audio.

3. From "File" menu choose "MPEG tools", then click on "Simple De-multiplexed"

4. Enter "file.mpg" in "Input" edit box, then specify names for your video and audio streams.

5. Click "Run", and that's it

Now your de-multiplexed (only) video file should be able to be called by mpgread function.

Dinh Quoc Phung

As one of you suggested, it works for me once I've separated the video and audio stream.
Here is a free software that can do the splitting job for you:
http://www.afterdawn.com/software/video_software/video_tools/tmpgenc.cfm

prem prem

give an example for using mpgread and mpgwrite functions in matlab.how to convert mpeg file into frames(no.)

vimal vimal

give me an example for opening an mpeg file in matlab.

pan lei

I cannot use this function ,my matlab's edition is matlab6.5,but this funciton doesn't work.Who can do me a favor to explain this question??The system always tells me "This is not a mpeg stream"!!!

Max Caprile

I can't read the files, the following message appears:
??? This is not an MPEG stream.

©P §Ó©¾

J Larsen

There aren't sufficient instructions to get this thing to work. You must have to be a guru in C and Matlab.

Richard Samms

Hey! Works! Using Matlab 5.3/VCC++6.0

Tried all methods of read. Once in, a colormap call and a movie call work. This'll come in handy

Asia m.

I downloaded the mpgwrite and mpgread from here, but they are empty files -- they only have comments in them. Is it supposed to be like that? Please advice me on this.
Thanx.

C Harding

The error message "This is not an MPEG stream" can be avioded by stripping the audio stream from the Mpeg first. I use a program called M1 Edit to do this before reading my MPEG into Matlab.

Hz Wang

I also met this problem whem I use MATLAB R12. I use
m=mpgread('test.mpg',[1:20],'truecolor');
movie(m)
and I found the background color have been changed! I wondering how to solve this problem or any othe updated mpgread available?

Thanks a lot!

John ng

This version is not work in matlab 6.1?!

As I have try to call mpgread in matlab 6.1,
but I only got the error message
"This is not an MPEG stream."
Please advice what's wrong.

I know that there is a update of mpgwrite,
will there be any update for mpgread ??

Thanks.

Updates

1.3.0.1

Updated license

1.3

Updated copyright and license information.

1.1

Updated description and copyright.

MATLAB Release
MATLAB 5.2 (R10)
Acknowledgements

Inspired: mmread

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video