Improving playback performance - multiple player objects

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
okk
Posts: 178
Joined: Wed Feb 04, 2015 11:37 am

Improving playback performance - multiple player objects

Post by okk » Wed Feb 04, 2015 1:50 pm

Hi,
I have a stack with a size of 4096×2304 pixels (4K). On the stack I placed 100 player objects that each references a QT clip (260x260px,12 fps, MPEG-4 Video, Linear PCM). I would like to play all clips at approximately the same time. I am on a Macbook Pro 2011 model. As expected, the playback is very poor.(about 0.5 frames per seconds...) My question: What can I do in order to improve playback performance (besides upgrading Hardware)? Can I do something with Livecode (like buffering ???) that would make playback smoother across the 100 player objects? Which video codec is most "easy" to handle for livecode? Is there any other way to improve playback?

Thanks for any hint.

Oliver

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Improving playback performance - multiple player objects

Post by Klaus » Wed Feb 04, 2015 2:44 pm

Hi Oliver,

1. welcome to the forum! :D

2. WOW, 100 player objects might be defintiely overkill and not only for Livecode! 8)
I don't think you can optimize performance with 100 player objects at all!

I have been working on a video application and the maximum we could play smoothly on a
Mac Pro with a FAST harddisk (sic!) was up to 16 movies at the same time.

Maybe you could create ONE BIG movie from the clip(s) and try to play this single movie?
Know what I mean? Maybe at half teh dimensions and then double its size on screen?
Just a thought, at least worth a try :D

Codecs:
Since LC does actually NOT handle media playback, it simply passes it to the
underlying media playback engine of the current OS, there is no such thing as an "easy" to handle codec,
MP4 is a standard format and should do.


Best

Klaus.

okk
Posts: 178
Joined: Wed Feb 04, 2015 11:37 am

Re: Improving playback performance - multiple player objects

Post by okk » Thu Feb 05, 2015 7:57 am

Hi Klaus,
thanks for the quick response. This project is a sort of data visualisation, so the player objects will be positioned on a x/y axis according to different questions/options the user selects. Therefore it is difficult to create one big movie file beforehand. I also don't aim for smooth playback of 100 full HD clips, the clips are only 200x200 pixel, ca. 15 sec each, and I could live with something like 6-8 fps. So I believe it is doable, but it is on the edge, therefore I was looking for any "trick" to optimize the playback. How about layerMode or qtIdleRate or alwaysBuffer? Can I somehow "pre-load" the clips (since they are just about 2 MB each or in total ca. 2GB)? Is alwaysBuffer a property that works similar to some sort of a pre-load function? But than the dictionary says:
Setting a player's alwaysBuffer to true always increases memory usage, and may make movie playing more jerky.


When you say, LC only passes the media playback to the underlying OS, does this mean following:
if I open 100 windows in QuickTime Player and the system can handle synchronous playback of those 100 movie clips, LC should be able to handle it as well? There should be no performance difference whatsoever if I play all those clips in Quicktime player or in LC? Or are there any Stack or Player-object properties that have an averse effect on playback performance in LC?


Thanks! BTW Great work you do here at the Forum!
Oliver

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Improving playback performance - multiple player objects

Post by Klaus » Thu Feb 05, 2015 2:53 pm

Hi Oliver,
okk wrote:How about layerMode or qtIdleRate or alwaysBuffer? Can I somehow "pre-load" the clips (since they are just about 2 MB each or in total ca. 2GB)? Is alwaysBuffer a property that works similar to some sort of a pre-load function? But than the dictionary says:
Setting a player's alwaysBuffer to true always increases memory usage, and may make movie playing more jerky.
layermode:
Player objects will always create some sort of overlay, which is always on top of all controls, so laymode does not apply here.

qtIdleRate:
Are you using LC >= 6.7x on a Mac?
Unless you explicitely:
set the dontuseqt to false
in your stack, LC now uses the new AVFoundation framework for playing media on OS X.
Apple has deprecated QuickTIme***, so this won't apply neither.

***The days of QuickTIme are definitively counted for the Mac and also for Windows.
E.g. when installing Apple's iTunes on Windows, it will NOT install QuickTime anymore!

