Jump to content

All my products and services are free. All my costs are met by donations I receive from my users. If you enjoy using any of my products, please donate to support me. Thank you for your support. Tom Speirs

Patreon

Capture Videos to PinballX Media - Table, Backglass, and DMD


Recommended Posts

Thanks .. I too used the original script with some small tweaks to go thru all my vp tables. For me it was a simple case of dir *.vpt > files.bat, then editing the files.bat to contain entries like:

myscript.ahk sometable.vpt

myscript.ahk othertable.vpt

etc etc

With this I can refresh periodically to capture new tables and new high scores and such in the dmd and backglasses ..

Link to comment
Share on other sites

  • 2 weeks later...

I haven't had a lot of time to spend on FP capture. I did try NVidia ShadowPlay with FP without luck. As FP uses OpenGl it doesn't appear that any DirectShow devices will pick it up. I have a line on another solution, but I've got a lot on my plate at the moment. I may not be able to test it out until after the holidays.

Link to comment
Share on other sites

  • 2 weeks later...

Hey guys.

Am I reading this right? I can use the script in the OP to capture video for use in PinballX previews, right? What if I have a real DMD? Will I need to attach a third monitor to the system temporarily to capture the DMD? Been trying to figure out how to make some video for some tables I have that are missing them.

Thanks all!

Link to comment
Share on other sites

Well I clearly have no idea what I'm doing. After reading this thread a bit I'm supposed to compile an exe that will execute VP and record the images for me. Problem is I have no idea how to compile the script to an exe.

Looking for help or other options. I'd love to be able to contribute to the VP community by making play field, back glass and DMD videos.

Link to comment
Share on other sites

Download autohotkey http://www.autohotkey.com/ and install

It will have a recorder

Copy and paste carny priest script into it change .exe in script if different and any thing else

Save it

Then go to ahk that saved right click and compile

And then you will have you exe also right click and set as administrator

Also make sure you install ffmpeg

Link to comment
Share on other sites

Just a note to say u don't have to compile to an exe you can run the .ahk files just fine if u have windows setup to always run them with autohotkey. While debugging I found it easier to run the ffmpeg commands by hand first to test.

When I was ready I ran a batch file that contained

Grabscreen.ahk "table1.vpt"

Grabscreen.ahk "table2.vpt"

Etc

I can run the above command each time I add a new table.

I created Similar akh scripts for pm5.exe and futurepinball.exe

Link to comment
Share on other sites

Just a note to say u don't have to compile to an exe you can run the .ahk files just fine if u have windows setup to always run them with autohotkey. While debugging I found it easier to run the ffmpeg commands by hand first to test.

When I was ready I ran a batch file that contained

Grabscreen.ahk "table1.vpt"

Grabscreen.ahk "table2.vpt"

Etc

I can run the above command each time I add a new table.

I created Similar akh scripts for pm5.exe and futurepinball.exe

Yes, this is true if you install autohotkey on your cabinet. I tend to prefer to keep my cabinet clear of any installers, run-time environments, applications that I don't absolutely need. I compile on my test machine and transfer the executable over to the cabinet for use.

Now, futurepinball.exe. You are actually able to capture table videos with the script?

Link to comment
Share on other sites

Here's an interim script for FP. It is a concept that will work Ok for plain vanilla Future Pinball set-ups. Adjust the script to your executable accordingly. This also assumes that you are using FutureDMD. If you are not then comment out the line that runs FutureDMD.

Although I am calling the table through BAM/fploader, I am not capturing any BAM post-processing, just unprocessed Future Pinball. So, this is not a solution for me and I will have to take a different tack. I always use BAM. There is not a pressing need for me to generate media right now, but I'll get back to this at some point. Might be easier to simply shell out for FRAPS, Camtasia, or dxtory.

The tool I am using here is apitrace

https://github.com/apitrace/apitrace

I simply extract it to C:\

This still uses ffmpeg for generating the final videos.

This is a bit kludgy. I use apitrace to capture OpenGl instructions to a file called playfield.trace. I then use apitrace to playback the capture and pipe the output directly to ffmpeg. It is a super long command and it seems like Windows does not properly recognize it as a valid command. I don't see any problems coming from Autohotkey (as in an interpreter issue). I got around this by inserting the command into a separate bat file.

