Video Performance
Posted: 24 July 2011 09:06 AM   [ Ignore ]
Rank
Joined  2011-07-19
Total Posts:  11
New Member

hello all,

I am working in a project that requires to display up to 6 videos at the time, but I noticed that the performance of the videos start getting poor as soon as I start reproducing more than one video. the videoas are not big 294x184 and is just 30 sec in average, so I really think that the performance should be better that what I getting in my app, so I am suspecting I should be doing something wrong with the video player class that im using.
So for testing purposes i took a fresh installation of mt4j taken from the svn a couple of days ago, then I installed GLGraphics-0.99 and GSVideo-0.9 on my environment and create an MTApplication based on the HelloWorld example that instead of adding the text is adding videos.
I noticed that the version I got from the svn does not have the video widget MTMovieClip as previous versions have and thats were I think my problem might be, so i just developed a small class based on the loop example of the GSVideo:

package basic.video;

import org.mt4j.components.TransformSpace;
import org.mt4j.components.visibleComponents.shapes.MTRectangle;

import processing.core.PApplet;
import processing.core.PImage;

import codeanticode.gsvideo.GSMovie;

public class 
VideoPlayer extends MTRectangle {

    
private PApplet app;
    private 
GSMovie myMovie;
    private 
PImage movieTexture;

    public 
VideoPlayer PApplet appString moviePath{
        super
app,400400 );
        
this.setNoFill(true);
        
this.setNoStroke(true);
        
this.app app;
        
myMovie = new GSMovie(appmoviePath);
        
movieTexture = new PImage();
        
myMovie.setPixelDest(movieTexture);
        
myMovie.setEventHandlerObject(this);
        
myMovie.loop();
    
}
    
public void movieEvent(GSMovie myMovie2{
        System
.gc();
        
myMovie.read();
    
}
    
@Override
    
public void updateComponent(long timeDelta){
        this
.setWidthLocal(myMovie.getSourceWidth());
        
this.setHeightLocal(myMovie.getSourceHeight());
        
movieTexture myMovie.get();
        
app.imagemovieTexture
                     
this.getPosition(TransformSpace.RELATIVE_TO_PARENT).getX()-this.getWidthXYRelativeToParent()/2
                     
this.getPosition(TransformSpace.RELATIVE_TO_PARENT).getY()-this.getHeightXYRelativeToParent()/2);
    
}
}

As I said the full MT application is based on the ‘hello world’ example, here is the code of the scene:

package basic.video;

import org.mt4j.MTApplication;
import org.mt4j.input.inputProcessors.globalProcessors.CursorTracer;
import org.mt4j.sceneManagement.AbstractScene;
import org.mt4j.util.MTColor;