alwaysbuffer:
the dictionary is correct!
With alwaysbuffer = true, the controller will not be functional, if that matters in your situation.
okk wrote:When you say, LC only passes the media playback to the underlying OS, does this mean following:
if I open 100 windows in QuickTime Player and the system can handle synchronous playback of those 100 movie clips, LC should be able to handle it as well?
No, you forget the overhead of communication LC <-> AVFoundation, so I think this will never be the same performance.
But I am no technical expert in this area 8)
okk wrote:Or are there any Stack or Player-object properties that have an averse effect on playback performance in LC?
No, I'm afraid 100 player objects at the same time are just to much.


Best

Klaus

okk
Posts: 178
Joined: Wed Feb 04, 2015 11:37 am

Re: Improving playback performance - multiple player objects

Post by okk » Fri Feb 06, 2015 11:09 am

Thanks for the further explanations. I use LC 7.01. so AV-Foundation framework is used. I have to find out more about it. I will do some testing when I get my hands on a mac pro with a fast ssd and see if there is any chance to get close to what I have in mind. My 2011 Macbook Pro managed around 20 player objects with my 200x200px mp4 files, so I have some hope. Best. oliver

PS: About Quicktime: I still remember vividly when I started to study back in the end of 1991 Quicktime was released and we played around with it. We were totally amazed when we could get a stamp-sized video playing back in our top of the line mac. times are changin.

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Improving playback performance - multiple player objects

Post by Klaus » Fri Feb 06, 2015 12:51 pm

Hi Oliver,
okk wrote:...PS: About Quicktime: I still remember vividly when I started to study back in the end of 1991 Quicktime was released and we played around with it. We were totally amazed when we could get a stamp-sized video playing back in our top of the line mac. times are changin.
yep, I was completely fascinated and "hooked" on moving images then!
Wasn't "0.mov" the guy with the cigarette smoke? :D


Best

Klaus

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

Re: Improving playback performance - multiple player objects

Post by Martin Koob » Fri Feb 06, 2015 8:04 pm

You could also try mergAV as a way to create players http://www.mergext.com

You have to create the controls to operate the players. I don't know if this is the case but since it is an external communicating directly with AVFoundation perhaps there would be a performance advantage.

Martin Koob

okk
Posts: 178
Joined: Wed Feb 04, 2015 11:37 am

Re: Improving playback performance - multiple player objects

Post by okk » Mon Feb 09, 2015 10:37 pm

Hi Martin, thanks for the hint. On a first look I cannot see why mergAV would improve playback performance. The external adds functions and commands to work with media; perhaps in a similar way then the EnhancedQT external, but simple playback should be the same with or without the external. But I will look at it more careful. Best Regards. Oliver

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

Re: Improving playback performance - multiple player objects

Post by Martin Koob » Wed Feb 11, 2015 2:41 am

Hi I am not sure if it would improve performance but I thought it may be worth a try as there may be less overhead than there would be using the LiveCode player object. Again this is just an unproven hunch.

Martin

okk
Posts: 178
Joined: Wed Feb 04, 2015 11:37 am

Re: Improving playback performance - multiple player objects

Post by okk » Tue Oct 20, 2015 1:42 pm

Just to report about our results: we managed to get up to 80 player objects playing almost synchronous on the late 2014 iMac (27" 5K i7, 8 GB RAM 4,0/M295X). We use OSX 10.10.5, LC 7.1. The players went out of sync by ca. 5 to 10 frames which was acceptable for our purpose. The video size was 150x150 pixels at a framerate of 12 fps and we had to use a ProRes 4444 codec to maintain transparency. When we went over the threshold of about 80 player-objects running at the same time motion got considerably more jerky. If perhaps maxing out the RAM at 32 GB can improve still perfromance, I don't know (yet). Best. Oliver

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Improving playback performance - multiple player objects

Post by Klaus » Thu Oct 22, 2015 1:21 pm

Congrats, consider me impressed! :D

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: Improving playback performance - multiple player objects

Post by bn » Thu Oct 22, 2015 3:37 pm

Hi,

from the very early days of Quicktime: the engineers made their own movie.

http://berndniggemann.on-rev.com/engine ... shower.mov

one of my all-time favorites.

especially "don't try this at home..."

Kind regards
Bernd

Post Reply