#NoEnv
#SingleInstance force
#WinActivateForce
SetTitleMatchMode 2
DetectHiddenWindows On
FileReadLine, PF_width, c:\Program Files (x86)\Visual Pinball\Tables\ScreenRes.txt, 1
;FileReadLine, PF_height, c:\Program Files (x86)\Visual Pinball\Tables\ScreenRes.txt, 2
FileReadLine, BG_width, c:\Program Files (x86)\Visual Pinball\Tables\ScreenRes.txt, 3
FileReadLine, BG_height, c:\Program Files (x86)\Visual Pinball\Tables\ScreenRes.txt, 4
FileReadLine, DMD_width, c:\Program Files (x86)\Visual Pinball\Tables\ScreenRes.txt, 8
FileReadLine, DMD_height, c:\Program Files (x86)\Visual Pinball\Tables\ScreenRes.txt, 9
FileReadLine, DMD_X, c:\Program Files (x86)\Visual Pinball\Tables\ScreenRes.txt, 10
FileReadLine, DMD_Y, c:\Program Files (x86)\Visual Pinball\Tables\ScreenRes.txt, 11
XDMD_X:=BG_width+DMD_X ;Reference to Top Left of Playfield screen
Table = %1% ;Variable from FP
StringTrimRight, XTable, Table, 4 ;Trim ".fpt" for output file name
;Disable Aero if Enabled
RegRead, DWMComp, HKCU, Software\Microsoft\Windows\DWM, Composition
Aero = %DWMComp%
If Aero = 1
Run, sc stop uxsms,,UseErrorLevel
Run, "c:\apitrace-msvc\x86\bin\apitrace.exe" trace --output="%A_ScriptDir%\playfield.trace" "c:\Games\Future Pinball\BAM\FPloader.exe" /STAYINRAM /open "c:\Games\Future Pinball\Tables\%Table%" /play /exit /arcaderender,,UseErrorLevel
Process, wait, Future Pinball.exe
Run, "c:\Games\Future Pinball\FutureDMD.exe" table=%Table% close=1,,UseErrorLevel
; Fastest Capture
Run, ffmpeg -t 100 -rtbufsize 1500M -f gdigrab -framerate 30 -offset_x %PF_width% -offset_y 0 -video_size %BG_width%x%BG_Height% -i desktop -pix_fmt yuv420p -vcodec libx264 -preset ultrafast -threads 8 "%A_ScriptDir%\bg.mkv",,Hide UseErrorLevel
If DMD_width > 0
Run, ffmpeg -t 100 -rtbufsize 1500M -f gdigrab -framerate 30 -offset_x %XDMD_X% -offset_y %DMD_Y% -video_size %DMD_width%x%DMD_Height% -i desktop -pix_fmt yuv420p -vcodec libx264 -preset ultrafast -threads 8 "%A_ScriptDir%\dmd.mkv",,Hide UseErrorLevel
WinActivate, Future Pinball
WinWaitActive, Future Pinball
Process, WaitClose, ffmpeg.exe, 100
Sleep 5000
; CloseFP from FPLaunch
WinHide, ahk_class FuturePinball
WinMinimize, ahk_class FuturePinball
;Future Pinball must be closed this way instead of killing process
;or it wil not save your last game information.i.e score/credtis
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {Esc}
WinWaitClose, ahk_class FuturePinballOpenGL
;saving fp table position, black screen hides fp window
; if (saveFPTables = "true") and (saveFPNeeded = "true") {
; ;WinRestore, ahk_class FuturePinball
; WinActivate, ahk_class FuturePinball
; WinWaitActive, ahk_class FuturePinball
; WinMenuSelectItem, ahk_class FuturePinball,,File,Save
; Sleep, 1000
; }
; IfExist %emupath%\FutureDMD.exe
Process, close, FutureDMD.exe
WinClose, ahk_class FuturePinball
WinWaitClose, ahk_class FuturePinball
Sleep 2000
; Post Capture Trim and Transcode
Run, %comspec% /c playfield.bat "%A_ScriptDir%\playfield.trace" "C:\PinballX\Media\Future Pinball\Table Videos\%XTable%.f4v",,UseErrorLevel
Run, ffmpeg -y -i "%A_ScriptDir%\bg.mkv" -ss 35 -to 95 -c:v libx264 -crf 26 "C:\PinballX\Media\Future Pinball\Backglass Videos\%XTable%.f4v",,UseErrorLevel
If DMD_width > 0
Run, ffmpeg -y -i "%A_ScriptDir%\dmd.mkv" -ss 35 -to 95 -c:v libx264 -crf 26 "C:\PinballX\Media\Future Pinball\DMD Videos\%XTable%.f4v",,UseErrorLevel
Process, WaitClose, ffmpeg.exe
; Clean up
FileDelete, %A_ScriptDir%\playfield.trace
FileDelete, %A_ScriptDir%\bg.mkv
If DMD_width > 0
FileDelete, %A_ScriptDir%\dmd.mkv
;Enable Aero if Enabled at the start of script execution
If Aero = 1
Run, sc start uxsms,,UseErrorLevel
ExitApp

Here are the contents of playfield.bat (all on line 1)

"c:\apitrace-msvc\x86\bin\apitrace.exe" dump-images -o - %1 | ffmpeg -r 30 -f image2pipe -vcodec ppm -i pipe: -ss 35 -to 95 -pix_fmt yuv420p -vf "rotate=PI:bilinear=0" -c:v libx264 -crf 26 -y %2

Think of playfield.trace as uncompressed video. The program cleans up after itself but you will need some space on your drive for the capture. Also, playback and pipe to ffmpeg looks like slo-mo when it is happening. The output file will be at normal speed, but it will take four or five minutes to complete the conversion to video. So, not as fast as the VP script.
Good luck. The search continues for a BAM-friendlier solution.
Link to comment
Share on other sites

Yes, this is true if you install autohotkey on your cabinet. I tend to prefer to keep my cabinet clear of any installers, run-time environments, applications that I don't absolutely need. I compile on my test machine and transfer the executable over to the cabinet for use.

Now, futurepinball.exe. You are actually able to capture table videos with the script?

You are right! I forgot .. it wasnt working for futurepinball. The screen sizes were bigger but the real problem seemed to be that future pinball would take control of the ahk stuff and just stop it or something.

Link to comment
Share on other sites

You are right! I forgot .. it wasnt working for futurepinball. The screen sizes were bigger but the real problem seemed to be that future pinball would take control of the ahk stuff and just stop it or something.

Ok, just making sure I wasn't missing something re: future pinball. You might try the newest script I posted. It might even work very well for you if you are not a BAM user. At least it shuts down FP cleanly which might have been one of the problems before this latest version.

