Author Topic: Movies - new possibilities for modding  (Read 6057 times)

0 Members and 1 Guest are viewing this topic.

Offline Mart

Movies - new possibilities for modding
« on: June 22, 2015, 12:58:06 AM »
I am not sure, how much of what I am going to post is already "old" stuff, but here it goes.

Working with coding, I tried to do recently something with playing our wve movie files. Recent PRACX patch made somewhat easier to watch them. Also, the "wve" format is old. I was wondering, if some new movies, or movie corrections, upgrades, etc. could be made. After looking for, unsuccessfully, encoders that would match the playuv15.exe player provided by SMACX, I made a solution in a different way.
By writing a short executable I was able to insert movie playing with ffplay.exe, which is part of the FFMpeg freeware.
The only thing not working, presently, is that after SPs there was this screenie with text giving some details about the SP. It is not there anymore. But maybe in the future, that could be solved.

What new capabilities that gives?
The ffplay.exe can be replaced at any time when there is a new version. This allows for making/having videos with even some newest encodings, resolutions, etc.
Also one would have broader choice of formats/codecs. Anything, that ffplay can show, it will be shown.
game exe sends the ".wve" file name, but that is not a problem. We could have e.g. avi file simply renamed to .wve and ffplay will take that without problems. These applications detect what kind of video types they deal with.

For now, the command is hardcoded, but future versions can make that customizable, when someone wants to adjust ffplay command.
Current settings are:
- fullscreen
- autoexit, which turned out to be necessary on my machine. But probably this is neutral in other cases.
And there was needed a solution for how PRACX patch works, since it has "-software" argument passed to playuv15, which is not understood by ffplay.
The executable has though the same name: "playuv15.exe" since this is what terran.exe and terranx.exe uses.

Only for windows presently.

Should I make that downloadable? (the original playuv15.exe would be there too, for easier uninstall of the option).
FFplay (FFmpeg) is freeware, so there will be probably no problem, one would need to acknowledge the FFmpeg creators, which I will make in a readme file.
Any interest in this in the current state?

Offline Buster's Uncle

  • With community service, I
  • Ascend
  • *
  • Posts: 49401
  • €73
  • View Inventory
  • Send /Gift
  • Because there are times when people just need a cute puppy  Soft kitty, warm kitty, little ball of fur  A WONDERFUL concept, Unity - & a 1-way trip that cost 400 trillion & 40 yrs.  
  • AC2 is my instrument, my heart, as I play my song.
  • Planet tales writer Smilie Artist Custom Faction Modder AC2 Wiki contributor Downloads Contributor
    • View Profile
    • My Custom Factions
    • Awards
Re: Movies - new possibilities for modding
« Reply #1 on: June 22, 2015, 01:03:24 AM »
I think it was Davyboy who posted some research into the text at the end a few years ago.  Might be worth looking for.

Offline Mart

Re: Movies - new possibilities for modding
« Reply #2 on: June 22, 2015, 01:12:24 AM »
Yes, I remember a thread about it. I will look for it.

On the other hand. Recently, I need to learn few things in coding (to make a living), so I would combine that with writing an application showing a text we want. I'm for it. :)

Offline Mart

Re: Movies - new possibilities for modding
« Reply #3 on: June 22, 2015, 12:20:35 PM »
As it turns out, ffmpeg is presently on github in public access.
They way it works, everyone can download source code and compile it.
And this is what I am going to do, so when providing appropriate license GNU LGPL, that is sufficient.

And regarding the text display after the SP movies, it looks like it is gone already in either PRACX or Yitzi patches, or maybe even earlier.

Offline Mart

Re: Movies - new possibilities for modding
« Reply #4 on: June 24, 2015, 10:37:52 PM »
Well, after some time spent on trying compilation of source code destined for linux on windows platform, and figuring out which bash version would digest the config and make on my system, I decided to settle on pre-compiled 32-bit ffplay for windows.
Already tried it, so it works ok.

I plan to make that a part of the Unity Mod v0.5, which hopefully will be soon for testing.

The replacement code for playuv15.exe is really simple:
Code: [Select]
#include <stdio.h>
#include <stdlib.h>
 
main( int argc, char *argv[] )
{
    int c = 0;   
    char String[255];
    sprintf(String, "start ffplay -fs -autoexit %s ", argv[2]);
    chdir(".\\movies");
    int a = 1;
    a = system(String);
    do{;}while(a!=0);
return ;
}
And that's it. Compiled with gcc (freeware c compiler) from command line.
The resulting exe file should be renamed to "playuv15.exe" unless this name is given as output name when we compile in command line.
What is does is taking the command passed to original playuv and forwarding it to ffplay.exe
argv[1] is "-software", so it is dropped.
argv[2] is file name to play.
Instead, -fs (fullscreen), and -autoexit (player quits and we get back to smax screen) are given to ffplay.exe

