Hosted Projects - FS2 Required > Just Another Day

All about APNGs

<< < (3/3)

m!m:
Sorry for derailing the thread...

I'll work a bit on the FFmpeg APNG support and get that working a bit more efficiently. Maybe the multi-threading of the movie player will help APNG performance a bit if used properly.

Axem:
I wish all thread derails could be the cause for some performance improvements. :)

m!m:
I finished adding the scripting API for movie files (https://github.com/scp-fs2open/fs2open.github.com/pull/1794) and it looks very promising. This also supports displaying APNG files with full transparency support so it's basically a drop-in solution for the streaming animation API. However, since the movie player code preloads a few frames and also uses a separate thread it uses more resources than the streaming animation code so it might not be ideal in all circumstances. Also, it doesn't support seeking in the movie file yet so looping animations are not supported currently.

I used this script for testing the playback so you can use that to see how displaying a cutscene is done from Lua. player:isPlaybackReady() is basically the part where the background thread is involved since that checks if enough frames have been preloaded to start playback.

--- Code: ---
#Conditional Hooks

$Application: FS2_Open
$State: GS_STATE_MAIN_MENU
$On State Start:
[
player = gr.openMovie("test")
playbackActive = true
]

$State: GS_STATE_MAIN_MENU
$On Frame:
[
if playbackActive and player:isPlaybackReady() then
if lastPlayerTime == nil then
lastPlayerTime = time.getCurrentTime()
end
local currentTime = time.getCurrentTime()

playbackActive = player:update(currentTime - lastPlayerTime)

player:drawMovie(100, 100)

lastPlayerTime = currentTime
end
]

$State: GS_STATE_MAIN_MENU
$On State End:
[
player:stop()
player = nil
]

#End

--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version