Link to comment
Share on other sites

  • 5 weeks later...

Update:

1.

Thanks to horseyhorsey/Chepas for the idea of unifying multiple VP executables under one system, I now have a single script that can capture VP media for multiple executables. No need to create different versions of essentially the same script. Sometimes you simply have to capture the table media with the same executable for which it was designed to run. Stern Indiana Jones is a good example.

It just requires adding an extra argument if you want to capture using an executable other than the default. For me, I have VPinball991.exe as the default. And I also have Physmod2 and Physmod5.

The lines that require editing are the path to the PinballX installation and the ini headers under which the other executables are set up.

Ex.

PinballX_Path = C:\PinballX
; For system use the ini header where you have defined your other Visual Pinball setups
system2 = System_9 ;PhysMod2
system3 = System_4 ;PhysMod5
I have PhysMod2 set up under Other Systems 9 and PhysMod5 set up under Other Systems 4 in the Settings Wizard, Other Systems screen.
The command would be capscreensvp.exe "table" arg2
where arg2 is 2 if you want to capture using PhysMod2 or 5 if you want to capture using PhysMod5. Anything else or leaving it blank will run the default.
Don't forget that the "table" filename must include the entire file name including the vpt extension.
2.

The output file will now save with the same name as the description tag in the xml. For most people that is Table Name (Manufacturer Year). Before, the output file was the same as the file name used as the input.

This means that when you capture an update to the table, you no longer have to go back in your media folders and delete out the old versions. If the media file name is the same as the description tag in the xml then it will simply be overwritten.

Compiling this requires the script xpath.ahk. A link is in the script. The file must be compiled with xpath.ahk in the same folder as the script, but after that the executable is portable.

3.

Changed the ffmpeg capture pix_fmt color space parameter from yuv420p to the default which is yuv444p. Just about every media player can play output encoded with yuv420p (most of the media files that I have seen distributed have this format) but the colors produced by the previous ffmpeg command were a bit washed out. This is especially evident with DMD videos in the standard orange color. The Shark codecs don't appear to have a problem playing back the output encoded in yuv444p and the colors are no longer washed out. There's an insignificant increase in file size. I call it a win!

#NoEnv
#SingleInstance force
#WinActivateForce
#Include, %A_ScriptDir%\xpath.ahk
SetTitleMatchMode 2
DetectHiddenWindows On
PinballX_Path = C:\PinballX
; For system use the ini header where you have defined your other Visual Pinball setups
system2 = System_9 ;PhysMod2
system3 = System_4 ;PhysMod5
Table = %1% ;Variable from VP
ExeType = %2%
If ExeType = 2
system = %system2%
Else If ExeType = 5
system = %system3%
Else system = VisualPinball
; Read PinballX config for paths
If system = VisualPinball
Name = Visual Pinball
Else IniRead, Name, %PinballX_Path%\Config\PinballX.ini, %system%, Name
IniRead, WorkingPath, %PinballX_Path%\Config\PinballX.ini, %system%, WorkingPath
IniRead, TablePath, %PinballX_Path%\Config\PinballX.ini, %system%, TablePath
IniRead, Exe, %PinballX_Path%\Config\PinballX.ini, %system%, Executable
SplitPath, Table,,,,XTable,
; Read description tag from xml - Thanks horseyhorsey - http://www.gameex.info/forums/topic/14632-multiple-exe-for-vp/#entry129111
databaseFile = %PinballX_Path%\Databases\%Name%\%Name%.xml
xpath_load(dbXML, databaseFile ) ; need to read the existing xml otherwise xpath deletes all existing nodes
description := XPath(dbXML, "/menu/game[@name= . XTable . ]/description/text()")
FileReadLine, PF_width, %TablePath%\ScreenRes.txt, 1
FileReadLine, PF_height, %TablePath%\ScreenRes.txt, 2
FileReadLine, BG_width, %TablePath%\ScreenRes.txt, 3
FileReadLine, BG_height, %TablePath%\ScreenRes.txt, 4
FileReadLine, DMD_width, %TablePath%\ScreenRes.txt, 8
FileReadLine, DMD_height, %TablePath%\ScreenRes.txt, 9
FileReadLine, DMD_X, %TablePath%\ScreenRes.txt, 10
FileReadLine, DMD_Y, %TablePath%\ScreenRes.txt, 11
XDMD_X:=BG_width+DMD_X ;Reference to Top Left of Playfield screen
; Disable Aero if Enabled
RegRead, DWMComp, HKCU, Software\Microsoft\Windows\DWM, Composition
Aero = %DWMComp%
If Aero = 1
Run, sc stop uxsms,,UseErrorLevel
;run dc2.exe -configure="%PinballX_Path%\Scripts\dc2config\VPMSettings.xml"
Run, %WorkingPath%\%Exe% -play "%TablePath%\%Table%",,UseErrorLevel
Process, wait, %Exe%
Sleep, 30000 ; Allow time for table score display to get well beyond loading and boot images
; Fastest Capture
Run, ffmpeg -t 70 -rtbufsize 1500M -f gdigrab -framerate 30 -offset_x 0 -offset_y 0 -video_size %PF_width%x%PF_Height% -i desktop -vcodec libx264 -preset ultrafast -threads 8 "%A_ScriptDir%\playfield.mkv",,Hide UseErrorLevel
Run, ffmpeg -t 70 -rtbufsize 1500M -f gdigrab -framerate 30 -offset_x %PF_width% -offset_y 0 -video_size %BG_width%x%BG_Height% -i desktop -vcodec libx264 -preset ultrafast -threads 8 "%A_ScriptDir%\bg.mkv",,Hide UseErrorLevel
If DMD_width > 0
Run, ffmpeg -t 70 -rtbufsize 1500M -f gdigrab -framerate 30 -offset_x %XDMD_X% -offset_y %DMD_Y% -video_size %DMD_width%x%DMD_Height% -i desktop -vcodec libx264 -preset ultrafast -threads 8 "%A_ScriptDir%\dmd.mkv",,Hide UseErrorLevel
WinActivate, Visual Pinball Player
WinWaitActive, Visual Pinball Player
Process, WaitClose, ffmpeg.exe, 70
Sleep 5000
Run, taskkill /IM %Exe% /F,,UseErrorLevel
;run dc2.exe -configure="%PinballX_Path%\Scripts\dc2config\StandardSettings.xml"
; Post Capture Trim and Transcode
Run, ffmpeg -y -i "%A_ScriptDir%\playfield.mkv" -ss 5 -to 65 -vf "rotate=PI:bilinear=0" -c:v libx264 -crf 26 "%PinballX_Path%\Media\Visual Pinball\Table Videos\%description%.f4v",,UseErrorLevel
Run, ffmpeg -y -i "%A_ScriptDir%\bg.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "%PinballX_Path%\Media\Visual Pinball\Backglass Videos\%description%.f4v",,UseErrorLevel
If DMD_width > 0
Run, ffmpeg -y -i "%A_ScriptDir%\dmd.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "%PinballX_Path%\Media\Visual Pinball\DMD Videos\%description%.f4v",,UseErrorLevel
Process, WaitClose, ffmpeg.exe
; Clean up
FileDelete, %A_ScriptDir%\playfield.mkv
FileDelete, %A_ScriptDir%\bg.mkv
If DMD_width > 0
FileDelete, %A_ScriptDir%\dmd.mkv
; Enable Aero if Enabled at the start of script execution
If Aero = 1
Run, sc start uxsms,,UseErrorLevel
ExitApp