So if some high resolution, nice looking movies are inserted into place of Secret Project movies, or opening movie, etc. we can watch them in very good quality.
=====
Corrected the code. The addition seems to fix the problem (originating in terranx.exe?) that for longer movies, smax was displaying its intro screenie, covering the movie, no video, but sound is on.
playuv15.exe terminating before ffplay completes?
« Last Edit: June 25, 2015, 03:11:12 AM by Mart »

Offline Mart

Re: Movies - new possibilities for modding
« Reply #5 on: June 28, 2015, 01:58:11 PM »
Some more findings.

The simple "redirecting" application does not work 100% satisfactory. And I am not sure, what is causing this. I have to take a look into PRACX functionality, so also check, how that would work with exe before PRACX patching. Problems so far:
- Sometimes ffplay starts in fullscreen ok, sometimes it does not. And it seems also to scale its window according to some unknown to me yet factors.
- It looks like after some 2 minutes? terranx.exe takes over display, showing the intro screen, you can hear sound though, in some cases. The original playuv15.exe seems to prevent this, but possibly only when it plays a video. I launched it as suspended process, and it did not help the problem. Or, maybe, it needs to be suspended after some time, when it already has done some actions?
- And I wonder, how much of that would be an issue of using 32-bit application on 64-bit system. The 32-bit one will have to be "the base." I compile to 32-bit, while having 64-bit OS.

I tried to find out more about encoders for wve format. So this is actually, what they call Electronic Arts TQI. For sound there is some PCM codec.
And while ffmpeg has a lot of codecs, decoders, encoders, for this range of them (EA stuff) there is decoding, but no encoding. Probably we are not going to see these encoders anytime soon. They are not to be used by public, it seems.

The original playuv15.exe says, it is uV, uV2, TGV, ASF. The TGV is like that TQI, that reports from wve in SMACX. I wonder, if there are possibly some public-available codecs, that original playuv15.exe could show from that era, 1997, and used in AVI files. And maybe ASF would work.
But having possibility to play more and newer movies encoded with recent codecs, like in mp4 format, would be better. ffplay provides during-play functionality from keyboard, like pause, move a single frame forward, switch fullscreen on/off. But it is not a good solution to need hit keybord some few times each time a smacx movie plays.
It will most likely turn out, that "redirecting" will be a bit more complex code.

Offline Buster's Uncle

  • With community service, I
  • Ascend
  • *
  • Posts: 49401
  • €73
  • View Inventory
  • Send /Gift
  • Because there are times when people just need a cute puppy  Soft kitty, warm kitty, little ball of fur  A WONDERFUL concept, Unity - & a 1-way trip that cost 400 trillion & 40 yrs.  
  • AC2 is my instrument, my heart, as I play my song.
  • Planet tales writer Smilie Artist Custom Faction Modder AC2 Wiki contributor Downloads Contributor
    • View Profile
    • My Custom Factions
    • Awards
Re: Movies - new possibilities for modding
« Reply #6 on: June 28, 2015, 02:00:58 PM »
Hmmm.  I recall years ago talking about how handy it would be for scenarios to be able to put in our own movies.  VERY handy, given a movie relevant.

Good research. ;b;

Offline Mart

Re: Movies - new possibilities for modding
« Reply #7 on: June 28, 2015, 04:54:34 PM »
Yes, we can already put our own movies in mods, and with that idea of writing your own executable, that passes movie file name to another player, ffplay being here only one of many possibilities, we can replace any movie file. For some movies, we probably have no good control, when they are played and how they are named, but there is this file:
movlist.txt
where we can rearrange/add SP movies (even rename). I haven't checked that yet, but possibly we can have 64 SP movies.

Offline Buster's Uncle

  • With community service, I
  • Ascend
  • *
  • Posts: 49401
  • €73
  • View Inventory
  • Send /Gift
  • Because there are times when people just need a cute puppy  Soft kitty, warm kitty, little ball of fur  A WONDERFUL concept, Unity - & a 1-way trip that cost 400 trillion & 40 yrs.  
  • AC2 is my instrument, my heart, as I play my song.
  • Planet tales writer Smilie Artist Custom Faction Modder AC2 Wiki contributor Downloads Contributor
    • View Profile
    • My Custom Factions
    • Awards
