Game launching video loading screens
-
Thanks to @cyperghost's scripting help - the process is now super simple.
- edit the runcommand-onstart.sh and add the lines below to it
- create the videoloadingscreens folder
- add MP4 files
Add these lines to the runcommand-onstart.sh script.
# Extract file name from called ROM gname="$(basename "$3")" # build path to file and remove extension from ROM to add mp4 extension # $HOME variable will help users that are not stick to raspberry ;) ifgame="$HOME/RetroPie/videoloadingscreens/${gname%.*}.mp4" ifsystem="$HOME/RetroPie/videoloadingscreens/$1.mp4" default="$HOME/RetroPie/videoloadingscreens/default.mp4" # If condition to check filename with -f switch, f means regular file if [[ -f $ifgame ]]; then omxplayer "$ifgame" > /dev/null 2>&1 elif [[ -f $ifsystem ]]; then omxplayer "$ifsystem" > /dev/null 2>&1 elif [[ -f $default ]]; then omxplayer "$default" > /dev/null 2>&1 fi
There's no longer any need to create a duplicate copy of omxplayer. Just the runcommand-onstart.sh addition and then MP4 files.
(original post)
OLD METHOD - DO NOT USE ANYMORE
USE THE METHOD POSTED ABOVE INSTEADHere's one easy method on how to add MP4 game launching videos to RetroPie.
When a game is launched, the script checks for an MP4 video named exactly as the rom filename. If it finds one, use that. If not, look for a system named MP4 video to use (named the same as the emulator is defined like atari600, atari7800, etc). And finally, if neither of the two above are found, just a default MP4 video file.
Basic steps
- create a copy of OMXPlayer file and edit the new copy and add in some addition text to hide the version number
- edit the runcommand-onstart.sh script to launch the new OMXPlayer with MP4 files
- create new folder and copy over MP4 file(s)
Step One - Create Copy Of OMXPlayer File
While in Emulation Station, press F4 to exit to the command line terminal. You could also perform these steps remotely using PUTTY or something simliar.
Once at the command line, type the following commands and press <enter> after each one.cd /usr/bin sudo cp omxplayer omxplayer_silent
This created a new copy of the OMXPlayer called “omxplayer_slient”.
Launching the nano editor
sudo nano omxplayer_silent
Use the arrow keys to scroll down until you find this line.
LD_LIBRARY_PATH="$OMXPLAYER_LIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" $OMXPLAYER_BIN “$@"
Scroll to the end of the line and type some additional text to make it look like this.
LD_LIBRARY_PATH="$OMXPLAYER_LIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" $OMXPLAYER_BIN "$@" > /dev/null 2>&1
This additional text will hide the onscreen versioning text that OMXPlayer usually displays by default.
To save and exit out of the nano editor, follow these steps.
Press: CTRL-X Press: Y Press: <enter>
This saves the file and exits out of nano.Step Two - Edit The runcommand-onstart.sh Script
Now that the new OMXPlayer script is ready, edit the run command script to show it when launching a game.On the command line, type the following commands and press <enter> after each one:
cd /opt/retropie/configs/all nano runcommand-onstart.sh
This will launch the nano text editor.
Add the following lines :
enablevideolaunch="true" if [[ $enablevideolaunch == "true" ]]; then gname=`echo $3 |cut -f7 -d "/" |sed 's/.\{4\}$//'` ifgame=`ls "/home/pi/RetroPie/videoloadingscreens/${gname}.mp4" |wc -l` ifsystem=`ls /home/pi/RetroPie/videoloadingscreens/$1.mp4 |wc -l` if [[ $ifgame > 0 ]];then omxplayer_silent --blank "/home/pi/RetroPie/videoloadingscreens/${gname}.mp4" elif [[ $ifsystem > 0 ]];then omxplayer_silent --blank /home/pi/RetroPie/videoloadingscreens/$1.mp4 else omxplayer_silent --blank /home/pi/RetroPie/videoloadingscreens/default.mp4 fi fi
To save and exit out of the nano editor, follow these steps.
Press: CTRL-X Press: Y Press: <enter>
This saves the file and exits out of nano.Step Three - Create A New Folder To Store MP4 Files
On the command line, type the following commands and press <enter> after each one:cd /home/pi/RetroPie mkdir videoloadingscreens
This created a new folder called “videoloadingscreens” to put the MP4 files into.
Step Four - Create and copy over MP4 files
Your RetroPie build is now setup to use video launching MP4 files for games/systems/default.All that's left is to copy over MP4 files.
As mentioned, the script flow is as follows.
Let's use an Atari 2600 game named Asteroids (USA).zip as our rom filename.
- script looks for an MP4 file named: Asteroids (USA).mp4
- if not found then look for an MP4 file named: atari2600.mp4
- if not found then play the default MP4 file named: default.mp4
If everything is setup correctly, you should now have videos being used when launching games. I've found that launching videos between 7-10 seconds seems to be a nice time length.
Hope some find this useful.
-
@dmmarti Just for improvement and make the code better maintainable because of less duplicates....
The test conditional is a very powerful command, so you usels
and pipe it towc
command to write a variable hit.Better use direct file test. the
[[ -f $file ]]
expression checks if file is a regular file
So you just type.# Extract file name from called ROM gname="$(basename "$3")" # build path to file and remove extension from ROM to add mp4 extension # $HOME variable will help users that are not stick to raspberry ;) ifgame="$HOME/RetroPie/videoloadingscreens/${gname%.*}.mp4" ifsystem="$HOME/RetroPie/videoloadingscreens/$1.mp4" default="$HOME/RetroPie/videoloadingscreens/default.mp4" # If condition to check filename with -f switch, f means regular file if [[ -f $ifgame ]]; then omxplayer "$ifgame" elif [[ -f $ifsystem ]]; then omxplayer "$ifsystem" elif [[ -f $default ]]; then omxplayer "$default" fi
Thanks for this idea... I like it.
Question? Does the call
omxplayer videofile.mp4 > /dev/null 2>&1
not work?
So we do not need to copy omxplayer and edit the file?Keep up the good work
-
Thanks for the changes...makes the code much cleaner too.
Hmm....ya know, I don't know if I ever tried calling it directly that way. I bet you're right though...that would probably work alot easier so you wouldn't need to duplicate the omxplayer file.
I don't think I ever tried it that way but I'll test and see!
-
@dmmarti I think the classic
> /dev/null 2>&1
should work or even the--no-osd
switch, too? -
Works like a charm!
Your updates to the script have greatly simplified the whole process now.
Thank you!
(I've also updated the main post above with the new method).
Thanks to @cyperghost's help, here is the easy way to get this done.
- edit the runcommand-onstart.sh and add the lines below to it
- create the videoloadingscreens folder
- add MP4 files
Add these lines to the runcommand-onstart.sh script.
# Extract file name from called ROM gname="$(basename "$3")" # build path to file and remove extension from ROM to add mp4 extension # $HOME variable will help users that are not stick to raspberry ;) ifgame="$HOME/RetroPie/videoloadingscreens/${gname%.*}.mp4" ifsystem="$HOME/RetroPie/videoloadingscreens/$1.mp4" default="$HOME/RetroPie/videoloadingscreens/default.mp4" # If condition to check filename with -f switch, f means regular file if [[ -f $ifgame ]]; then omxplayer "$ifgame" > /dev/null 2>&1 elif [[ -f $ifsystem ]]; then omxplayer "$ifsystem" > /dev/null 2>&1 elif [[ -f $default ]]; then omxplayer "$default" > /dev/null 2>&1 fi
There's no longer any need to create a duplicate copy of omxplayer. Just the runcommand-onstart.sh addition and then MP4 files.
-
@dmmarti No problem. We have a nice thread shell scripting topic powered by the insane @meleu there you can improve and test your scripting skills. For me it was an ignition to improve code styling and keep things simple. We have some real talented and helpfull people here in the forum. So take this chance if you want ;)
-
So I did this all on the retropie and I tried the newer code. Whenever I try to save it, a message pops up saying that I can't save it because access was denied. I already have "pkill -STOP mpg123" in runcommand because I put music in the selecting page.
I am using a Rpi 3b on retropie 4.4.4
I even tried moving the pkill thing down and It still didn't work -
@Seedname101
The runcommand-onstart.sh file is owned by user "pi".As long as you are editing the file as user "pi" you shouldn't have any issues with file permissions. Also create the new videoloadingscreens folder as user "pi" and you should be good to go.
-
@dmmarti I was using that username. It worked a few weeks later. Thanks anyway!
-
@dmmarti and @cyperghost Do you guys think there's be a way to utilize a different audio driver, but use the same basic setup? So just point to a different drier? In my case I'm using an i2s sound board in a handheld build and I've made my own custom Runcommand videos that have sound. I believe it uses the ALSA driver. It has no access to the OMXplayer sytem. For reference here's what I'm running: Adafruit I2S Stereo Decoder - UDA1334A](https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a/raspberry-pi-usage)
-
@Unboundclassic I2S should work you need to set a
asound.cfg
-
@cyperghost honestly I'm not familiar enough with what you're referring to to know what you're asking me to do. I have audio on the system, the games, and the Splashscreen video working well. Only thing not giving audio is the Runcommand videos as they appear to use OMXplayer.
-
@Unboundclassic said in Game launching video loading screens:
Only thing not giving audio is the Runcommand videos as they appear to use OMXplayer.
Modify the play commands in the on-start script and set
omxplayer
to usealsa
as the output device, i.e. replace allomxplayer
commands withomxplayer -o alsa <...rest of the parameters>
-
@mitu Perfect! Thank you so much! I've been trying to figure this one out for a long time.
So for anyone wanting to run these Runcommand videos and have audio on an i2s sound board here's the script that worked for me.
# Extract file name from called ROM gname="$(basename "$3")" # build path to file and remove extension from ROM to add mp4 extension # $HOME variable will help users that are not stick to raspberry ;) ifgame="$HOME/RetroPie/videoloadingscreens/${gname%.*}.mp4" ifsystem="$HOME/RetroPie/videoloadingscreens/$1.mp4" default="$HOME/RetroPie/videoloadingscreens/default.mp4" # If condition to check filename with -f switch, f means regular file if [[ -f $ifgame ]]; then omxplayer -o alsa "$ifgame" > /dev/null 2>&1 elif [[ -f $ifsystem ]]; then omxplayer -o alsa "$ifsystem" > /dev/null 2>&1 elif [[ -f $default ]]; then omxplayer -o alsa "$default" > /dev/null 2>&1 fi
-
Also here's the set of Runcommand videos I made for my Game Gear Pi if anyone wants to use them. I need to take some time and do HD versions at some point. Rookervik Style Runcommand Videos
-
One of my pet peeves with this setup is the total loading time = Total video runtime + total game loading time.
My solution to this is making the call to omxplayer fork, and it immediately gets on with loading the game, "behind" the playing video.
Most of my (arcade) roms load faster then the usual runtime of the videos, but by the time I finish the video it's run throught he boot initialization and is asking for a coin.
If this also irks you:(<any of the above calls>)&
Since I don't use sound and I'm using a per-rom set of loading screens :
(omxplayer "$ifgame" > /dev/null 2>&1) &
-
@gus_sc I once tried this with launching images, but it created some irritant effects:
this will create a strange behavior of the keyboard's Enter key in the emulator, which is especially annoying in MAME's Tab menu: Pressing Enter will either exit the Emulator or do other strange things like running Emulation Station a second time. It seems like another terminal is running in the background that reacts to the keyboard inputs in the running game.
See https://retropie.org.uk/forum/topic/24671/loading-rom-completely-while-displaying-launch-image/ for the complete thread about it.
Does your method have any such effects?
-
Can Someone Please help me with this!?
Hi, I need help with getting game launching video loading screens to work on my
Raspberry 3B+ on Emulation Station. I'm new to this so can you help me step by step so I can learn how to do this on my own. The reason why I want help with this is, I followed the 3 steps, like step 1 create copy of omxplayer file, I typed cd/usr/bin then I typed sudo cp omxplayer omxplayer_silent, pressed enter, then I typed sudo nano omxplayer_silent. When I did this, this command worked. Then I scrolled down to the end of line like the directions tell me where it says, LD_LIBRARY_PATH="$OMXPLAYER_LIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" $OMXPLAYER_BIN “$@"Then I typed the text that says,
LD_LIBRARY_PATH="$OMXPLAYER_LIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" $OMXPLAYER_BIN "$@" > /dev/null 2>&1
Then I press CTRL-X Press: Y Press: <enter> when I did this, this also worked. Then step 2 edit the runcommand-onstart.sh script, okay so I typed on the command line the commands and I pressed enter after each one, when I did this, this also worked. So I typed the lines:
enablevideolaunch="true"
if [[ $enablevideolaunch == "true" ]]; then
gname=echo $3 |cut -f7 -d "/" |sed 's/.\{4\}$//'
ifgame=ls "/home/pi/RetroPie/videoloadingscreens/${gname}.mp4" |wc -l
ifsystem=ls /home/pi/RetroPie/videoloadingscreens/$1.mp4 |wc -l
if [[ $ifgame > 0 ]];then
omxplayer_silent --blank "/home/pi/RetroPie/videoloadingscreens/${gname}.mp4"
elif [[ $ifsystem > 0 ]];then
omxplayer_silent --blank /home/pi/RetroPie/videoloadingscreens/$1.mp4
else
omxplayer_silent --blank /home/pi/RetroPie/videoloadingscreens/default.mp4
fi
fiwhen I typed all the lines in the runcommand-onstart.sh then I pressed CTRL-X pressed Y pressed <enter>
When I did this, this also worked but when I get to step 3, this is what happens on step 3 create a new folder to store mp4 files. I typed the command cd /home/pi/Retropie then I pressed enter this step did'nt work for me all I get instead is a message that says,
-bash: cd/home/pi/Retropie: No such file or directory
when that did'nt work I tried typing the command mkdir videoloadingscreens that did'nt work either all I got was the message that says,
mkdir: cannot create directory videoloadingscreens file exists
this is the problem I'm having with trying to do this. I can't go beyond step 3 create a new folder to store mp4 files. Is it something I'm doing wrong? This is why I'm asking for someone to help me with this.....
-
@pisces3988 According to the opening post, you don't have to copy omxplayer anymore:
There's no longer any need to create a duplicate copy of omxplayer. Just the runcommand-onstart.sh addition and then MP4 files.
As for your problem with cd, the directory's name is
RetroPie
with an upper caseP
. Linux' file and directory names are case sensitive, soRetropie
is a different dir thanRetroPie
.mkdir: cannot create directory videoloadingscreens file exists
That means just that: there already is a file or directory with this name. Any chance that you created it before? Can you
cd
into it? -
I can't remember if I did or not.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.