The dc2 lines are there because I run a custom resolution for VPM. Most people don't do that, so I've commented them out here.

  • Like 1
Link to comment
Share on other sites

Carny can you help me Ive been struggling on my dmd to record

I cant not get to record my DMD Ive tried a couple things like changing the XDMD_X to XDMD_X:=3845 to show location of top left of dmd. Ive also deleted the "If DMD_width > 0" in script to see if that works and i cant get dmd to record the BG and PF record fine. Ive tried your new script and same thing

Any suggestions would be helpful

Thanks again for time put into this because it is nice to record BG and PF so easy

Chris

Heres My screenres.txt

1920
1080
1920
1080
3
0
0
1024
433
3845
69
0
Link to comment
Share on other sites

I'm reading in the values of screenres.txt under the assumption that you place the VPM DMD in the same location. For whatever reason I'm thinking that's not the case for your setup.

In your screenres.txt I always understood that the third screen LED X offset was in reference to the left corner of the backglass, not the playfield. In other words, to see the LED display on your third screen the value should be 1965. Do you ever use the third screen to display the alpha numeric LED for games like Jokerz and Funhouse or do you always set up so that those are displayed on the backglass?

http://www.vpforums.org/index.php?showtopic=18020#entry163516

What are the x and y positions and width and height for the default set up For Visual PinMAME in the registry?

I probably should just read these values in from the registry but I do capture the directB2S third screen for my media collection. These just typically don't get published... anywhere.

In any case if I'm right just fix your screenres.txt even if you never use the third screen for LED tables.

Link to comment
Share on other sites

Ok, I subtracted wrong somewhere. It shouldn't have been 1965

Recall that Visual PinMAME DMD and directB2S are two different and independent systems. What values you assign in screenres.txt does not somehow carry over into the registry or vice-versa.

If you are happy with the way your DMD looks, I'd suggest setting up your B2S settings to match. Then, going by your registry values, screenres.txt would be:

1920

1080

1920

1080

0

0

1022

430

1921

71

0

Here, the value for X Position of the LED screen is 1921 instead of 3841 because directB2S is looking for a value in reference to the top corner of the backglass screen and not the playfield screen

Give it a try then you will be able to properly record media for your alphanumeric games and for other directB2S backglasses that make use of the third screen (displaying a logo, etc.)

Looking at the screenres values, it reminds me that there may be users that use the backglass offsets either because they need to work around a bezel or they have set up multiple screenres.txt to retain correct aspect ratios for translites from different eras. I don't do that. I make use of as much screen real estate as I can. But if there is a need I'll work with anyone who wants to run this script.

Link to comment
Share on other sites

Update:

Added some file name handling.

Fixed - Xpath code was reading in commas as special characters, , So, A description like "Addams Family, The (Bally 1992)" would have incorrect file names and would not get played by PinballX without having to go in and rename manually.

Added - script looks for invalid Windows file name characters. If it finds one then the file name reverts to the input file name (i.e., the value of the game name field). A description like "AC/DC (Stern 2012)" can't be used as the forward slash is an invalid file name character.

