• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • Eevee Expo's webhost has been having technical issues since Nov. 20th and you might be unable to connect to our site. Staff are also facing issues connecting, so please send a DM to Cat on-site or through Discord directly for faster service!
Resource icon

v19 How to insert video/cinematics in Pokemon Essentials 1

This resource pertains to version 19 of Pokémon Essentials.
HOW TO INSERT VIDEOS/CINEMATICS IN POKEMON ESSENTIALS

English isn't my first language so apologies for any mistake

In this tutorial, I'll explain how to "play" videos in Pokemon Essentials. (Tested in v16.2 - But I think it works in other versions)

Not so long ago, I found the "Scene_Movie" script, that allowed you to play videos, but I couldn't manage to make it work. Later I saw it had been removed in newer versions, so I suppose it was unusable.
So I decided to do one by myself. It's about showing on the screen, frame by frame, the images from the video, and playing the audio at the same time, but on a different channel. What I mean is the audio and the video need to be separated. This brings some problems, because the computer needs time to do operations, and this time isn't always the same even for the same operation. So the video and the audio could be out of sync. I solved that with a script

It has some disadvantages, as the weight of your "Picture" folder may increase. Also, if you tried to play too long videos, the computer will get slower. I made an example of a 6:20 minutes video that works perfectly fine. Although you could play any videos, I recommend using this script for small cinematics. It could be the badge animation of black and white; a little animation entering in a determined map; the apparition of a legendary; even a true intro... (but I think this last one would need some changes to work properly)

The video I was talking about. Apologies, I'm Spanish, so the video is in my language. But the important thing here is that you can see it works perfectly fine. All shown here are ingame scenes:


I'll divide the tutorial into 3 parts: how to prepare the frames; how to create the event; and a little explanation of the script used here.

PREPARING THE FRAMES

This could be either very simple or very tedious. Three important things: duration and dimensions of the video, and the amount of frames

DIMENSIONS: 512x384. That's the screen dimension. So if you don't want to see just a quarter of your video, you'll need to redimension each frame. The easiest way is to redimension the video. You could also change the zoom of each image in the event (I'll explain later that), but I prefer this way.


DURATION: This is very important. Remember, video and audio aren't on the same channel. Essentials need a pause between frames to show them. The smallest pause Essentials allows you is 1/20 sec. That means, we need 20 frames per second (20 fps). Problem is, if you record a video at 20 fps, most of the time when you try to extract the frames, you'll receive more than 20 frames per second. So you will have more frames than seconds your audio lasts.

AMOUNT OF FRAMES: As I said, 20 frames= 1 second. When you extract the frames, you'll have to delete lots of them. Point is, you need the same amount of frame your audio lasts. Don't worry about deleting some frames, the human eye can't distinguish images at 12fps.

Example: I have a video with a duration of 38 seconds, and when I extract all the frames, I found it has 952 frames. With 38 seconds, that means that I have 760 frames (38s * 20 frames/second = 760), so I don't need 192 frames (952-760 = 192), and I have to delete them. The best way is to delete them proportionally. If you don't do that, you could find huge jumps between scenes and the video wouldn't be smooth. So the best thing is to distribute them, (952/192= 4,958....). That means I have to delete 1 frame of each 5 I find.
I think that's the hardest part of the tutorial. Not because of its difficulty, but because of how tedious it is. I needed to do some programs in Language C (a programming language) to help me with this. However, if your video is short, you shouldn't have problems with it. And if your video is quite big, then you could always send me a message and I'll help you with that if you ask me.

