jvcleave / ofxOMXPlayer

OpenMax accelerated video player for openFrameworks on the Raspberry Pi 0-3. Does not work with RPI4
GNU General Public License v2.0
180 stars 61 forks source link

running openFrameworks / ofxOMXPlayer in portrait mode on Raspberry PI2 #59

Closed nenadlazovic closed 9 years ago

nenadlazovic commented 9 years ago

As part of project, I need to run openFrameworks / ofxOMXPlayer in portrait mode on Raspberry PI2. I tried few things

Any suggestion on how to have ofxOMXPlayer plays in portrait mode ?

timonsku commented 9 years ago

I would encode the videos in 9:16 and try that. Also try textured mode, in non textured mode the hardware encoder just draws how ever it wants to the screen, in non-textured mode a 9:16 video is the only thing that could maybe work.

nenadlazovic commented 9 years ago

idea makes sense.

Concern is frame rate achieved in textured mode. We did play with ofxOMXPlayer in textured mode, we noticed that frame rate achieved drops significantly ... not 20,30% ... it drops 5-10 times (e.g. from 50 fps to 5 fps). Is that big of the frame rate drop expected in textured mode ?

jvcleave commented 9 years ago

there is a OMX_IndexConfigCommonRotate that may be able to rotate it - I usually start searching here

Yes - above 720p the textured mode is much slower

jvcleave commented 9 years ago

Change this method https://github.com/jvcleave/ofxOMXPlayer/blob/master/src/OMXVideo.cpp#L523

to this

    OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
    OMX_INIT_STRUCTURE(configDisplay);
    configDisplay.nPortIndex = m_omx_render.GetInputPort();

    configDisplay.set = (OMX_DISPLAYSETTYPE)(OMX_DISPLAY_SET_DEST_RECT|OMX_DISPLAY_SET_SRC_RECT|OMX_DISPLAY_SET_FULLSCREEN|OMX_DISPLAY_SET_NOASPECT | OMX_DISPLAY_SET_TRANSFORM);
    configDisplay.dest_rect.x_offset  = 0;
    configDisplay.dest_rect.y_offset  = 0;
    configDisplay.dest_rect.width     = 1280;
    configDisplay.dest_rect.height    = 720;
    configDisplay.fullscreen = OMX_FALSE;
    configDisplay.noaspect   = OMX_TRUE;    
    configDisplay.transform  = OMX_DISPLAY_ROT90;
    m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);

Make sure configureDisplay(); by editing the code here https://github.com/jvcleave/ofxOMXPlayer/blob/master/src/OMXVideo.cpp#L349

refer to this for other options https://github.com/popcornmix/omxplayer/blob/master/OMXVideo.cpp#L635

nenadlazovic commented 9 years ago

wow. thanks a lot.

bit confused. This code is in ofxOMXPlayer. Will this cause whole display to be rotated or just a one ofxOMXPlayer instance ?

Nenad

On Tue, Sep 15, 2015 at 2:02 PM, Jason Van Cleave notifications@github.com wrote:

Change this method https://github.com/jvcleave/ofxOMXPlayer/blob/master/src/OMXVideo.cpp#L523

to this

OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
OMX_INIT_STRUCTURE(configDisplay);
configDisplay.nPortIndex = m_omx_render.GetInputPort();

configDisplay.set = (OMX_DISPLAYSETTYPE)(OMX_DISPLAY_SET_DEST_RECT|OMX_DISPLAY_SET_SRC_RECT|OMX_DISPLAY_SET_FULLSCREEN|OMX_DISPLAY_SET_NOASPECT | OMX_DISPLAY_SET_TRANSFORM);
configDisplay.dest_rect.x_offset  = 0;
configDisplay.dest_rect.y_offset  = 0;
configDisplay.dest_rect.width     = 1280;
configDisplay.dest_rect.height    = 720;
configDisplay.fullscreen = OMX_FALSE;
configDisplay.noaspect   = OMX_TRUE;
configDisplay.transform  = OMX_DISPLAY_ROT90;
m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);

Make sure configureDisplay(); by editing the code here https://github.com/jvcleave/ofxOMXPlayer/blob/master/src/OMXVideo.cpp#L349

refer to this for other options https://github.com/popcornmix/omxplayer/blob/master/OMXVideo.cpp#L635

— Reply to this email directly or view it on GitHub https://github.com/jvcleave/ofxOMXPlayer/issues/59#issuecomment-140484683 .

timonsku commented 9 years ago

Oh thats great to know. Maybe I find the time to break that out as an option.

@nenadlazovic This only effects video played back with ofxOMXPlayer.

nenadlazovic commented 9 years ago

Did as proposed. Thanks. I also looked at https://github.com/popcornmix/omxplayer/blob/master/OMXVideo.cpp.

I was not quite sure about meaning of your comment

Make sure configureDisplay(); by editing the code here https://github.com/jvcleave/ofxOMXPlayer/blob/master/src/OMXVideo.cpp#L349 Please explain.

Below is modified configureDisplay() method. I am planning to add orientation to ofxOMXPlayerSettings in order to pass to to COMXVideo. Video performance portrait mode is quite decent. I tried 3 videos and it was playing quite fine.

As I am not familiar with ofxOMXPlayer code, don't have proper testing environment -> not comfortable changing it.

Would it be possible for you to add ofxOMXPlayerSettings.orientation attribute support ? I am sure that many people will welcome it. Thanks in advance.

    ofxOMXPlayerSettings settings;
    ...
    settings.orientation = true;    //0,90,180,270  <--- new attribute

Modified COMXVideo::configureDisplay() method

void COMXVideo::configureDisplay()
{
        OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
        OMX_INIT_STRUCTURE(configDisplay);
        configDisplay.nPortIndex = m_omx_render.GetInputPort();

        configDisplay.set = (OMX_DISPLAYSETTYPE)(OMX_DISPLAY_SET_DEST_RECT|OMX_DISPLAY_SET_SRC_RECT|OMX_DISPLAY_SET_FULLSCREEN|OMX_DISPLAY_SET_NOASPECT | OMX_DISPLAY_SET_TRANSFORM);

        configDisplay.dest_rect.x_offset  = displayRect.x;
        configDisplay.dest_rect.y_offset  = displayRect.y;
        configDisplay.dest_rect.width     = displayRect.getWidth();
        configDisplay.dest_rect.height    = displayRect.getHeight();

        configDisplay.fullscreen = OMX_FALSE;
        configDisplay.noaspect   = OMX_TRUE;
        configDisplay.transform  = OMX_DISPLAY_ROT270;

        m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
}       
nenadlazovic commented 9 years ago

managed to complete. works ok, using code above. thanks a lot.