Menu

Is it faster than mmreader()+read()

Help
Kevin
2009-01-12
2013-02-21
  • Kevin

    Kevin - 2009-01-12

    How is performance of the package? Is it faster than
    mmreader()+read()?

    I mean could the following code be real time?

    vr = videoReader('tests/numbers.uncompressed.avi');
    while (next(vr)) 
        img = getframe(vr); 
        imshow(img); 
    end

    mmreader()+read() in Matlab cannot be real time; if the above
    code can run much faster than mmreader()+read(), I finally find
    the package I want.

     
    • Kevin

      Kevin - 2009-01-12

      BTW, I need to retrieve frames randomly (by index).
      Could it be real time? Say on mpeg4 videos.

       
      • Gerald Dalley

        Gerald Dalley - 2009-01-12

        videoReader will typically be much faster than mmreader because it keeps a file open.

        Random access to general mpeg4 video will not be realtime even with a highly-optimized pure C implementation.  To do a random seek, you must seek to the nearest independently-coded frame (I-frame) prior to the desired frame.  Any implementation must then do some extra decoding to actually get to the desired frame.  If bidirectionally-encoded frames are used, both the previous and the next I-frame must be decoded.  For typical mpeg4 videos, there are a lot of progressive and bidirectional frames between I-frames,which greatly slows down random access, no matter what software you use.

        If you want fast random access, do one of the following: (1) make sure I-frames are forced to occur very frequently, maybe as often as every 4 frames, (2) use mpeg2 or mpeg1 -- they tend to have much more frequent I-frames than mpeg4, (3) use a codec designed for random access like huffyuv or Cineform.  These options lower the compression ratio.

        If you're willing to have it seek to approximately the right position, but not exactly to the requested position, videoReader can be fast.

         
        • Gerald Dalley

          Gerald Dalley - 2009-01-12

          Quick update... I was thinking of the older Matlab API in the last post.  videoReader should be roughly the same speed as mmreader in most cases.

          You'll need better hardware, a different I-frame frequency, and/or a different codec for better performance.

           
        • Kevin

          Kevin - 2009-01-12

          Thanks a lot for your clear explanations.

           
    • lvdmaaten

      lvdmaaten - 2009-08-05

      On my platform (Mac OS 10.5.7 with Matlab 7.6) videoIO is actually a lot faster than mmreader. This may be very platform-specific though!

      Example:

      >> obj = mmreader('intersection300.orig.revel.avi');
      >> tic, video = read(obj); toc
      Elapsed time is 10.292934 seconds.
      >> tic, video = doFullRead('intersection300.orig.revel.avi', 'ffmpegDirect'); toc
      Elapsed time is 3.375455 seconds.

       

Log in to post a comment.