Re: Movies - new possibilities for modding
« Reply #8 on: June 28, 2015, 06:30:00 PM »
I linked a movie in the GotM folder at WPC long ago - it's dirty, but the first few minutes are cool CGI ships flying and docking.  That part could be useful, and not hard to toss the rest w/ Windows Movie Maker or something.

Offline Mart

Re: Movies - new possibilities for modding
« Reply #9 on: June 30, 2015, 01:33:37 AM »
We may have a kinda Hollywood on this forum soon.
Movie maker from Microsoft does not have many options for pan, transitions, animations, etc.
I found some other programs that can help:
- VirtualDub
- Avisynth
but I need to use them to find out more what they can do.

One problem solved, the movie now can play more than 2 minutes.
Done with c++, about 150 lines of code...
So the trick is to suspend terranx.exe for the time of playing the video and resume after.

Offline Buster's Uncle

  • With community service, I
  • Ascend
  • *
  • Posts: 49401
  • €73
  • View Inventory
  • Send /Gift
  • Because there are times when people just need a cute puppy  Soft kitty, warm kitty, little ball of fur  A WONDERFUL concept, Unity - & a 1-way trip that cost 400 trillion & 40 yrs.  
  • AC2 is my instrument, my heart, as I play my song.
  • Planet tales writer Smilie Artist Custom Faction Modder AC2 Wiki contributor Downloads Contributor
    • View Profile
    • My Custom Factions
    • Awards
Re: Movies - new possibilities for modding
« Reply #10 on: June 30, 2015, 01:46:52 AM »
...My sister is a Poser artist and quite adept with the video creation/editing, so a 30 seconds from scratch might be doable, if not too complex...

Offline Mart

Re: Movies - new possibilities for modding
« Reply #11 on: July 06, 2015, 12:32:20 PM »
Update, but no big improvement.
At present, what is possible, is to have intro movie showing ok, and this is due to the game window having status: SW_SHOWNORMAL (int value 1) at this time. The problem of game screen taking over after 2 minutes (around, I am not sure how specific it is to OS settings on someone's computer) can be overcome by suspending terranx.exe process for that time. It all can be done with Win32 API.
Problem is still with other movies, like during SP completion, as I found, game window has status SW_SHOWMAXIMIZED (int value 3). Generally windows at that time are covered by terranx fullscreen. Although pushing 'f' few times can bring fullscreen ffplay to the front. How many times to push 'f'? This seems to be windows thing - just it depends on something, no idea what. It is known, that there is so-called "fight" over showing windows on top of other windows. Like you have advertisements screenies popping out into your face while doing something on your computer. People, comp users, really do not like that, so there is some ongoing development to control when and how windows can pop out on top of other windows. Not really easy stuff to overcome.

There are though ways, e.g. D3D hook. Not a perfect solution.
I try also to automatically change smacx window placement, but it looks like not an easy thing to do. C++ used functions like showwindow or setwindowplacement do not work.
And all this may be OS version specific, like versions of windows have different level of control over these permissions to change other windows' parameters. Or maybe this is more to the directx version.

So when someone runs a game in windowed mode, there is no problem, you can watch ffplay ok, it is not covered by smacx game. But I think many people play fullscreen.

Offline Mart

Re: Movies - new possibilities for modding
« Reply #12 on: July 10, 2015, 01:36:14 PM »
Ok, so it seems I have a solution. For windows OS. Short explanation.
If we start terranx.exe in a regular way, some other application that we place in our game folder for purpose of playing movies, will not have sufficient rights to work around how the window of terranx.exe is displayed. How it is done in original playuv15.exe, I do not know. My attempts to force terranx.exe window to a particular state from such replaced playuv15.exe faild.
The solution, that I found is to use a launcher application, simple exe, that will launch terranx.exe and then "observe" if the playuv15.exe is launched by the game. If so, it fires the appropriate movie file.
The thing is, it seems like this launcher exe now can force smax main window to properly minimize and allow ffplay window to display on top.

I went further with testing release, now there will be "movies2" folder. Any new movie in this folder with matching body name (extensions .wve or .mp4 do not matter) will replace the original one.

I have downloaded the demo zip (renamed to .z) and it awaits approval.
In next posts:
- how to install and run the demo, uninstal.
- save file for testing.
- source code for those who prefer to compile executables themselves.

Offline Mart

Re: Movies - new possibilities for modding
« Reply #13 on: July 10, 2015, 02:22:58 PM »
Installing smax-movie-demo

First, you may want to backup your playuv15.exe file from "movies" folder, although the rescue file (copy of it) is provided in the zip.
Most likely, the file you have (downloaded), has name ending with .z
Rename it to .zip
Unpack the content "keeping folders tree" into your game folder
- file: terx_movie.exe should be in the same folder as your terranx.exe, that you play smax with.

There will be one file replacement needed: playuv15.exe, make the replacement.
- there is provided PP version: playuv15.exe.original in case you did not make a backup.

Important:

Start the game clicking the terx_movie.exe, otherwise you will not be able to watch any movies in the game.

Additional:
- After a movie, in this demo/test, for now, use mouse to click appropriate buttons rather than enter from keyboard. It works better this way.
New version will have appropriately set activate window function.

Uninstalling smax-movie-demo

You can remove completely:
- folder "TERX_movie"
- folder "movies2", thogh you may want to keep your alternative movies.
- terx_movie.exe file from main game folder.
- As for folder "movies" you can delete files:
-- playuv15.exe
-- ffplay.exe
-- ffplay-LICENSE.txt

At this point you either:
- place your buckup playuv15.exe to restore functionality from before demo
- rename 'playuv15.exe.original' to 'playuv15.exe'

If you choose the first option, you can delete the ' .original' file.

How to add replacement movies to the game


1) Make a movie and save it in some format readable for ffplay. They have broad range of codecs, so mp4 or avi would work ok. The original wve format can also be played by ffplay!
2) Name this new movie with the same file body name, as the one you want to replace. The extension does not matter, so for example:
making file 'openingx.mp4' will replace 'openingx.wve' during game.
3) Place this new movie in "movies2" folder.
You do not need to move or delete or replace the file in "movies" folder. You can keep the original movies there.