#NoEnv
#SingleInstance force
#WinActivateForce
#Include, %A_ScriptDir%\xpath.ahk
SetTitleMatchMode 2
DetectHiddenWindows On
PinballX_Path = C:\PinballX
; For system use the ini header where you have defined your other Visual Pinball setups
system2 = System_9 ;PhysMod2
system3 = System_4 ;PhysMod5
Table = %1% ;Variable from VP
ExeType = %2%
If ExeType = 2
system = %system2%
Else If ExeType = 5
system = %system3%
Else system = VisualPinball
; Read PinballX config for paths
If system = VisualPinball
Name = Visual Pinball
Else IniRead, Name, %PinballX_Path%\Config\PinballX.ini, %system%, Name
IniRead, WorkingPath, %PinballX_Path%\Config\PinballX.ini, %system%, WorkingPath
IniRead, TablePath, %PinballX_Path%\Config\PinballX.ini, %system%, TablePath
IniRead, Exe, %PinballX_Path%\Config\PinballX.ini, %system%, Executable
SplitPath, Table,,,,XTable,
; Read description tag from xml - Thanks horseyhorsey - http://www.gameex.info/forums/topic/14632-multiple-exe-for-vp/#entry129111
databaseFile = %PinballX_Path%\Databases\%Name%\%Name%.xml
xpath_load(dbXML, databaseFile ) ; need to read the existing xml otherwise xpath deletes all existing nodes
description := XPath(dbXML, "/menu/game[@name= . XTable . ]/description/text()")
StringReplace, description, description,,,`,,
StringGetPos, pos, description,\
If ErrorLevel=1
StringGetPos, pos, description,/
If ErrorLevel=1
StringGetPos, pos, description,:
If ErrorLevel=1
StringGetPos, pos, description,*
If ErrorLevel=1
StringGetPos, pos, description,?
If ErrorLevel=1
StringGetPos, pos, description,"
If ErrorLevel=1
StringGetPos, pos, description,>
If ErrorLevel=1
StringGetPos, pos, description,|
If ErrorLevel=0
description=%XTable%
FileReadLine, PF_width, %TablePath%\ScreenRes.txt, 1
FileReadLine, PF_height, %TablePath%\ScreenRes.txt, 2
FileReadLine, BG_width, %TablePath%\ScreenRes.txt, 3
FileReadLine, BG_height, %TablePath%\ScreenRes.txt, 4
FileReadLine, DMD_width, %TablePath%\ScreenRes.txt, 8
FileReadLine, DMD_height, %TablePath%\ScreenRes.txt, 9
FileReadLine, DMD_X, %TablePath%\ScreenRes.txt, 10
FileReadLine, DMD_Y, %TablePath%\ScreenRes.txt, 11
XDMD_X:=BG_width+DMD_X ;Reference to Top Left of Playfield screen
; Disable Aero if Enabled
RegRead, DWMComp, HKCU, Software\Microsoft\Windows\DWM, Composition
Aero = %DWMComp%
If Aero = 1
Run, sc stop uxsms,,UseErrorLevel
;run dc2.exe -configure="%PinballX_Path%\Scripts\dc2config\VPMSettings.xml"
Run, %WorkingPath%\%Exe% -play "%TablePath%\%Table%",,UseErrorLevel
Process, wait, %Exe%
Sleep, 30000 ; Allow time for table score display to get well beyond loading and boot images
; Fastest Capture
Run, ffmpeg -t 70 -rtbufsize 1500M -f gdigrab -framerate 30 -offset_x 0 -offset_y 0 -video_size %PF_width%x%PF_Height% -i desktop -vcodec libx264 -preset ultrafast -threads 8 "%A_ScriptDir%\playfield.mkv",,Hide UseErrorLevel
Run, ffmpeg -t 70 -rtbufsize 1500M -f gdigrab -framerate 30 -offset_x %PF_width% -offset_y 0 -video_size %BG_width%x%BG_Height% -i desktop -vcodec libx264 -preset ultrafast -threads 8 "%A_ScriptDir%\bg.mkv",,Hide UseErrorLevel
If DMD_width > 0
Run, ffmpeg -t 70 -rtbufsize 1500M -f gdigrab -framerate 30 -offset_x %XDMD_X% -offset_y %DMD_Y% -video_size %DMD_width%x%DMD_Height% -i desktop -vcodec libx264 -preset ultrafast -threads 8 "%A_ScriptDir%\dmd.mkv",,Hide UseErrorLevel
WinActivate, Visual Pinball Player
WinWaitActive, Visual Pinball Player
Process, WaitClose, ffmpeg.exe, 70
Sleep 5000
Run, taskkill /IM %Exe% /F,,UseErrorLevel
;run dc2.exe -configure="%PinballX_Path%\Scripts\dc2config\StandardSettings.xml"
; Post Capture Trim and Transcode
Run, ffmpeg -y -i "%A_ScriptDir%\playfield.mkv" -ss 5 -to 65 -vf "rotate=PI:bilinear=0" -c:v libx264 -crf 26 "%PinballX_Path%\Media\Visual Pinball\Table Videos\%description%.f4v",,UseErrorLevel
Run, ffmpeg -y -i "%A_ScriptDir%\bg.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "%PinballX_Path%\Media\Visual Pinball\Backglass Videos\%description%.f4v",,UseErrorLevel
If DMD_width > 0
Run, ffmpeg -y -i "%A_ScriptDir%\dmd.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "%PinballX_Path%\Media\Visual Pinball\DMD Videos\%description%.f4v",,UseErrorLevel
Process, WaitClose, ffmpeg.exe
; Clean up
FileDelete, %A_ScriptDir%\playfield.mkv
FileDelete, %A_ScriptDir%\bg.mkv
If DMD_width > 0
FileDelete, %A_ScriptDir%\dmd.mkv
; Enable Aero if Enabled at the start of script execution
If Aero = 1
Run, sc start uxsms,,UseErrorLevel
ExitApp

I expect that once there is support in PinballX that the script will work just fine for VP10. It is agnostic as far as file extensions go. Just add a new system at the top of the script.
  • Like 1
Link to comment
Share on other sites

Hi Carny_Priest,

your script is cool ! The new feature of different VP Versions is fine...but in PX I have different \media Folders, eg. \media\Visual Pinball and \Media\Physmod (depends on the name given to system_x in the setup. So the Output should go to ..\media \%SystemName%\...and not to .\media\Visual Pinball\... for all systems as it is at the moment. I tried myself, but I did'nt manage to do :-((

See Ya... Jas

Link to comment
Share on other sites

I use symbolic links to tie the media folders for the alternate executables to the default. Makes files easier to manage for those times when you update a table to physmod5.

If you'd rather keep the media attached to their respective systems, try %Name% instead of %SystemName%

Hmm..never userd symlinks in Windows..but like the idea to have only one place for die Media.....i think i'll try it out ...

Tnx, Jas....

Link to comment
Share on other sites

I found that the xpath doesn't appear to match the xml if the input table name has an ampersand, such as "Twilight Zone Night Mod Toys & TV.vpt". I can't think what to do about that. After all, that was the file name given by the author. Just rename the file and game name without the "&". Should work from there.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Update:

1. Now with support for Future Pinball! I'm using Open Broadcaster Software v0.64 beta.

https://obsproject.com/

You will also need the file in the attachment.

Download OBS and copy the contents of the file somewhere. Choose the 32bit or 64bit version. In the folder with the OBS executable, create a folder named 'profiles'. Create a second folder named 'sceneCollection'.

Extract the two files in the attachment. Copy FuturePinball.ini to the profiles folder. Copy FuturePinball.xconfig to the sceneCollection folder. Then define in the top of the script the path to the OBS executable. That's it. Anything else needed by the program will be read from the registry and FutureDMD.ini.

Capturing in YUV 4:4:4 Planar is disabled in this version of OBS, so the program is setup to capture in full range Planar YUV 4:2:0. In other words, no clipping of blacks or whites and reduced contrast versus what you experience in-game.

The profile and config files are set up to produce reference files that have lossless video and the highest quality available audio. I don't use audio myself, but I can't disable audio capture. So, in that spirit...

2. ... I've added lossless audio capture for Visual Pinball. This may come free with your audio driver. See this tutorial:

http://www.howtogeek.com/howto/39532/how-to-enable-stereo-mix-in-windows-7-to-record-audio/

alternately you can see what DirectShow devices are already available. The command is:

ffmpeg -list_devices true -f dshow -i dummy

Select a device and type it in quotes in the Audio_Device line at the top of the script

If your audio driver doesn't support Stereo Mix output, you can use this capturer:

https://github.com/rdp/virtual-audio-capture-grabber-device

If you don't want to capture audio at all there is an alternate command that is commented out in the script that captures without audio.

3. Tweaked the ffmpeg VP captures to ensure that they are lossless

4. Fixed the link to the xpath library at the top of the script

5. Tweaked to be a little more portable. Add your path to ffmpeg at the top of the script. Now you don't have to keep ffmpeg in your cabinet or change your environment path.

As in the earlier script, there is a second pass that transcodes the reference files to final output and saves them in the correct media folders. Then it deletes the reference files. The idea is that you can always comment out the lines that delete these files if you want to use them in your own editing software.

The quality levels I selected produce table files somewhere around 10Mb for 1920x1080 resolution. The audio streams are stripped back out. File sizes can get a bit larger if you are running Future Pinball at higher resolutions and downsampling.

One other note: I don't know whether it is a feature or a bug with OBS (seeing how it was not really designed for recording video but for streaming video), but I'm running the script off of a portable drive that also has OBS. That's how I transfer files over to my cabinet. I don't use OBS for anything else, so I don't need a permanent installation on my cabinet. I found that I have to unplug and plug back in my drive in between FP captures. Otherwise, OBS will only capture audio and not video. So batching up runs is out for me. Not a huge deal for me as I don't have many FP tables. It's not really working for me to try to do everything off of my local SSD. So, fair warning. I have absolutely no issues with VP captures.

If worse comes to worse, it is possible to cycle a USB port programmatically. But I'll just see if this improves in the future with updates to OBS.

#NoEnv
#SingleInstance force
#WinActivateForce
#Include, %A_ScriptDir%\xpath.ahk
SetTitleMatchMode 2
DetectHiddenWindows On
PinballX_Path = c:\PinballX
; For system use the ini header where you have defined your other Visual Pinball setups
system2 = System_9 ;PhysMod2
system3 = System_4 ;PhysMod5
FFMPEG_Path = c:\FFMPEG\bin
OBS_Path = c:\OBS\64bit
Audio_Device = "Stereo Mix (Realtek High Defini"
Table = %1% ;Table filename
ExeType = %2%
SplitPath, Table,,,ext,XTable,
If ExeType = 2
system = %system2%
Else If ExeType = 5
system = %system3%
Else If ext = fpt
system = FuturePinball
Else system = VisualPinball
; Read PinballX config for paths
If system = VisualPinball
Name = Visual Pinball
Else If system = FuturePinball
Name = Future Pinball
Else IniRead, Name, %PinballX_Path%\Config\PinballX.ini, %system%, Name
IniRead, WorkingPath, %PinballX_Path%\Config\PinballX.ini, %system%, WorkingPath
IniRead, TablePath, %PinballX_Path%\Config\PinballX.ini, %system%, TablePath
IniRead, Exe, %PinballX_Path%\Config\PinballX.ini, %system%, Executable
If ext = fpt
{
RegRead, PF_width, HKCU, Software\Future Pinball\GamePlayer, Width
RegRead, PF_height, HKCU, Software\Future Pinball\GamePlayer, Height
RegRead, BG_width, HKCU, Software\Future Pinball\GamePlayer, SecondMonitorWidth
RegRead, BG_height, HKCU, Software\Future Pinball\GamePlayer, SecondMonitorHeight
IniRead, DMD_width, %WorkingPath%\FutureDMD.ini, default, SizeW
IniRead, DMD_height, %WorkingPath%\FutureDMD.ini, default, SizeH
IniRead, DMD_X, %WorkingPath%\FutureDMD.ini, default, PosX
IniRead, DMD_Y, %WorkingPath%\FutureDMD.ini, default, PosY
IniWrite, %PF_width%, %OBS_Path%\profiles\FuturePinball.ini, Video, BaseWidth
IniWrite, %PF_height%, %OBS_Path%\profiles\FuturePinball.ini, Video, BaseHeight
IniWrite, %A_ScriptDir%\playfield.mp4, %OBS_Path%\profiles\FuturePinball.ini, Publish, SavePath
IniWrite, %A_ScriptDir%\Replay-$T.flv, %OBS_Path%\profiles\FuturePinball.ini, Publish, ReplayBufferSavePath
FileRead, Text, %OBS_Path%\sceneCollection\FuturePinball.xconfig ; Read file and return as var Text
IfNotInString, Text, %PF_width%
IfNotInString, Text, %PF_height%
{
IfInString, Text, 1280
IfInString, Text, 1024
{
StringReplace, Text, Text, 1280, %PF_width%, All
StringReplace, Text, Text, 1024, %PF_height%, All
FileDelete, %OBS_Path%\sceneCollection\FuturePinball.xconfig
FileAppend, %Text%, %OBS_Path%\sceneCollection\FuturePinball.xconfig
init=1
}
If init != 1
{
MsgBox Warning playfield width/height do not match FuturePinball.xconfig
ExitApp
}
}
}
Else
{
FileReadLine, PF_width, %TablePath%\ScreenRes.txt, 1
FileReadLine, PF_height, %TablePath%\ScreenRes.txt, 2
FileReadLine, BG_width, %TablePath%\ScreenRes.txt, 3
FileReadLine, BG_height, %TablePath%\ScreenRes.txt, 4
FileReadLine, DMD_width, %TablePath%\ScreenRes.txt, 8
FileReadLine, DMD_height, %TablePath%\ScreenRes.txt, 9
FileReadLine, XDMD_X, %TablePath%\ScreenRes.txt, 10
FileReadLine, DMD_Y, %TablePath%\ScreenRes.txt, 11
DMD_X:=BG_width+XDMD_X ;Reference to Top Left of Playfield screen
}
; Read description tag from xml - Thanks horseyhorsey - http://www.gameex.info/forums/topic/14632-multiple-exe-for-vp/#entry129111
databaseFile = %PinballX_Path%\Databases\%Name%\%Name%.xml
xpath_load(dbXML, databaseFile ) ; need to read the existing xml otherwise xpath deletes all existing nodes
description := XPath(dbXML, "/menu/game[@name= . XTable . ]/description/text()")
StringReplace, description, description,,,`,,
StringGetPos, pos, description,\
If ErrorLevel=1
StringGetPos, pos, description,/
If ErrorLevel=1
StringGetPos, pos, description,:
If ErrorLevel=1
StringGetPos, pos, description,*
If ErrorLevel=1
StringGetPos, pos, description,?
If ErrorLevel=1
StringGetPos, pos, description,"
If ErrorLevel=1
StringGetPos, pos, description,>
If ErrorLevel=1
StringGetPos, pos, description,|
If ErrorLevel=0
description=%XTable%
;Disable Aero if Enabled
RegRead, DWMComp, HKCU, Software\Microsoft\Windows\DWM, Composition
Aero = %DWMComp%
If Aero = 1
Run, sc stop uxsms,,UseErrorLevel
;If ext = fpt
; Run, "%PinballX_Path%\Scripts\dc2.exe" -configure="%PinballX_Path%\Scripts\dc2config\FPSettings.xml"
;Else
; Run, "%PinballX_Path%\Scripts\dc2.exe" -configure="%PinballX_Path%\Scripts\dc2config\VPMSettings.xml"
If ext = fpt
{
Run, %WorkingPath%\%Exe% /STAYINRAM /open "%TablePath%\%Table%" /play /exit,,UseErrorLevel
Process, wait, Future Pinball.exe
If DMD_width>0
Run, %WorkingPath%\FutureDMD.exe table="%Table%" close=1,,UseErrorLevel
}
Else
{
Run, %WorkingPath%\%Exe% -play "%TablePath%\%Table%",,UseErrorLevel
Process, wait, %Exe%
}
Sleep, 30000 ; Allow time for table score display to get well beyond loading and boot images
; Fastest Capture
If ext = fpt
Run, %OBS_Path%\OBS.exe -portable -profiles "FuturePinball" -start,,Hide UseErrorLevel
Else
Run, ffmpeg -t 70 -rtbufsize 1500M -f dshow -i audio=%Audio_Device% -f gdigrab -framerate 30 -offset_x 0 -offset_y 0 -video_size %PF_width%x%PF_height% -i desktop -vcodec libx264 -preset ultrafast -qp 0 -acodec copy -threads 8 "%A_ScriptDir%\playfield.mkv",,Hide UseErrorLevel
; Run, ffmpeg -t 70 -rtbufsize 1500M -f gdigrab -framerate 30 -offset_x 0 -offset_y 0 -video_size %PF_width%x%PF_height% -i desktop -vcodec libx264 -preset ultrafast -qp 0 -threads 8 "%A_ScriptDir%\playfield.mkv",,Hide UseErrorLevel
Run, ffmpeg -t 70 -rtbufsize 1500M -f gdigrab -framerate 30 -offset_x %PF_width% -offset_y 0 -video_size %BG_width%x%BG_height% -i desktop -vcodec libx264 -preset ultrafast -qp 0 -threads 8 "%A_ScriptDir%\bg.mkv",,Hide UseErrorLevel
If DMD_width > 0
Run, ffmpeg -t 70 -rtbufsize 1500M -f gdigrab -framerate 30 -offset_x %DMD_X% -offset_y %DMD_Y% -video_size %DMD_width%x%DMD_height% -i desktop -vcodec libx264 -preset ultrafast -qp 0 -threads 8 "%A_ScriptDir%\dmd.mkv",,Hide UseErrorLevel
If ext = fpt
{
WinHide, ahk_class FuturePinball
WinMinimize, ahk_class FuturePinball
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
WinHide, ahk_class Button
WinHide, ahk_class Shell_TrayWnd
}
Else
{
WinActivate, Visual Pinball Player
WinWaitActive, Visual Pinball Player
}
Process, WaitClose, ffmpeg.exe, 80
Process, Close, %ErrorLevel%
WinClose, ahk_class OBSWindowClass
If ext = fpt
{
Sleep 15000
Run, taskkill /IM OBS.exe /F,,UseErrorLevel
; CloseFP from FPLaunch
WinHide, ahk_class FuturePinball
WinMinimize, ahk_class FuturePinball
;Future Pinball must be closed this way instead of killing process
;or it wil not save your last game information.i.e score/credtis
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {Esc}
WinWaitClose, ahk_class FuturePinballOpenGL
;saving fp table position, black screen hides fp window
; if (saveFPTables = "true") and (saveFPNeeded = "true") {
; ;WinRestore, ahk_class FuturePinball
; WinActivate, ahk_class FuturePinball
; WinWaitActive, ahk_class FuturePinball
; WinMenuSelectItem, ahk_class FuturePinball,,File,Save
; Sleep, 1000
; }
; IfExist %emupath%\FutureDMD.exe
Process, close, FutureDMD.exe
WinClose, ahk_class FuturePinball
WinWaitClose, ahk_class FuturePinball
WinShow, ahk_class Button
WinShow, ahk_class Shell_TrayWnd
}
Else
Run, taskkill /IM %Exe% /F,,UseErrorLevel
;Run, "%PinballX_Path%\Scripts\dc2.exe" -configure="%PinballX_Path%\Scripts\dc2config\StandardSettings.xml"
;Enable Aero if Enabled at the start of script execution
If Aero = 1
Run, sc start uxsms,,UseErrorLevel
; Post Capture Trim and Transcode
If ext = fpt
{
Run, ffmpeg -y -i "%A_ScriptDir%\playfield.mp4" -ss 5 -to 65 -vf "rotate=PI:bilinear=0" -map 0:1 -c:v libx264 -crf 26 "%PinballX_Path%\Media\Future Pinball\Table Videos\%description%.f4v",,UseErrorLevel
Run, ffmpeg -y -i "%A_ScriptDir%\bg.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "%PinballX_Path%\Media\Future Pinball\Backglass Videos\%description%.f4v",,UseErrorLevel
If DMD_width > 0
Run, ffmpeg -y -i "%A_ScriptDir%\dmd.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "%PinballX_Path%\Media\Future Pinball\DMD Videos\%description%.f4v",,UseErrorLevel
}
Else
{
Run, ffmpeg -y -i "%A_ScriptDir%\playfield.mkv" -ss 5 -to 65 -vf "rotate=PI:bilinear=0" -map 0:0 -c:v libx264 -crf 26 "%PinballX_Path%\Media\Visual Pinball\Table Videos\%description%.f4v",,UseErrorLevel
Run, ffmpeg -y -i "%A_ScriptDir%\bg.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "%PinballX_Path%\Media\Visual Pinball\Backglass Videos\%description%.f4v",,UseErrorLevel
If DMD_width > 0
Run, ffmpeg -y -i "%A_ScriptDir%\dmd.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "%PinballX_Path%\Media\Visual Pinball\DMD Videos\%description%.f4v",,UseErrorLevel
}
Process, WaitClose, ffmpeg.exe
; Clean up
FileDelete, %A_ScriptDir%\playfield.mp4
FileDelete, %A_ScriptDir%\playfield.mkv
FileDelete, %A_ScriptDir%\bg.mkv
If DMD_width > 0
FileDelete, %A_ScriptDir%\dmd.mkv
ExitApp

FuturePinballOBS.zip

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...