public class 
VideoScene extends AbstractScene {

    
public VideoScene(MTApplication mtApplicationString name{
        super
(mtApplicationname);
        
        
this.setClearColor(new MTColor(146150188255));
        
//Show touches
        
this.registerGlobalInputProcessor(new CursorTracer(mtApplicationthis));
        
        
//Create a video
        
this.getCanvas().addChild(new VideoPlayer(mtApplication,"bin/data/video3.mov"));
    
}
    
}

and the app:

package basic.video;

import org.mt4j.MTApplication;

public class 
StartVideo extends MTApplication {
    
private static final long serialVersionUID 1L;
    
    public static 
void main(String[] args{
        initialize
();
    
}
    
@Override
    
public void startUp() {
        addScene
(new VideoScene(this"Hello World Scene"));
    
}
}

I tested this in similar setups for a mac snow leopard 64bits and a Windows 7 32bits with similar poor performance at the moment I start adding more than one video. The mac has problems when I am using .mp4 but i think the windows behaves better with the mp4 videos, the final setup is going to be a windows 7 setup so more worried about the performance there.
Do you guys have any advise for me in this one.
Thanks a lot,
Gustavo.

Profile
 
 
Posted: 24 July 2011 01:51 PM   [ Ignore ]   [ # 1 ]
Rank
Joined  2010-12-18
Total Posts:  51
New Member

I’m curious, what are the specs of your computer?

Profile
 
 
Posted: 25 July 2011 04:42 AM   [ Ignore ]   [ # 2 ]
Rank
Joined  2011-07-19
Total Posts:  11
New Member

Hey BMcFrizzle,
The Mac is not high specs so I’m not really expecting a wonderful performance there… it is a 2GHz Core Duo with 2GB of RAM with a video card Intel GMA 950
What worries me is the fact that the win machine is a Q8700 Quadcore processor with 4 gigs of Ram, and Geforce GTX550TI 1Gb DDR5 Display card so i was expecting a really good performance in that one but there is not considerable improvement. I’m also suspecting about the codecs… is there any recommended codec pack that works better with MT4J?
Thanks,
Gustavo

Profile
 
 
Posted: 25 July 2011 07:15 AM   [ Ignore ]   [ # 3 ]
Avatar
RankRankRankRank
Joined  2008-04-30
Total Posts:  612
Elite

Im curious about the

System.gc();

call in the movieEvent method. Did you put it there or was it in a gsvideo example? The method is invoked every video frame so this could be expensive.
The updateComponent method is invoked on every mt4j frame so we also have to be careful with expensive method calls.

this.setWidthLocal(myMovie.getSourceWidth());
this.setHeightLocal(myMovie.getSourceHeight());

Probably has to be done only once at the beginning.

The

myMovie.get();

method might also be expensive, maybe there is another way but not sure atm.

Using the latest gstreamer versions might bring speed improvements, too

The old MTMovieClip class etc has been moved to the MT4j Extensions Project (GStreamer) for license reasons:
http://code.google.com/p/mt4jextensions/source/browse/

 Signature 

MT4j - Multi-Touch for Java!

Profile
 
 
Posted: 25 July 2011 07:33 AM   [ Ignore ]   [ # 4 ]
Rank
Joined  2011-07-19
Total Posts:  11
New Member

Thanks for answering TherioN,
I put the garbage collector just as an alternative but similar results without it… actually if I put a large video and comment the gc() call the program rans out of memory.
thanks for the advise of resizing outside of the updateComponent method, that surely should have an impact, just made a quick test in the mac environment and the performance still poor.
I will download another version of gstreamer and see if that improves.
BTW, what happened with the MTMovieClip widget? is it deprecated?
Thanks,
Gustavo.

Profile
 
 
Posted: 25 July 2011 07:48 AM   [ Ignore ]   [ # 5 ]
Avatar
RankRankRankRank
Joined  2008-04-30
Total Posts:  612
Elite

The MTMovieClip (from the extensions SVN) in combination with the gstreamer version linked here (http://code.google.com/p/mt4j-gstreamer-extension/ scroll down) should work. And if you havent yet, you should try it.
The downside is that I had to modify the gsvideo library for proper use in mt4j which makes updating to newer versions (gsvideo) a little harder. I cant work on an update myself atm but welcome anyone you would take a shot at it =)
The most expensive part will always be the upload of the video data to the opengl texture. This is pretty optimized in the mt4j version (check mtvideotexture’s updateComponent method) compared to the processing image() method calls.

 Signature 

MT4j - Multi-Touch for Java!

Profile
 
 
Posted: 25 July 2011 08:50 AM   [ Ignore ]   [ # 6 ]
Rank
Joined  2011-07-19
Total Posts:  11
New Member

Thanks TherioN… I’m quite busy right now with something else, but for sure I will made some tests with the extension tomorrow and I will let you guys know!

Profile
 
 
Posted: 25 July 2011 01:49 PM   [ Ignore ]   [ # 7 ]
Avatar
RankRank
Joined  2011-01-06
Total Posts:  168
Member

i’m not an expert in those coding stuff but have you tried to play 6 or more videos in 6 players simultan? like 6 times vlc with 6 videos? Maybe its just a hdd-problem?

 Signature 

As always thanks to the NUI Group

Profile
 
 
Posted: 26 July 2011 04:27 AM   [ Ignore ]   [ # 8 ]
Rank
Joined  2011-07-19
Total Posts:  11
New Member

Hey ISoree, The very same videos reproduce with not problems in quick time player in the mac and thats why I think it should be possible to get a similar performance inside the MT4J environment.

Profile
 
 
Posted: 28 July 2011 10:12 AM   [ Ignore ]   [ # 9 ]
Rank
Joined  2011-07-19
Total Posts:  11
New Member

Hello There…
The suggestion of Therion of using MTMovieClip from the extensions really did the job… now the windows machine is playing those videos with a nice performance. Thanks for the help.
However I tried to install gstreamer in the mac as in (http://codeanticode.wordpress.com/2010/08/31/building-gstreamer-on-osx/) I followed all the steps and I couldn’t make it work. Actually it doesn’t bother me that much because the deploy machine is the windows one.
It would be really cool to have the gsvideo 0.9 working with this performance(I waned to used the setPixelDestination to be able of having videos with alpha channel), but I’m not brave enough to go into that library and made the changes to make it work in mt4j plus time-constrains.. always time.
Cheers,
Gustavo

Profile