Wednesday, November 3, 2010

Matlab AVI video use

Matlab requires a RAW VIDEO file to be imported and used. however most cameras and recording devices use a compression to reduce file size and so on.

my trouble was an AVI file with a different codec. when i used AVIREAD in matlab, it gave me an error that it wasnt able to find the codedc or the frames are not known.

one option that is FREE:
use FFMPEG im downloading the executable for windows from this URL
ffmpeg is a command line tool, so in order to convert to a raw video to use in maatlab you use this command:


c:/> ffmpeg -i foo.avi -vcodec rawvideo bar.avi


foo.avi is your compressed video file
bar.avi is your new raw video file name that you will use in MATLAB

7 comments:

  1. hi sir! i am a student currently doing a project about background subtraction. i have a question. how can i increase the frame rate of a video? can give me any suggestion? thank you very much.

    ReplyDelete
  2. in FFMPEG you can use the -r option to increase or decrease the framerate

    example of 32 fps
    ffmpeg -i input.avi -r 32 output.avi


    example of 1 fps
    ffmpeg -i input.avi -r 1 output.avi

    ReplyDelete
  3. hi aresh,
    I'm doing a project, I hope you can help me with it.
    I'm suppose to calculate the velocity of a falling ball in a liquid.
    do you know the command?

    I must also calculate the area of the ball.

    I can record this action via a digital camera using a 1000fps, 410fps, 210fps, or HD. (the higher fps, the lower the quality will get)

    please help me
    I'm not very good at matlab.

    ReplyDelete
  4. Thank you very much for sharing this. It helps me a lot as a new beginner in Matlab.

    By the way, I came across the 'mmreader' function. What are the differences between 'mmreader' and 'aviread'?

    ReplyDelete
  5. depending on your version of matlab mmreader is a deprecated function for the new matlab software

    ReplyDelete
  6. hi sir
    i have avi video,but cant read it in matlab, i'm try to use the aviread function and mmreader function but they failed to read this file the error message is "Initialization failed. (No combination of
    intermediate filters could be found to make the
    connection.)

    Error in ==> mmreader.mmreader>mmreader.init at 364
    obj.MMReaderImpl =
    audiovideo.mmreader(fullName);

    Error in ==> mmreader.mmreader>mmreader.mmreader at 133
    obj.init(fileName);"
    can you help me to solve this problem
    thanks

    ReplyDelete
  7. hello
    i am doing a project which involves taking some frames out of a video along with the sound. I tried using videoreader but i cant get the sound in it ( i use the getframe method to get frames). can anyone suggest how to get sound and frames simultaneously or atleast how to join them once i have them separately
    Thanks

    ReplyDelete