OpenXcom Forum

Modding => Work In Progress => Topic started by: rbuck000 on January 18, 2020, 03:18:19 am

Title: I have found a way to make new cutscenes!
Post by: rbuck000 on January 18, 2020, 03:18:19 am
there is a app i have i can now use to make cut scenes any ideas?
Title: Re: I have found a way to make new cutscenes!
Post by: Solarius Scorch on January 18, 2020, 05:17:12 pm
What kind of an app? Does it save as .fli?
Title: Re: I have found a way to make new cutscenes!
Post by: rbuck000 on January 24, 2020, 07:21:25 am
I do believe so, atm I'm working with flc and got one to load. I gotta figure out how to make the fps match up the images
Title: Re: I have found a way to make new cutscenes!
Post by: Solarius Scorch on January 24, 2020, 03:25:45 pm
Very interesting. It would be nice to have an option to use animation instead of still pictures, though I have no idea if anyone would be determined enough to actually make animations.
Best of luck!
Title: Re: I have found a way to make new cutscenes!
Post by: rbuck000 on January 29, 2020, 03:50:58 am
So far so good I was able to use 3d studio max to make a test scene I'm working on frame rate and using clips of into to make more mini clips doe mods
Title: Re: I have found a way to make new cutscenes!
Post by: rbuck000 on January 29, 2020, 05:37:29 am
I'll try to upload demos and samples when I next get wifi
Title: Re: I have found a way to make new cutscenes!
Post by: Solarius Scorch on January 29, 2020, 01:06:31 pm
Cool, please do!
Title: Re: I have found a way to make new cutscenes!
Post by: gaffer on February 01, 2020, 05:12:24 am
Looking forward to it!
Title: Re: I have found a way to make new cutscenes!
Post by: rbuck000 on February 09, 2020, 02:41:24 am
Atm i do not have the yaml or the meta data or rule set made.
so easiest way to test is dl the psx video mod and replace the one you want to try with the intro or abort mission with the file from my pack and use the same name as the prior psx video mods name.

some are very short as in only seconds and some hve fps / frame rate issues but they all should work
Title: Re: I have found a way to make new cutscenes!
Post by: rbuck000 on February 09, 2020, 05:39:11 am
let me know of this works for you
Title: Re: I have found a way to make new cutscenes!
Post by: rbuck000 on February 09, 2020, 08:21:19 pm
working on these ( there just avi atm)
Title: Re: I have found a way to make new cutscenes!
Post by: rbuck000 on February 21, 2020, 03:10:52 am
Is there a way to recover the color pallet for the in game videos so that I can make more accurate cgi scenes. Like a sectoid containment break, mid game xnunber of turns  turn the dead civilian to new enemies or a mid game alien reinforcements
Title: Re: I have found a way to make new cutscenes!
Post by: memmaker on March 02, 2020, 05:49:19 pm
Have been looking into this and found the following:

