Drop in fps when playing movies on windows

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
medrimonia
Posts: 3
Joined: Thu Jan 07, 2016 12:30 pm

Drop in fps when playing movies on windows

Post by medrimonia » Thu Jan 07, 2016 1:23 pm

I have a set of video files in 1920*1080 (.mov) and I try to play them using the livecode 'player'.

While I use the same hardware on windows and macOS (dual-boot), I experience a very low fps (1 image per second) on windows, while the video is played smoothly on macOS. (the sound is played properly)

I checked on the quality of the display using classical video player on windows and quicktime, windows media player and vlc are all able to play the video without any drop in the framerate.

You will find here the code I use to play the video. I tried with and without the option alwaysbuffer, but it did not bring any improvement.

Code: Select all

      create invisible player "myPlayer"
      set the alwaysbuffer of player "myPlayer" to true
      set the filename of player "myPlayer" to fich
      set the height of player "myPlayer" to 542
      set the width of player "myPlayer" to 962
      set the location of player "myPlayer" to 513,351
      put the duration of player "myPlayer" into $videoSize
      put the timeScale of player "myPlayer" into $timeRatio
      if $timeRatio is 0 then 
         put 25 into $timeRatio 
      end if
      put $videoSize/$timeRatio into $videoTime
      -- put $videoSize/600 into $videoTime
      wait for 3 secs
      set the visible of player "myPlayer" to true
      wait for 0.3 secs
      start player "myPlayer"
      wait for $videoTime secs
      -- deal with click during the sound
      get flushEvents("all")
      wait for 0.3 secs
      delete player "myPlayer"
Is there a reason for such a low framerate when using livecode on windows, and does anyone has a clue toward a solution?


Some of you will notice that the video is resized (original size is divided by two with two additional pixels for the margin). Although reducing the quality of the video increase the framerate, I would like to keep the possibility of playing HD movies since my hardware can manage to play it with classical video players or even through livecode, when running on macOS.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Drop in fps when playing movies on windows

Post by jacque » Thu Jan 07, 2016 5:53 pm

I suspect this line:

wait for $videoTime secs

Wait is blocking. Try removing it. If that fixes the problem, add a mouseUp handler that checks whether the video is playing and blocks any user action if so.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

medrimonia
Posts: 3
Joined: Thu Jan 07, 2016 12:30 pm

Re: Drop in fps when playing movies on windows

Post by medrimonia » Thu Jan 07, 2016 11:58 pm

Thank you for your suggestion, I tested it, and looking through the documentation I also saw the possibility of adding *with messages* to the wait command, but both solutions did not bring any improvement.

Furthermore, since I still have some images (around 1 fps), even for video which last 10 seconds, the wait does not seem to be the problem, otherwise the video should entirely freeze for 10 seconds.

Does anyone has another guess?

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Drop in fps when playing movies on windows

Post by Klaus » Fri Jan 08, 2016 12:52 pm

Hi medrimonia,

1. welcome to the forum! :D

2. LC and QuickTime on WIndows is not the best combination, but the only one we have in the moment.
Maybe creating and deleting a player every time will cause some memory problems which will slow down things?

I would try to use only ONE (pre-set) player object and a different approach, see below:
a. Create a player and set its height, width and loc in the inspector as desired
Uncheck "border" so it is not "visible" when its filename is still empty!

Then use an extra handler that you execute with a delay like this:

Code: Select all

local tVideosize
local tTimeRatio

## Not sure where FICH comes from
global fich # ??

## Not sure where you want to put this:
on opencard # ????
   send "dotheplayerthing" to me in 3 secs
end opencard

command dotheplayerthing
   set the filename of player "myPlayer" to fich
   put the duration of player "myPlayer" into $videoSize
   put the timeScale of player "myPlayer" into $timeRatio
   if $timeRatio is 0 then 
      put 25 into $timeRatio 
   end if
   put $videoSize/$timeRatio into $videoTime
   wait for 0.3 secs
   start player "myPlayer"
   wait for $videoTime secs
   -- deal with click during the sound
   get flushEvents("all")
   wait for 0.3 secs
   set the filename of player "myPlayer" to empty
end dotheplayerthing
At least worth a try and one WAIT less :D


Best

Klaus

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

Re: Drop in fps when playing movies on windows

Post by Martin Koob » Fri Jan 08, 2016 4:43 pm

One thing that might be causing a problem is setting alwaysBuffer to true.

For the Mac there is a confirmed bug that doing this results in choppy playback.
http://quality.livecode.com/show_bug.cgi?id=12811

Maybe the same issue is affecting QuickTime on Windows.

Prior to the change to AVFoundation based player I would set alwaysBuffer to true when Live resizing a player object playing a video so the video played smoothly while being resized.

Because to the bug I had to stop using it but I found with AVFoundation I don't need to set alwaysBuffer to true to get smooth playback while resizing.

Still I think we need alwaysBuffer fixed though for other things like if you want to draw on top of the player video image.

Martin

medrimonia
Posts: 3
Joined: Thu Jan 07, 2016 12:30 pm

Re: Drop in fps when playing movies on windows

Post by medrimonia » Tue Jan 12, 2016 3:39 pm

I am sorry for keeping you waiting, I was quite busy on other projects.

I tried removing the alwaysBuffer as suggested by Martin without any improvement, it was worth a try!

Thank you for your suggestion Klaus, it was a good try, but it still doesn't bring any improvement.
At least, I can guess from your comments that the problem does not necessarily from my code, but more probably from the combination of quicktime library and windows.

I still find weird that using quicktime player outside of livecode, I can play the video smoothly!

If anyone has another guess, I'll be happy to try it, if not I will have to stick to mac users.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Drop in fps when playing movies on windows

Post by bn » Tue Jan 12, 2016 9:22 pm

Hi Medrimonia,

I suppose you played with the dontUseQT property? I don't see it in your code.

If you did not "set the dontUseQT to false" on a Windows computer that has Quicktime installed it is worth a try.

This property used to be set to false but lately it is set to true by default. Typically you would set it in a openstack handler -> see dictionary.

Kind regards

Bernd

Post Reply

Return to “Multimedia”