So once you have all the frames, the last part is to rename them. Programs that extract frames usually add the number in order next to the previous name of your video (if you had a video named "R", it will appear "R-1",R-2".... or similar). But when you reduce frames, you will find gaps between numbers (as for example, the picture "R-3" is missing. So you need to rename them. If you're in Windows, just select all (CTRL + E) and click on "change name". Choose the name you want and all the files will be renamed, with the new number between parenthesis. That's what we're looking for, and that's the way this tutorial is made.

Then, just is left to extract the audio from the video (any editing program do that). If I remember correctly, Essentials support mp3, wav and ogg files.

Don't forget to put everything in its corresponding folder. The frames inside \\Graphics\\Pictures (inside this one you could create a new one if you wish). And the audio, inside any subfolder you find in the Audio folder. I put it in SE, but it works in every folder. If you don't save it in the SE folder, make sure you modify any SE you will use the proper command to call the music.


HOW TO CREATE THE EVENT


We finally start in Essentials. Again apologies for the language. The event is written in Spanish, but I'll translate everything



Tutorial evento.PNG





Needed variables: 107 (control the frames); 108 (time the playback started); 109 (last time we called the script). The number of the variables could be, but they have to be in consonance with the script (3rd part of the tutorial)


This event has two configurations: The short one, where it isn't important if the video gets slower than the audio (even if we cut the frames, the audio will be some steps ahead). Could be mute videos. If that's the case, you could skip the next 3 paragraphs and the script, because you will not need it. You must erase everything that contains "Time.now" and end with something like this:



reducido.png



-But if you want to correct the mismatch:

1.PNG


We start putting the variables in order. Var 108 will have the time the sound started. At this time, the var 109 will do the same, but just to avoid bugs. Just then, play the sound (SE in my case)

ciclo pequeño.PNG


When the cinematic is short, video and audio aren't mismatched or at least is hard to notice. However, I think is good to use this always. It allows us to autorefresh the frame we are showing on the screen. If the computer gets slower, or if we click outside the window (the image will freeze then), this event helps to return to the correct frame, calling to the función "Autorregulador" self-regulating

So our code will enter in that conditional if the difference between the current time and the time we last called our function is >=5 secs. This parameter is random. I choose 5 seconds because is a number that works right for me. The lower it is, the faster it will autorefresh the frame.
How the var 109 knows the time we last called the function? It is set inside the script (3rd part).

If it could enter inside the conditional, we call the function and now var 107 will have the correct frame.

-Same for everyone:

script.png


Next thing is to call the picture, to wait the correct time, and to delete it. I have it as Picture "12" for nothing special. What it's important is that you use the same number to call the picture and to delete it.

In order to make it easier to call the picture with a script, I had to change a couple of things inside the script editor. You go to "Game_Picture" and change "attr_reader :name" to "attr_accessor :name"

23.png


Then:

name = '\\Videos\\BT\\AvsP\\IvsE (' +
pbGet(107).to_s+')'

$game_screen.pictures[12].show(name, 0,
0, 0, 100, 100, 255, 0)

name will contain the route and the name of the file (frame). In my case, I have them stored in a folder called AvsP, inside other folder which is BT, inside Videos, that it's inside Pictures. You could just store them inside Pictures and write name= 'name_file_without_extension (' + pbGet(107).to_s+')'
Really important the use of single quotes

What is between ' ' is the file name. The loop will have a new name each time (var 107 will have a new number each time). To anyone who knows about programming, "name" is a string, and the variable is an integer, so we need to use .to_s. The "+" are just to add more letters to the string.

My file is called IvsE (1). The parenthesis appears when we prepare the frames, as I said before.
If you just have the file IvsE1 , it should be, assuming the route is the same:

name = '\\Videos\\BT\\AvsP\\IvsE ' + pbGet(107).to_s

Is important to note where we add the single quotes. Between mi "e" and my "(", there's a space, so you have to leave a space in the script too.

Now, $game_screen.pictures[12].show(name, 0, 0, 0, 100, 100, 255, 0) . Its the transcription to script of "show image" in Essentials.

Between brackets, the number of the image (NOT THE FRAME). As I said, this number is random, just have to be the same as in "Delete Image". If you don't do that, the picture will not be deleted and you will fail.

Name is left untouched, "name", in lowercase letters. That will be replaced automatically with the file name and its route when we call the event

The first 0 means where you want to show the picture. 0 means "up-left" , 1 (in the center). I think 0 is best, but it's up to you.

Second and third 0 are "x" and "y", respectively.
Both 100 are x zoom and y zoom, (width and height), in %. Default is 100. If you want a smaller image, put a number <100. If you want a bigger one, the opposite, >100. In my case, I resized the frames before, so I don't have to redimension them here. But if you didn't, you have to do it now.

255 is the opacity.

And the last one is the pallet. Left it always as 0.

After the script, we wait one frame. This is necessary. Essentials is quite fast, so if you skip this pause, you will see nothing.

Finally, delete the image.

ersgr.png


To end this part, the conditional that allows us to stop the loop once we had ended with the frames. In my case, there are 7618 frames, but you have to change it to adapt it to yours. If we enter here, the loop is broken and we end the event.


After the conditional, add +1 to the var 107 (frames), so the next frame will be shown. And we end the big loop.
That's the way it's possible to show thousands of images without putting a "show image" command for each one.


USED SCRIPT AND ITS EXPLANATION

First of all, I must say I know how to program in C, but I have never studied OOP, so ruby is huge for me right know some times. It may be an easier way to program this script, a more optimal way. If someone know one, please tell me and I'll update it.

"
def pbAutoregulador()

hora_inicio=$game_variables[108]

hora_actual=Time.now

diferencia=(hora_actual-hora_inicio)*20 #20 frames corresponde a 1 seg

#Redondeo

diferencia_entera= diferencia.to_i

diferencia_entera=diferencia_entera.to_f

if diferencia-diferencia_entera>=0.5
diferencia_entera=diferencia_entera+1
end

$game_variables[107]=diferencia_entera.to_int

$game_variables[109]=Time.now

return $game_variables[107]
end

"
Again, variables are in Spanish. Direct translations are : "hora_inicio"="start_time" ; "hora_actual"="current_time" ;
"diferencia"="difference" ; "20 frames corresponde a 1 seg"="20 frames are 1 sec" ; "Redondeo" = "To round" ;
"diferencia_entera"="integer_diference"

def pbAutoregulador()

start_time=$game_variables[108]

current_time=Time.now

difference=(current_time-start_time)*20 #20 frames are 1 sec

#To round the difference

integer_diference= difference.to_i

integer_difference=integer_different.to_f

if difference-integer_difference>=0.5
integer_difference=integer_difference+1
end

$game_variables[107]=integer_difference.to_int

$game_variables[109]=Time.now

return $game_variables[107]
end



Is a simple script. It searches the difference between the current time and the time the playback started (var 108). Said difference is multiplied by 20, the number of fps, so we have the correct frame we should be.

Problem: Time is a float, and the frame is an integer. I had to search for a way to convert it losing as little information as possible, or the jump between frames will be bigger. That is the better way I found. I still lose some decimals but is not a big deal

Then, we convert it again into an integer and return the var 107 with the correct frame,and at the same time updating the last time the function was called.



And that's all. I leave here the link to the script if anyone wants to download it, although you can copy and paste it from here. As always, copy it above main.
https://www.mediafire.com/file/baoyam4nxzw8wkt/pbAutorregulador.txt/file

Greetings!
Credits
I don´t need credits, just enjoy it and hope it's useful
Author
Pableroski
Views
3,071
First release
Last update

Ratings

0.00 star(s) 0 ratings
Back
Top