Quote
There are two "official" types of FLIC files: FLI and FLC (the names of these types refer to the filename extensions). The FLI files are the older format and are limited to a resolution of 320×200. The FLC file format adds configurable resolution and better compression.
(Source: https://www.compuphase.com/flic.htm)

The original intro file is a .FLI, as evidenced by both the file extension and the magic byte marker at offset 0x04. The original also uses a delay between video ticks of 5 (value at offset 0x10 in the .FLI).

At this point, many thanks to sylandro and his post here: https://openxcom.org/forum/index.php/topic,3234.msg84987.html#msg84987.

That made my tinkering a lot easier. Although, I am not really sure why he suggests to set the delay to 1 and force the file type via hex-editing. My research seems to discourage that approach in favor of a toolset that encodes the correct filetype to begin with. While looking at the OXCE source code, I noticed that the FLIC player being used supports both the older FLI and the newer FLC types for playback, so we are not restricted to FLI files here. In fact, the only difference in the source code between the two file formats is how the delay between two frames is calculated.

The hard part seems to be to get the framerate of the video right. Especially since my testing indicates, that, for example, the VLC player will play FLIC files at a different frame-rate than the OXCE in-game FLIC Player.

The game will handle FLC and FLI files differently regarding to frame-rate (as the standard demands).

The default delay between frames for FLI files is
Code: [Select]
SPEED_FROM_FILE_HEADER * (1000.0/70.0)

So a speed value of 5 in the file header (as used by the original intro) would result in a delay of ~ 71,4 ticks, where one tick is one millisecond. Since there are 1000 ticks in a second this means the video plays at a frame-rate of about 14 fps. When starting out...
Stepping through the code I noticed the following behaviour with the built-in audio and intro sequence of the UK version: The frame-rate gets changed while the cutscene is playing. It goes like this, it starts out with a header speed of 5 and about 14 fps and then changes the header speed to 7 thereby reducing the frame-rate to 10 fps. The command for changing the video playback speed seems to be embedded into the intro soundtrack audio data. There are more command embedded: resetting the framerate to 14 fps for a small rendered animation of the space ship and then going to back to 10 fps.
At one point the speed even gets set to 1 resulting in 70 fps (for a few frames?!) going back to speed 6 and about 11 fps shortly after that. The Mutons teleporting out of the way is played with a speed of 10 and 7 fps and so on. Basically the animation speed is controlled by commands embedded in the audio track, which constantly changes speed to emphasize some frames or smooth the animation of others.

This also explains the hex editing of sylandros post: He sets to the speed in the file header to 1, resulting in a delay of 1000 / 70 = 14 (unsigned int) and calculated frame-rate of 70 fps. Which is the frame-rate he exported the original video file at. His file has 3300 video frames compared to the 810 frames which are really there and different to each other.

While the default delay between frames for FLC files is

Code: [Select]
1000 / (AUDIO_DATA_SAMPLERATE / AUDIO_FRAME_SIZE)

Sample Rate: 44.1 khz -> 44100 Samples per Second
Audio Frame Size: Sample Size (in Bytes) * Channels -> 32-Bit Stereo => 4 * 2 = 8 bytes

Which seems to be defined by the audio data. A bit odd to me, but maybe there are good reasons for this. However this of course has the consequence, that a FLC file will depend on the audio sample rate for its playback speed. This definitely explains some strange results I've been seeing. It also seems to contradict the FLC file specs, which state, that a FLC file's speed value represents the delay between two frames in milliseconds.

I have been using the following toolchain to successfully re-encode the cutscenes from a PSX ISO file for OpenXcom. The same approach can be used to encode any video or picture stream into cutscenes.

FLIC animations as used by OpenXcom use a 8-bit color depth with an indexed colormap (a color palette). One palette is used for the whole animation, which is the reason ppm2fli will use a remapping algorithm to make sure all the colors used in all the pictures can be mapped to one color palette. You can ensure that no changes happen to your files by preparing the images so they already use an optimized shared palette.

ppm2fli - Takes a series of .PPM picture files and encodes them into a .FLI or .FLC video file
unflick - Reverses the process and converts a .FLC or .FLI file into a series of .PPM picture files (I used this successfully on the original intro file)
http://vento.pi.tu-berlin.de/STROEMUNGSAKUSTIK/SOFTWARE/ppm2fli/main.html

A graphics tool-suite which includes pnmremap
pnmremap - Uses an dithering like algorithm (Floyd Steinberg) in order to enhance image quality on gradients, I have used this as an alternative color mapping algorithm for better quality of the output.
http://netpbm.sourceforge.net/

mogrify is part of imagemagick and allows the conversion of BMP files to PPM files
https://imagemagick.org/script/mogrify.php

gegl - Graphics manipulation toolkit written for GIMP
http://gegl.org/

PSX Decode - Used for getting the video files from a PSX ISO
https://github.com/m35/jpsxdec

From AVI to OXC FLIC File

Code: [Select]
# extract frames from AVI, changing frame-rate on export (use for example 17.5 fps for FLI)
ffmpeg -i input.avi -filter:v fps=fps=25 frame%04d.bmp

# optional: resize the frames:
for filename in *.bmp; do basename="${filename%.*}"; convert "$basename.bmp" -resize 320x200 small_${basename}.bmp; done

# convert BMPs to PPMs
for filename in *.bmp; do basename="${filename%.*}"; mogrify -format ppm "$basename.bmp"; done

# optional / alternative, use gegl for noise reduction or other cleanup during conversion
for filename in *.bmp; do basename="${filename%.*}"; gegl "$basename.bmp" -- noise-reduction iterations=2 ppm-save path="./$basename.ppm" bitdepth=8; done

# make a list of ppm files
ls -1 *.ppm > pics.list

# FLI: generate the FLIC animation, speed set to 4 for 17.5 fps in the FLI formt
ppm2fli -O -s 4 pics.list output.fli

# FLC: generate the FLIC animation, speed set to 40 for 25 fps in the FLC formt
ppm2fli -g 320x200 -s 40 pics.list output.flc

# Optional step for better quantization (use the output of this command for the list which ppm2fli uses instead)
for filename in "$i"*.ppm; do pnmremap -mapfile="table-$i.ppm" -fs "$filename" > "./requant/$filename"; done

Because of the limitations of the FLIC format, there are only a bunch of frame-rates which can be used without getting into floating point problems:

The FLI format can use these whole-number FPS values:
70fps at speed 1
35fps at speed 2
17,5fps at speed 4
14fps at speed 5
10 fps at speed 7
7 fps at speed 10
5 fps at speed 14

While the FLC format has a whole-number FPS for these speed values:
1000fps at speed 1
500fps at speed 2
50fps at speed 20
40fps at speed 25
25fps at speed 40
20fps at speed 50

In this example I used 25 fps and the FLC file format, since the FLI file format does not allow for this frame-rate. Unfortunately, the current Version of OXC is not standard compliant with regards to the FLC standard. This has to do with the suppport of the non-standard TFTD video files. I have already proposed a fix in form of a PR and hope for its inclusion in the upcoming OXC versions.

@rbuck000
The tools ppm2fli and unflick which I have been using both allow for the extraction of the color palette of the original video files. However, as far as I understand, the palette in the video files are completely indepedent of the rest of the game. So you should be able to just choose an optimal palette for your video content.
Title: Re: I have found a way to make new cutscenes!
Post by: rbuck000 on March 03, 2020, 09:10:55 pm
Nice ! So once I get the pallet I'll plan on finishing a few scenes I have going ufo detection I plan on making multiple and finding a way to displaying on screen  as a sort of overlay with using the bottom right of the geo scape empty square. To show the events the use default message such as the flashing alert on bottom right followed by a ufo flying over a small town or following a passenger  airplane.view from  out the window of the airplane.

First I wanna finish I'm trying to find a way to make sections head and body rigged in 3d max for simple things like the ps1 lose game execution kinda simple. I plan on making a few scenes kinda like that and wanna do the whole races inside the alien containment unit since if you look it has all those cameras. I'd really like to do a sort of modern version of the research findings for oxce like in the more current xcom does

Also all I need to do is import the pictures or what I do is export an avid from 3d max then convert it to flic.
Title: Re: I have found a way to make new cutscenes!
Post by: memmaker on March 15, 2020, 08:20:40 pm
Just for completeness:

Although I managed to get OXC to play 640x360 FLC files I couldn't get the FLC player built into the game to sync up a video to a audio stream at these resolutions. My guess would be that the player is not fast enough? The video seems to always be a bit slower than it should be.

So I present the optimal way to encode videos for OXC in form of this script. Save it into a file called oxcvideo and use it like this:

BASH Script oxcvideo
Code: [Select]
#!/bin/bash

INPUTVIDEO="../${1}"
NAME="${1%.*}"
TEMPDIR="${NAME}_TEMP"

mkdir ${TEMPDIR}
cd ${TEMPDIR}

shift

ffmpeg -i ${INPUTVIDEO} -vf "scale=w=320:h=200:force_original_aspect_ratio=decrease:flags=lanczos, fps=fps=17.5" $@ frame%04d.bmp

for filename in frame*.bmp; do basename="${filename%.*}"; mogrify -format ppm "$basename.bmp"; done

rm frame*.bmp

ls -1 frame*.ppm > pics.list

ppm2fli -w table.ppm pics.list

for filename in frame*.ppm; do pnmremap -mapfile="table.ppm" -fs "$filename" > "requant_$filename"; done

rm frame*.ppm
rm pics.list

ls -1 requant_frame*.ppm > pics.list

ppm2fli -O -s 4 -m table.ppm pics.list output.fli

rm table.ppm
rm pics.list
rm requant*.ppm

ffmpeg -i ${INPUTVIDEO} -b:a 128000 -vn -acodec libvorbis -y $@ audio.ogg

mv output.fli ../${NAME}.FLI
mv audio.ogg ../${NAME}.OGG

cd ..

rm -r ${TEMPDIR}

Usage

Code: [Select]
oxcvideo VIDEO_FILENAME.AVI

It will accept all video formats that FFMPEG can read, which are many.

The output will be VIDEO_FILENAME.FLI and VIDEO_FILENAME.OGG ready for insertion in a mod.

Of course you would need most of the tools I mentioned in the previous post installed and available in your path.

Have fun.
Title: Re: I have found a way to make new cutscenes!
Post by: DrakenJ35 on March 31, 2020, 08:05:21 pm
That sounds great man, I'll try and see if I can come up with something that looks good as well! Right now, I'm stuck with a massive insurance estimation for some real estate in Cannes (https://tranio.com/france/provence-alpes-cote_d_azur/cannes/), but by Saturday, I should be done with it and will have time for ambitious projects at home.
Title: Re: I have found a way to make new cutscenes!
Post by: Nino_the_Younger on August 04, 2020, 03:40:20 am
Better Ending for TFTD, maybe show Cthulhu wake up before he dies. Any kind of resolution would be nice, hopefully blending the xcom and lovecraftian themes already developed in the rest of the game. I'm sure whatever you end up making will be great and I look forward to seeing it.
Title: Re: I have found a way to make new cutscenes!
Post by: rbuck000 on August 12, 2020, 06:58:46 pm
So atm I'm waiting to hear back if they can make event hooks to start videos such as prior to ufo detected a alert video we'll play in a mini window or as a overlay inside of a window similar to the air to air combat window.

So I have some  rough drafts made for events such as: ufo over city, fly by air to air contact , ufo attacks jet, jet from nato makes visual contact with  ufo in air , half done with ufo approaching  mountain base.  And mountain base hidden hanger hatch opening up and launching  I'm not sure what I wanna use as the intercepter or the skyranger models.

I'm useing the custom made ufo that look like the ones in the PlayStation lose game scene I'm trying to find new tricks and learn  how make more of like a Shakey cam as the jets and or intercepter sliders down in from top left to center screen and shake the camera with jet exhaust and cloud passes.

But as I said still trying to figure out how to trigger videos  and  figure out best way to process the audio sync in max timing
Title: Re: I have found a way to make new cutscenes!
Post by: _Raven_ on November 28, 2023, 11:23:28 pm
I want to draw your attention to one unpleasant problem in the cutscenes.rul file.

The fact is that these heavy flc and fli files weigh so much that the game cannot fully load them in a second, resulting in the ogg audio track loading in a second and starting to work, while the flc or fli file continues to load for several more seconds and as a result, the video lags behind the sound by 3-5 seconds (especially on weak devices, especially on Android). We need you and other developers to do something about this lag between video and sound in high-quality fli and flc cutscenes.

We need to fix this by writing a special animation playback algorithm, that is, the game needs to either first load the flc file and then the ogg file and only after that the cutscene starts playing, or the second option, the ogg file is loaded first because it is lightweight and weighs little, then a special algorithm must pause the ogg file and not allow it to play until the flc file is completely loaded, and after this algorithm sees that both cutscene files are fully loaded and ready to play, then the algorithm simultaneously removes the lock from both files and the cutscene starts.

It is impossible for both ogg and flc files to load at the same time, a large flc file does not have time to load as quickly as a small ogg file and as a result we see a lag between the video and the sound for several seconds, this is very unpleasant to watch, that’s why I divide my cutscenes into small pieces lasting no more than 30 seconds, and gluing and loading every 30 seconds or even 10 seconds is very unpleasant, but when the video lags behind the sound by 5 seconds it is even more unpleasant.

I also wanted to add that flc and fli files are very heavy (1 second 1MB, 1 minute video 60MB), it’s bad that you don’t have a programmer who would develop various useful programs for OXCE (for example, a program for converting mp4 to flc like Video_Mach_Pro_Portable or an existing program improve and create some kind of flc file encryption codec that would be able to compress files several times and make them several times smaller and easier for the game to read these files.

Please do something with the cutscenes.rul file and prevent ogg or wav files from launching before flc or fli files.

I am made such high-quality cutscenes with high fps and excellent quality, but they are very heavy, take up a lot of space and take a very long time to load when the cutscene starts, and also, as luck would have it, the sound starts playing 5 seconds before the video loads.