Re: [osg-users] [osgPlugins] Multiple video textures using ffmpeg plugin

2017-10-10 Thread Michael Maurus
Hi guys,

Thanks for the replies.
I tried using the suggested ffmpeg plugin changes, but it didn't make a 
difference.
Turns out the culprit was automatic texture scaling to power of two texture 
size.
After setting the resizePowerOfTwoHint to false, I was able to play two 720p 
videos with 60fps.

Cheers,
Michael

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72148#72148





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [osgPlugins] Multiple video textures using ffmpeg plugin

2017-10-06 Thread Sebastian Messerschmidt

Hi Guys,

Maybe this [1] might help to increase performance.
I'm not sure which ffmpeg is supported now, but maybe that's a good 
argument to upgrade.


Cheers
Sebastian

[1] https://developer.nvidia.com/ffmpeg


Hi Michael,
we use a modified version of the ffmpeg plugin with changes in
OpenSceneGraph\src\osgPlugins\ffmpeg\FFmpegDecoderVideo.cpp
to move the threads to different processors. (full modified file 
attached) It's a crude bit of code,

but it allows us to decode and show 2  1920x1080 movies at 30 fps.
I've pulled out just the code for cpu affinity, this should work with 
osg 3.4.2 as well as git master.

Regards, Laurens.


+ #define RESERVERD_CORES 2
+ static int next_cpu = RESERVERD_CORES;

void FFmpegDecoderVideo::decodeLoop()
{
     FFmpegPacket packet;
     double pts;
+     {
+         int num_cpus = OpenThreads::GetNumberOfProcessors();
+         if (num_cpus > RESERVERD_CORES + 1) {
+             int cpu = next_cpu;
+             ++next_cpu;
+             if (next_cpu >= num_cpus) next_cpu -= num_cpus - 
RESERVERD_CORES;

+             if (cpu >= num_cpus) cpu -= num_cpus - RESERVERD_CORES;
+             OpenThreads::SetProcessorAffinityOfCurrentThread(cpu);
+             OSG_WARN << "FFmpegDecoderVideo::run : 
OpenThreads::SetProcessorAffinityOfCurrentThread" << cpu << std::endl;

+         }
+     }

On Thu, Oct 5, 2017 at 4:54 PM, Robert Osfield > wrote:


Hi Michael,

On 5 October 2017 at 15:41, Michael Maurus > wrote:

This was actually a nice hint.
Only one of my CPUs was working at full capacity.


I haven't looked at the code recently so I'm a bit cold on the
ffmpeg implementation side.  I don't recall any external way to
control the threads that the ffmpeg creates.

 From what it sounds like is the threads that the ffmpeg plugin is
creating is inheriting the affinity of the thread that created
them.  In OSG master there is finer grained control over the
affinity setting behaviour, in your case it might be appropriate to
disable the default setting of affinity.

In an ideal world you want to decided which threads you want to run
on what threads, but this reques knowledge of all the threads, their
needs, and the hardware you are working on.

FYI, the OSG by default tries to make a best guess based on your the
number of CPU cores the OS says the machine has and the
configuration of your viewer, this scheme doesn't know about any
extra threads that plugins might create though.  This scheme is more
hardwired in OSG-3.4 and prior releases, so master might be the
thing to use if you do end up needing more control.

Robert.


___
osg-users mailing list
osg-users@lists.openscenegraph.org

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [osgPlugins] Multiple video textures using ffmpeg plugin

2017-10-05 Thread Robert Osfield
Hi Michael,

On 5 October 2017 at 15:41, Michael Maurus  wrote:

> This was actually a nice hint.
> Only one of my CPUs was working at full capacity.
>

I haven't looked at the code recently so I'm a bit cold on the ffmpeg
implementation side.  I don't recall any external way to control the
threads that the ffmpeg creates.

>From what it sounds like is the threads that the ffmpeg plugin is creating
is inheriting the affinity of the thread that created them.  In OSG master
there is finer grained control over the affinity setting behaviour, in your
case it might be appropriate to disable the default setting of affinity.

In an ideal world you want to decided which threads you want to run on what
threads, but this reques knowledge of all the threads, their needs, and the
hardware you are working on.

FYI, the OSG by default tries to make a best guess based on your the number
of CPU cores the OS says the machine has and the configuration of your
viewer, this scheme doesn't know about any extra threads that plugins might
create though.  This scheme is more hardwired in OSG-3.4 and prior
releases, so master might be the thing to use if you do end up needing more
control.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [osgPlugins] Multiple video textures using ffmpeg plugin

2017-10-05 Thread Michael Maurus
This was actually a nice hint.
Only one of my CPUs was working at full capacity.

The FFmpegImageStream inherits from OpenThreads.
So I should have two separate threads for both decoders, right?

Is there a possibility to SetProcessorAffinityOfCurrentThread() from outside 
FFmpegImageStream?

How about ffmpeg plugin puts different encoders in different processors?
And why doesn't it upload a bunch of frames (maybe even the whole video) as a 
texture2darray to the graphics card which would improve performance even 
further?

Is it possible to create a Texture2DArray out of the loaded ImageStream to do 
that manually?

Cheers, Michael

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72112#72112





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [osgPlugins] Multiple video textures using ffmpeg plugin

2017-10-05 Thread Voerman, L.
Try to make sure the ffmpeg decoding happens on different actual cores. osg
currently cannot detect hyperthreading, so the decode threads can end up on
the same core. Try to see in taskmanage (for windows) or top (for linux)
how many cores you actually use - this might hint to the problem.
The ImageStream sends frames one by one to the gfx in the graphics thread,
after detecting that a decoding thread changed the modified count.
Regards, Laurens.

On Thu, Oct 5, 2017 at 12:02 PM, Michael Maurus 
wrote:

> Hello everyone,
>
> I am currently trying to display a video (mp4) on a textured quad using
> the osgmovie example. When displaying two of those, I suddenly get a frame
> drop from 60fps to 12fps.
>
> So my question: what's the proper way to to this without performance
> issues?
>
> I am not sure how the ImageStream class works in the background. Already
> looked at the source code but I couldn't figure out, if the current video
> frame will be loaded to the graphics cards every frame or the whole video
> will be uploaded to GPU memory
>
> Thank you!
>
> Cheers,
> Michael
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=72108#72108
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] [osgPlugins] Multiple video textures using ffmpeg plugin

2017-10-05 Thread Michael Maurus
Hello everyone,

I am currently trying to display a video (mp4) on a textured quad using the 
osgmovie example. When displaying two of those, I suddenly get a frame drop 
from 60fps to 12fps.

So my question: what's the proper way to to this without performance issues? 

I am not sure how the ImageStream class works in the background. Already looked 
at the source code but I couldn't figure out, if the current video frame will 
be loaded to the graphics cards every frame or the whole video will be uploaded 
to GPU memory

Thank you!

Cheers,
Michael

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72108#72108





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org