In case you want return to original movie, either:
- delete new file from "movies2"
- change the name of the file in "movies2" so the name bodies do not match, e.g.:
'openingx.mp4' to 'openingx_1.mp4'

Notes:

- Folder "TERX_movie" is crucial for functioning of the system, so it should be there, and:
- Folder "TERX_movie"should be possible to be written into, the playuv15.exe writes movie name to a txt file there. So do not set "read-only" flag for it.
- Inside this folder, "TERX_movie" is the file "ffplay_options.txt", also crucial to the system functioning well. It contains flags for ffplay.
It is recommended to keep -autoexit for automatic movie end. Otherwise, you will need to close ffplay window manually each time.
You can try other options for ffplay, e.g. resizing or full screen, etc.
- when playing movies, you have access to functions of ffplay from keyboard, such as:
"s" step one movie frame, it also makes a "pause"
"f" toggle fullscreen
"p" pause
etc. check ffplay documentation for more.
« Last Edit: July 10, 2015, 06:23:25 PM by Mart »

Offline Mart

Re: Movies - new possibilities for modding
« Reply #14 on: July 10, 2015, 02:34:04 PM »
A short test, that you can quickly check.

The demo zip contains two replacement movies:
- openingx.mp4, so in order to watch it, you should have it "not disabled" in the ini file.
- weatherParadigm.mp4

Attached to this post is save file, for Gaians, that their two bases are completing two SPs next turn:
- Weather Paradigm
- Merchant exchange

So only by pushing "end turn" you can check if both movies play properly, one is replaced, the other is not. Merchant exchange will have in its window .wve name.

How does that work for you?
« Last Edit: July 10, 2015, 03:14:02 PM by Mart »

 

* User

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

* Community poll

SMAC v.4 SMAX v.2 (or previous versions)
-=-
24 (7%)
XP Compatibility patch
-=-
9 (2%)
Gog version for Windows
-=-
103 (32%)
Scient (unofficial) patch
-=-
40 (12%)
Kyrub's latest patch
-=-
14 (4%)
Yitzi's latest patch
-=-
89 (28%)
AC for Mac
-=-
3 (0%)
AC for Linux
-=-
6 (1%)
Gog version for Mac
-=-
10 (3%)
No patch
-=-
16 (5%)
Total Members Voted: 314
AC2 Wiki Logo
-click pic for wik-

* Random quote

The prevalence of anoxic environments rich in organic material, combined with the presence of nitrated compounds has led to an astonishing variety of underground organisms which live in the absence of oxygen and 'breathe' nitrate. Likewise, the scarcity of carbon in the environment has forced plants to economize on its use. Thus, all our efforts to return carbon to the biosphere will encourage the native life to proliferate. Conversely, the huge quantities of nitrate in the soil will be heaven to human farmers.
~Lady Deirdre Skye 'The Early Years'

* Select your theme

*
Templates: 5: index (default), PortaMx/Mainindex (default), PortaMx/Frames (default), Display (default), GenericControls (default).
Sub templates: 8: init, html_above, body_above, portamx_above, main, portamx_below, body_below, html_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 45 - 1228KB. (show)
Queries used: 35.

[Show Queries]