Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: Crimson Wizard on Fri 08/07/2022 19:34:30

Title: PLUGIN: SpriteVideo v0.9.7 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Fri 08/07/2022 19:34:30
This is an upgrade of the older "Direct3D" plugin by AJA (https://www.adventuregamestudio.co.uk/forums/index.php?topic=45348.0), which was used to display Theora videos in AGS, and also freely display sprites with various transformations (without creating standard game objects).

The original plugin was a nice addition as it worked around some engine's limitations, such as being unable to display video non-blocking or while keeping some other objects on screen (like GUI or cursor); or randomly creating scaled and rotated sprites on any layer in game. Not much changed since, except maybe in AGS 3.6.0 Overlays now come close to this plugin's sprites abilities.
But the older plugin also had a significant limitation, as it was made for an older engine, it did not support anything besides Direct3D renderer on Windows.

This new upgraded version, called "SpriteVideo", now has following major improvements:
* OpenGL renderer support;
* May be built for Linux and Android;
* When used along the latest AGS 3.6.1+ may stream video from within the game package too (no need to put video files directly in the game folder).
* Potentially maybe will work on Mac OSX, but not yet configured the project for that. Also I don't know how to build on Mac :/, so help is welcome.

Another important part is that this plugin is purposely made 100% script compatible with the old plugin, which means that you may simply replace it in your game project and all the scripts will continue to work. In fact, you may even rename new plugin's dll into "ags_d3d.dll", replace it in the game folder, and it should hook up correctly.

WARNING: neither the original plugin nor this reimplementation play any sounds from videos, they only display video frames. Adding sound support might be a goal for the future versions, but it's not in the immediate plans.
UPDATED INFO: AGS 4.0 supports non-blocking videos with sound starting with Alpha 9, see this post for details (https://www.adventuregamestudio.co.uk/forums/ags-engine-editor-releases/ags-4-0-early-alpha-for-public-test/msg636661716/#msg636661716). If you're using AGS 4, it's likely that you don't need this plugin at all.

Documentation:
https://github.com/ivan-mogilko/ags-spritevideo/wiki

The plugin is currently in the "test stage", and I will be interested to see how it works with existing games that used the original plugin. My primary goal at this point is to make it complete and stable substitute for "Direct3D" plugin.

Downloads:
Updated 22 December 2023
For Windows: https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.7/win_ags_spritevideo.zip
For Linux (debian-based): https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.7/libags_spritevideo.tar.xz
For Android: https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.7/android_libags_spritevideo.zip
Source code: https://github.com/ivan-mogilko/ags-spritevideo

TODO for v1.0:
* Testing in some real games.
* Bug fixing (https://github.com/ivan-mogilko/ags-sprite3d/issues?q=is%3Aissue+label%3Ainvalid%2Cbug+is%3Aopen)
Title: Re: PLUGIN: Sprite3D v0.9 (sprite and video render), based on Direct3D plugin
Post by: Tarnos12 on Sat 09/07/2022 18:07:10
Thanks,

Just to add to that, the documentation for d3d is not complete afaik.
There are some properties and/or functions which don't have explanations.

Looking forward to android/osx support in the future and perhaps some new features.
Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Sun 10/07/2022 03:21:40
Updated to v0.9.1, now implements D3D.OpenSpriteFile() again.

For Windows: https://github.com/ivan-mogilko/ags-sprite3d/releases/download/v0.9.1/win_ags_sprite3d.zip
For Linux (debian-based): https://github.com/ivan-mogilko/ags-sprite3d/releases/download/v0.9.1/libags_sprite3d.tar.xz

I think this now covers all the functionality of the old plugin. What remains is mostly testing and writing a documentation.
Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: Vincent on Mon 11/07/2022 08:10:11
Thank you very much Crimson for working on this plugin, I really appreciate! 💖
Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: AndreasBlack on Fri 15/07/2022 15:38:54
Cool! Can't wait to try it out later! 8-0  (nod) Thanks like always. Too much summer activities as of lately so not much of game creation going on, on my end. Great to see others keeping the spirit up (laugh)
Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: Jess McD on Thu 21/07/2022 04:43:37
I tried to use this plug in on my test game, but received an error "undefined token 'video'".  I was attempting to play the video clip on room load before the fade in.  Is there anything I need to do beyond copying the plug-in file to the ags directory?

I'm running AGS Build 3.5.1.19

Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Thu 21/07/2022 11:31:32
Quote from: Jess McD on Thu 21/07/2022 04:43:37
I tried to use this plug in on my test game, but received an error "undefined token 'video'".  I was attempting to play the video clip on room load before the fade in.

Please post your script where you are using this plugin?

Quote from: Jess McD on Thu 21/07/2022 04:43:37
Is there anything I need to do beyond copying the plug-in file to the ags directory?

You also need to activate the plugin in the game's project tree.
Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: Jess McD on Sat 23/07/2022 20:49:56
The plugin is activated.  This is just a simple room where I would like it to play the video, then open a menu with a title screen and start button.  Everything works just fine, until I try to add the video.  The plug in instructions just had the code, but not a lot of explanation, so I'm sure I just missed something

The code is below.  -Thank you!

// room script file


function room_Load()
{
gIconbar.Visible = false;
gStatusline.Visible = false;
mouse.DisableMode(eModeWalkto);
mouse.DisableMode(eModeLookat);
mouse.DisableMode(eModeInteract);
mouse.DisableMode(eModeTalkto);
mouse.DisableMode(eModeUseinv);
mouse.DisableMode(eModePickup);
mouse.DisableMode(eModeUsermode1);
mouse.DisableMode(eModeUsermode2);
mouse.EnableMode(eModePointer);
mouse.Mode = eModePointer;

// Required for autoplay
    D3D.SetLoopsPerSecond( GetGameSpeed() );
   
    // Open video file
    video = D3D.OpenVideo( "G:\AGS_RPG_POC\Renders\MMI Intro.ogv" );
   
    if ( video )
    {
        // Use room coordinates
        video.relativeTo = eD3D_RelativeToRoom;
       
        // Anchor point to top left corner
        video.SetAnchor( -0.5, -0.5 );
       
        // Play!
        video.Autoplay();
    }
    else
    {
        Display( "Couldn't open video." );
        return;

aTitleMusic.Play();
}

function Startbutton_AnyClick()
{
cEgo.ChangeRoom (2);
}

function room_Leave()
{
// Free memory when leaving the room
    video = null;
}
Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Sat 23/07/2022 20:59:37
Quote from: Jess McD on Sat 23/07/2022 20:49:56Everything works just fine, until I try to add the video.  The plug in instructions just had the code, but not a lot of explanation, so I'm sure I just missed something

In your code you are using a variable called "video", but you have not declared it anywhere. Since you are using it in multiple functions, you need to declare a global variable, somewhere at the top of your script:
Code (ags) Select

D3DVideo* video;

Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: Jess McD on Sat 23/07/2022 21:46:38
I placed:

Code (ags) Select
// define video
D3DVideo* video;


at the top of the global script, but I still get the undefined token error on the "video = D3D.OpenVideo ....." line of my room1 script.


Thank you for your help so far, I appreciate it.
Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Sat 23/07/2022 22:26:44
Quote from: Jess McD on Sat 23/07/2022 21:46:38
I placed:

Code (ags) Select
// define video
D3DVideo* video;


at the top of the global script, but I still get the undefined token error on the "video = D3D.OpenVideo ....." line of my room1 script.

If you are using this variable only in the room script, then you should declare it in the room script. Room script does not see variables declared inside the global script.

If you want to use this variable throughout the game, in global script and multiple rooms, then you need to place it in global script and import/export it.
Code (ags) Select

// in GlobalScript.asc
D3DVideo* video;
export video;

// in GlobalScript.ash
import D3DVideo* video;


AGS manual has this article about sharing variables between scripts:
https://adventuregamestudio.github.io/ags-manual/ImportingFunctionsAndVariables.html
Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: Jess McD on Mon 25/07/2022 01:22:54
Thanks again for all your help!  I'll be using video in every room, so this sounds like a great solution.  I placed the code as instructed, lines 2&3 in the global script and line 6 in the global header.  I'm now getting the following error when I attempt to run the game.

Code (ags) Select
Failed to save room room1.crm; details below
GlobalScript.ash(7): Error (line 7): expected variable or function after import, not 'D3DVideo'


Sorry for asking so many questions - this is the first time I've used a plug-in.  Getting the music to keep playing while a video plays is one the last obstacles to overcome for my little proof of concept game - then I can start developing the real thing!

Thanks again!
Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Mon 25/07/2022 04:23:15
Quote from: Jess McD on Mon 25/07/2022 01:22:54
Code (ags) Select
Failed to save room room1.crm; details below
GlobalScript.ash(7): Error (line 7): expected variable or function after import, not 'D3DVideo'


Sorry for asking so many questions - this is the first time I've used a plug-in.

Sorry, I said it wrong, it's D3D_Video, not D3DVideo.
This is mentioned in the original plugin's documentation here: http://www.serpentpictures.net/ags_d3d/ where it sais "b) Playing a video over the background"


EDIT:
Quote from: Jess McD on Mon 25/07/2022 01:22:54Getting the music to keep playing while a video plays is one the last obstacles to overcome for my little proof of concept game - then I can start developing the real thing!

I was curious and found your previous posts about the game you're trying to make here: https://www.adventuregamestudio.co.uk/forums/index.php?topic=60020.0

I must mention that this plugin does not play any sound, it technically has no audio output, so it only displays video frames. I should have mentioned this in the description earlier.
Resolving the sound issue would require either to fix the engine and let it play video sounds simultaneously with the game sounds (that's perfectly possible to do), or extend the plugin to support audio output.
Title: Re: PLUGIN: Sprite3D v0.9.1 (sprite and video render), based on Direct3D plugin
Post by: Jess McD on Tue 26/07/2022 04:27:09
Thank you!  The video played, and my menu sprites were still displayed above the video, that's exactly what I wanted!  I experimented by playing an audio file immediately after the video started, and it played at the same time.  I'll continue experimenting with playing the audio exported from the original video files and see how close they sync up.

1 more question for you.  When the video ended it just froze on the last frame until I clicked.  Is there a way to make it go away without user input when the video ends? - Calculated video cycles then:

Code (ags) Select
WaitMouseKey(640);

video = null;


Thanks again!  Getting the video to play over the sound was a huge step toward getting my crazy idea out of my head and onto a screen. You made my day!
Title: Re: PLUGIN: Sprite3D v0.9.2 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Wed 27/07/2022 21:47:42
Updated to v0.9.2,

- Fixed D3D_Sprite's Tint properties not working in OpenGL mode.
- Fixed plugin crash when exiting game while video is playing.

For Windows: https://github.com/ivan-mogilko/ags-sprite3d/releases/download/v0.9.2/win_ags_sprite3d.zip
For Linux (debian-based): https://github.com/ivan-mogilko/ags-sprite3d/releases/download/v0.9.2/libags_sprite3d.tar.xz
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Tue 16/08/2022 14:53:44
I decided to rename this plugin from "Sprite3D" to "SpriteVideo", that in my opinion better reflects what it does and is meant for.
All the script commands stay the same, of course, but if you used this plugin before in your game, you only need to disable old plugin with old name, and activate new plugin with the new name.

Also, updated to v0.9.3 with some minor fixes.

For Windows: https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.3/win_ags_spritevideo.zip
For Linux (debian-based): https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.3/libags_spritevideo.tar.xz

I think the plugin is fully working and ready to be released as a complete version 1.0, but I would like to hear from someone who used this in real games, especially with OpenGL renderer and on Linux.
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: grahfmusic on Mon 03/10/2022 22:43:14
Excellent; I've been waiting for years for this plugin to be updated for me to get back into AGS again.  Unfortunately, it is using the Ogg Theora video, considering it has become an obsolete codec since VP8 and VP9.   Is it difficult to integrate more modern open-source codecs into AGS?
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Tue 04/10/2022 09:37:44
Quote from: grahfmusic on Mon 03/10/2022 22:43:14Unfortunately, it is using the Ogg Theora video, considering it has become an obsolete codec since VP8 and VP9.   Is it difficult to integrate more modern open-source codecs into AGS?

The video playback is fully implemented inside the plugin, it's not using AGS own functionality to play them. So there are two separate questions:
* video support in this plugin,
* video support in AGS itself.

I guess it's easier to do in plugin first, since it already has a non-blocking playback. AGS would require to reimplement video controls, and add more sophisticated playback script API to support the same thing.

Unfortunately, I have no idea what codecs VP8 and VP9 are, what are they played with. I understand the principles of programming video, but do not know alot about formats and codecs.
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Vincent on Mon 23/01/2023 11:26:42
Hello, I tested this plugin on the new version of Ags. I think this has already been documented but it seems the plugin doesn't work if the game is compiled for android, can you guys confirm this? When I open the game on my phone I get this screen: (Sorry for the giant picture)

(https://i.imgur.com/6ziEfz3.jpg)

In addiction I'd like to say that this plugin is very important to me because I like making FMV games and I would like if one day it could also embed video sound instead of mute because sometimes syncing sound with video is difficult. Also it would be very helpful (for me) if we could have a way to pause the video.
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Mon 23/01/2023 11:49:30
Quote from: Vincent on Mon 23/01/2023 11:26:42Hello, I tested this plugin on the new version of Ags. I think this has already been documented but it seems the plugin doesn't work if the game is compiled for android

Of course, you need to have this plugin compiled for Android too. Each plugin you are using has to be compiled separately for each platform you're building your game for.

I don't remember how do you add plugins for Android though, this has to be clarified. Probably, they are put somewhere inside the Android subfolder, inside the Editor program files.
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Vincent on Mon 23/01/2023 11:58:35
Quote from: Crimson Wizard on Mon 23/01/2023 11:49:30Of course, because you need to have this plugin compiled for Android too. Each plugin you are using has to be compiled separately for each platform you're building your game for.

I don't remember how do you add plugins for Android though, this has to be clarified.

Hi CW thanks for answering, I didn't know that I am sorry. So this might work on Android but the plugin need to be compiled separately, how to do that?
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Mon 23/01/2023 12:05:08
Quote from: Vincent on Mon 23/01/2023 11:58:35So this might work on Android but the plugin need to be compiled separately, how to do that?

I wish I knew myself... Theoretically this may be done under Linux, at least we were building some of the "standard" plugins for Android under Linux previously.

I will have to consult someone about this, like eri0o maybe.
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Vincent on Mon 23/01/2023 12:09:23
Quote from: Crimson Wizard on Mon 23/01/2023 12:05:08I wish I knew myself... Theoretically this may be done under Linux, at least we were building some of the "standard" plugins under Linux previously.

I will have to consult someone about this, like eri0o maybe.

There's no problem really, maybe @eri0o knows how to do that, sorry for mentioning.
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: eri0o on Mon 23/01/2023 12:38:21
To just run it's simply add the pre-builts of the plugin in the same place where pre-builts of the engine are placed, note there's a directory for each different architecture, so you want to build the plugin for all those individually.

The way I find easier to build is to add the plugin in the AGS cmake project and make sure the project is a shared library. Then it should create the additional plugin as a library in each architecture directory.

You can theoretically make your own Makefile, make sure it uses the same sdk and ndk AGS uses and all that but my experience was that keeping that updated with all the changes in Android was a much bigger burden if you want binaries that can actually be approved in Google Play.

Edit: ah, that would be all easier if there was a cmake project already in the plugin directory.
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Vincent on Mon 23/01/2023 13:01:22
Quote from: eri0o on Mon 23/01/2023 12:38:21To just run it's simply add the pre-builts of the plugin in the same place where pre-builts of the engine are placed, note there's a directory for each different architecture, so you want to build the plugin for all those individually.

The way I find easier to build is to add the plugin in the AGS cmake project and make sure the project is a shared library. Then it should create the additional plugin as a library in each architecture directory.

You can theoretically make your own Makefile, make sure it uses the same sdk and ndk AGS uses and all that but my experience was that keeping that updated with all the changes in Android was a much bigger burden if you want binaries that can actually be approved in Google Play.

Edit: ah, that would be all easier if there was a cmake project already in the plugin directory.

@eri0o do you mind to do a step-by-step walkthough on how to do this? If you dont mind and when you have some free time ofc!
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: eri0o on Fri 03/02/2023 02:17:10
Just for reporting, I looked into but there's a dependency (TheoraPlayer) that I have no idea how to build. My suggestion would be to make a minimal version of TheoraPlayer and have the source files of it in the project itself, but this looks like a ton of work. There it seems to be some sort of Android Studio project of that library there in TheoraPlayer sources, but I don't understand it, and there's a CMake file, but it's not written with anything beyond Linux in mind, so I didn't push it further. 
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Fri 03/02/2023 09:52:10
Quote from: eri0o on Fri 03/02/2023 02:17:10My suggestion would be to make a minimal version of TheoraPlayer and have the source files of it in the project itself

I may look into this if I have spare time.

There's already some issues with building TheoraPlayer on linux, as it does not have a proper lib installation.
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Vincent on Fri 03/02/2023 11:56:37
This is kind offtopic but there wont be a chance to change how the default 'playvideo' work? So to allow the video to play also in Noblock mode? Because the main focus of this plugin to me is that you can play a video in Noblock mode. Theoretically if that were the case there would be no need to use a plugin and in my mind an Android game would play the videos just fine with the standard Ags command, is that right?
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: eri0o on Fri 03/02/2023 12:27:48
Can you elaborate what is the use of playing videos in non-blocking? (Like, what's intended to happen simultaneously with the video)



The libogg, vorbis and theora are already dependencies in ags, and say in the future we want colored emoji fonts that are PNG based or adding reading PNG files to AGS itself, so libpng would be there too.

Somewhere in the future, it feels like a good idea to have this plugin sources around the other compatibility plugins in ags project itself. 
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Vincent on Fri 03/02/2023 12:34:04
Quote from: eri0o on Fri 03/02/2023 12:27:48Can you elaborate what is the use of playing videos in non-blocking? (Like, what's intended to happen simultaneously with the video)

Well all the stuff you can do when the game is not blocking you know? Eg. Like moving the mouse, interacting with buttons etc.
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: eri0o on Fri 03/02/2023 13:19:52
I made a post on the engine board for a  feature request to try to get the engine specifics there on a possible in engine implementation - For a short term version of it, it's best to focus on this plugin, but perhaps it's worth to discuss a bit what's needed in engine.
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Vincent on Fri 03/02/2023 13:44:15
Thank you very much for the post I really appreciated!!
Title: Re: PLUGIN: SpriteVideo v0.9.3 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Mon 24/04/2023 18:53:28
Updated to v0.9.4, fixed a crash upon restoring a saved game where some of the objects had Parents; and couple other minor fixes.

For Windows: https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.4/win_ags_spritevideo.zip
For Linux (debian-based): https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.4/libags_spritevideo.tar.xz
Title: Re: PLUGIN: SpriteVideo v0.9.4 (sprite and video render), based on Direct3D plugin
Post by: Vincent on Sat 29/04/2023 19:24:54
What it means if the objects had Parents if I might ask?
Title: Re: PLUGIN: SpriteVideo v0.9.4 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Sat 29/04/2023 19:30:36
Quote from: Vincent on Sat 29/04/2023 19:24:54What it means if the objects had Parents if I might ask?

You can connect objects together as Parent - Child, and then children's position and transformation becomes relative to the parent's.
The full explanation may be found in the docs, see the "SetParent" description:
https://github.com/ivan-mogilko/ags-spritevideo/wiki/SpriteVideo-API
Title: Re: PLUGIN: SpriteVideo v0.9.4 (sprite and video render), based on Direct3D plugin
Post by: Vincent on Sat 29/04/2023 19:48:18
Thanks a lot for the documentation, I was misunderstanding that it was something new in Ags instead is part of this plugin
Title: Re: PLUGIN: SpriteVideo v0.9.4 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Mon 15/05/2023 03:31:22
Quote from: eri0o on Fri 03/02/2023 02:17:10Just for reporting, I looked into but there's a dependency (TheoraPlayer) that I have no idea how to build. My suggestion would be to make a minimal version of TheoraPlayer and have the source files of it in the project itself, but this looks like a ton of work. There it seems to be some sort of Android Studio project of that library there in TheoraPlayer sources, but I don't understand it, and there's a CMake file, but it's not written with anything beyond Linux in mind, so I didn't push it further. 

@eri0o
I found some spare time and made a branch, placing minimal TheoraPlayer sources inside the plugin:
https://github.com/ivan-mogilko/ags-spritevideo/commits/theora-directlink2

It works on Windows and Linux.

Would it make it easier to build for Android? Note it still requires separate libpng, libogg, libtheora and libvorbis. TheoraPlayer comes with its own ogg/theora/vorbis sources, but I decided to skip these now, and only add later if there's really no other way.
Title: Re: PLUGIN: SpriteVideo v0.9.4 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Sun 12/11/2023 06:25:58
I made an attempt to build this for Android, it's quite rough and dirty though:
https://github.com/ivan-mogilko/ags-spritevideo/tree/android

preliminary build for a test:
https://www.dropbox.com/scl/fi/hh8fnokfl47918ixcavd9/libags_spritevideo.zip?rlkey=zgds6fc4hs5ztvri2ite5h78n&dl=0

UPDATE: the plugin is working, there are some issues, like sprite colors may be mismatched (RGB->BGR), but that is a minor problem compared to the rest.
I keep testing and fixing this in a spare time.

UPDATE 2: the biggest problem at the moment is that AGS plugins cannot read data that is not on disk, at all. Like, if a video file is packed inside the game's package, or inside Android's standard package, it cannot see and get it. Plugins only understand raw files on disk.
Idk if it's possible to force android to unpack some game files from APK. But ideal solution would be to add plugin API which requests "custom file stream" from the engine, which may load data from anywhere as needed. This is something that has to be done in AGS itself, plugin code cannot do that on its own.

This is an old problem with plugins, that has not be resolved still after all these years unfortunately.

I'm currently considering to add this ability to 3.6.1. This may be used even if you're making game in earlier versions (for example, make main game in 3.6.0, and build for Android in 3.6.1).

https://github.com/adventuregamestudio/ags/issues/2226

UPDATE 3: I got the experimental version working on Android, with video playback.
But to get to the actual release i'd need to do alot of tidying up.
* Add file stream to the 3.6.1 plugin API.
* Clean up plugin sources after lots of experimenting.
* Ensure plugin still runs with older engines, and correctly limits its functionality.
Title: Re: PLUGIN: SpriteVideo v0.9.4 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Fri 17/11/2023 20:05:42
Quote from: Crimson Wizard on Sun 12/11/2023 06:25:58But to get to the actual release i'd need to do alot of tidying up.
* Add file stream to the 3.6.1 plugin API.
* Clean up plugin sources after lots of experimenting.
* Ensure plugin still runs with older engines, and correctly limits its functionality.

This is practically done, what is currently pending is to merge the new API into the 3.6.1 engine, and then I'll be able to release a plugin's update that will fully functional on Android.

As a consequence of these changes this plugin will actually be able to load OGV videos packaged inside ags game too (previously it could only load from standalone files).
Title: Re: PLUGIN: SpriteVideo v0.9.6 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Sun 19/11/2023 16:51:33
Updated to v0.9.6

* Support Android version (renders with OpenGL ES 2.0).
* Videos and external PNG files are read using newer AGS engine File API if available, since 3.6.1 (will fallback to standard direct file reading if run with older engine). This lets to stream assets packed inside a game data pack too. This is the only method that will work on Android if game is packaged as APK.
* Plugin will print debug messages to stdout if failed to open file for logging.
* Fixed printing overly verbose "RENDER screen WxH" message.


For Windows: https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.6/win_ags_spritevideo.zip
For Linux (debian-based): https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.6/libags_spritevideo.tar.xz
For Android: https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.6/android_libags_spritevideo.zip
Source code: https://github.com/ivan-mogilko/ags-spritevideo



@Vincent I'm terribly sorry that this took so long, I've been thinking about doing this update, but was getting distracted all the time, and frankly thought that it will require me to spend much time learning configuring builds for Android. In reality that task took less time than I expected.

But then it turned out that it's not enough, because you cannot read videos from files on disk when running APK on Android, so I had to implement a new feature in the engine that would let plugins stream resources from any package that engine itself can read. (Of course same will work on Windows, Linux etc.)

Current version does work on Android with (almost) any engine, but it can only load videos from within APKs if you run it along the latest 3.6.1 (starting with 3.6.1.12 and later).
Title: Re: PLUGIN: SpriteVideo v0.9.6 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Sat 09/12/2023 21:34:28
I was doing an experiment of supporting audio playback in this plugin. This requires some also experimental, although relatively minor changes to the engine too, because I wanted the plugin to use standard engine's audio output instead of having its own.
This is achieved by exposing "audio player" interface in plugin API. The experimental draft may be seen here:
https://github.com/adventuregamestudio/ags/pull/2256

The test game that I quickly made up with two tiny pieces from "Lawrence of Arabia" movie (because I was too lazy searching for any suitable ogv files).
https://www.dropbox.com/s/c8vljxe5m3znji9/test--videoaudio.zip?dl=0

As may be seen in the demo, two videos may be played at the room background by pressing buttons on GUI. They are played with sound, and may play simultaneously. The game keeps working while the videos play (cursor moves, buttons are clickable, character may be walked around).

There's a strange issue where a number of last video frames is not rendered, videos got stuck at some point. From the first glance this is not a desynchronization, but actually frames not advancing or not drawn. They are present in original files.
Title: Re: PLUGIN: SpriteVideo v0.9.6 (sprite and video render), based on Direct3D plugin
Post by: Vincent on Mon 18/12/2023 11:13:03
@Crimson Wizard
First off, I am sorry for the late response, I didn't had much time to login in these days. Anyway don't worry, I know you guys are very busy fixing the engine stuff, so that's fine really. Indeed, I wanted to thank you for spending time on this plugin.

I downloaded the demo and everything is so beautiful, I'm very happy that now we can hear the audio from the video, this was one of the most important things (because on the old version you had to start the audio separately and sometimes it was difficult to synchronize the audio with the video) so for me this is a big one feature achieved along with the interactions with buttons while the video is playing, also having multiple videos playing at the same time is truly amazing, thank you very much, I am really happy!!

In the near future I will try to do also some tests on Android too to see if everything goes fine and I'll let you know.

Before you did this work on this plugin, I was trying to do the same "kind of test game" on Unity and basically now this plugin its working as Unity do, the only exception is that over there you have a chance to pause the video, in this state of the plugin is there a way to do that? If not then that isn't a big deal but if we could then I think it would be cool. Still thanks a lot for everything I really appreciated!!
Title: Re: PLUGIN: SpriteVideo v0.9.6 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Mon 18/12/2023 14:22:36
To be honest, I do not think this audio support will be added in 3.6.1 version. Previously I had a thought that it may be, but time have passed, and now I'd rather like to finalize 3.6.1 as soon as possible, and move on. This addition that lets plugin play sounds through the engine is formally working, but there is a number of issues, both in design and technical, which have to be resolved to make it stable and convenient in a long run. So, this will be likely added to AGS 4, or another minor update after 3.6.1, if there will be one at all.
Title: Re: PLUGIN: SpriteVideo v0.9.7 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Fri 22/12/2023 17:42:09
Updated to v0.9.7

This is a minor update, making the plugin compatible with AGS 3.6.1.14 (Beta 15), which had some fixes to the plugin API.

For Windows: https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.7/win_ags_spritevideo.zip
For Linux (debian-based): https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.7/libags_spritevideo.tar.xz
For Android: https://github.com/ivan-mogilko/ags-spritevideo/releases/download/v0.9.7/android_libags_spritevideo.zip
Title: Re: PLUGIN: SpriteVideo v0.9.7 (sprite and video render), based on Direct3D plugin
Post by: Crimson Wizard on Wed 27/03/2024 12:30:15
Only for the reference, AGS 4 wip version now supports non-blocking video playback with sound (!), which may be a better alternative that this plugin, if you are not against using a wip version of AGS.

See: https://www.adventuregamestudio.co.uk/forums/ags-engine-editor-releases/ags-4-0-early-alpha-for-public-test/msg636661716/#msg636661716