Carny_Priest

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

Recommended Posts

Carny_Priest    205

This is part proof of concept and part feature request.

The following script starts a user defined Visual Pinball table and captures up to three videos -

1. Table

2. Backglass

3. DMD

Parameters for the capture are read from the user's ScreenRes.txt file.

Output files are saved in the appropriate Media/Visual Pinball folder.

This assumes that Visual Pinball is in the default installation path "Program Files (x86)" and PinballX is in the default installation path on the C drive. Change the script as needed.

The script is using an experimental version of VPinball990. Change the executable in the script as needed.

The script produces video clips about 1 minute long, high quality, and size somewhere around 10 Mb or under.

Requires the Windows static build of ffmpeg which is free and open-source:

http://ffmpeg.zeranoe.com/builds/

I would use this to capture the attract mode sequence, but it is certainly possible to capture in-play.

As the script captures playfield, backglass, and DMD simultaneously, the sequences should be synced. If a DMD area is not defined in ScreenRes.txt then the script assumes the configuration is two screen and no DMD area is captured.

Output file names match the VP table name. In my database, I use the same VP table name as the "game name" field. So, PinballX will pick up and display these videos without any further renaming required.

The benefit is that the user no longer needs to rely on others to upload media, and that the resulting output best reflects the user's specific table configuration (e.g., layback settings, offset, graphic mods, DMD colorization, 2 screen or 3 screen B2S).

If you have a three screen cab, there is typically no B2S LED alpha-numeric displays uploaded on our favorite sites. This will capture a video of the B2S LED for those tables.

One warning, ffmpeg's built-in gdigrab device is video only, no audio. I have my settings.ini set-up to mute sound in videos anyway because that is my preference. It should be possible to add sound if not with gdigrab then with another DirectShow-based screen capture device like Screen Capturer Recorder.

#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 VP
StringTrimRight, XTable, Table, 4 ;Trim ".vpt" for output file name
Run, "c:\Program Files (x86)\Visual Pinball\vpinball-9_9-accelmod-8-20-2014.exe" -play "c:\Program Files (x86)\Visual Pinball\Tables\%Table%",,UseErrorLevel
Process, wait, vpinball-9_9-accelmod-8-20-2014.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 -pix_fmt yuv420p -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 -pix_fmt yuv420p -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 -pix_fmt yuv420p -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 vpinball-9_9-accelmod-8-20-2014.exe /F,,UseErrorLevel
; 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 "C:\PinballX\Media\Visual Pinball\Table Videos\%XTable%.f4v",,UseErrorLevel
Run, ffmpeg -y -i "%A_ScriptDir%\bg.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "C:\PinballX\Media\Visual Pinball\Backglass Videos\%XTable%.f4v",,UseErrorLevel
If DMD_width > 0
Run, ffmpeg -y -i "%A_ScriptDir%\dmd.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "C:\PinballX\Media\Visual Pinball\DMD Videos\%XTable%.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
ExitApp

Assuming you compile the script as CapScreensCab.exe. The command would be:

CapScreenCab.exe "tablefilename"

with tablefilename including the vpt extension

This can be fairly easily modified to capture Future Pinball/FutureDMD media as well, I believe. In the end, for ease of use the functionality is probably much better integrated fully into PinballX. So, that's a feature that I'd like to see as the script demonstrates that it is very doable.

EDIT - Not Future Pinball, I'm working on another script for that.

  • Like 7

Share this post


Link to post
Share on other sites
rockyrocket    121

Just want to say thanks again for showcasing ffmpeg carny as it is a very powerful tool.

Used a couple of variations of the script today to record just the playfield with audio and rotate to the correct orientation.

For a standard landscape set up I found the script below worked great.

s::; Fastest CaptureRun, ffmpeg -t 70 -rtbufsize 1500M -f dshow -i video="screen-capture-recorder":audio="virtual-audio-capturer" -vcodec libx264 -preset ultrafast -threads 8 playfield.mkv,,Hide UseErrorLevel Process, WaitClose, ffmpeg.exe, 70Sleep 1000; Post Capture Trim and TranscodeRun, ffmpeg -y -i "%A_ScriptDir%\playfield.mkv" -ss 5 -to 65 -vf "rotate=PI:bilinear=0" -c:v libx264 -crf 26 "%A_ScriptDir%\PFCapture.mp4,,UseErrorLevel Process, WaitClose, ffmpeg.exe ; Clean upFileDelete, %A_ScriptDir%\playfield.mkv ExitApp

And for recording when the screen is in portrait mode (android ect) you only need to rotate 90° ..

s::; Fastest CaptureRun, ffmpeg -t 70 -rtbufsize 1500M -f dshow -i video="screen-capture-recorder":audio="virtual-audio-capturer" -vcodec libx264 -preset ultrafast -threads 8 playfield.mkv,,Hide UseErrorLevel Process, WaitClose, ffmpeg.exe, 70Sleep 1000; Post Capture Trim and TranscodeRun, ffmpeg -y -i "%A_ScriptDir%\playfield.mkv" -ss 5 -to 65 -vf "transpose=1" -c:v libx264 -crf 26 "%A_ScriptDir%\PFCapture.mp4,,UseErrorLevel Process, WaitClose, ffmpeg.exe ; Clean upFileDelete, %A_ScriptDir%\playfield.mkv ExitApp

Of course you still need to manually rename with this method but it is pretty universal.

Share this post


Link to post
Share on other sites
Carny_Priest    205

Good stuff. I don't know the native format for audio using "virtual-audio-capturer". If the output file size is large, there may be an an opportunity to use ffmpeg's built in audio codecs to compress the audio track with good quality in the transcode step.

One of these days, I'll work on a variation for Future Pinball/FutureDMD.

Share this post


Link to post
Share on other sites
chernandez    0

Carny

I've been trying to get this script to work for me but i keep getting an error when vp loads up

when vp loads up it gives me a load error box and say cant load C:\program files (86)\visual pinball\ tables\and the table name that i put in

I only changed the script with Vpinball.exe over the one you had in there.

Any ideas of what i should try

thanks

Chris

Share this post


Link to post
Share on other sites
Carny_Priest    205

The VP path name in your table has a space in front of "tables". I assume that is a typo?

The entire path for the executable is within quotes?

The entire path for the table is within quotes?

You are using the play parameter correctly? Should have "-play". It should not be missing or just "play".

When you execute the script from the command line are you adding the full table name to the command?

CapScreenCab.exe [tablefilename]

Tablefilename should be a table that exists in your tables folder and you need to use the full file name including ".vpt"

Still not working? Run VP as administrator.

Share this post


Link to post
Share on other sites
chernandez    0

ok heres the script i used


#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 VP
StringTrimRight, XTable, Table, 4 ;Trim ".vpt" for output file name

Run, "c:\Program Files (x86)\Visual Pinball\VPinball.exe" -play "c:\Program Files (x86)\Visual Pinball\Tables\%Table%",,UseErrorLevel
Process, wait, VPinball.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 -pix_fmt yuv420p -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 -pix_fmt yuv420p -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 -pix_fmt yuv420p -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 VPinball.exe /F,,UseErrorLevel

; 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 "C:\PinballX\Media\Visual Pinball\Table Videos\%XTable%.f4v",,UseErrorLevel
Run, ffmpeg -y -i "%A_ScriptDir%\bg.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "C:\PinballX\Media\Visual Pinball\Backglass Videos\%XTable%.f4v",,UseErrorLevel
If DMD_width > 0
Run, ffmpeg -y -i "%A_ScriptDir%\dmd.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "C:\PinballX\Media\Visual Pinball\DMD Videos\%XTable%.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

ExitApp

and heres what i get when i run command

Share this post


Link to post
Share on other sites
Carny_Priest    205

The name of your file is [avatar (stern)].vpt? With the brackets? The load error is because VP is not finding that file in your Tables folder, I think. The editor is open but it could not find the table to load.

Is it simply avatar (stern).vpt?

Sorry, I think I confused you by putting in brackets in my example, but what I mean is that you just reference the file name as it appears in your Tables folder.

Try entering the following:

capscreencab.exe "avatar (stern).vpt"

The quotes will be needed because the file name has spaces in it.

EDIT - changed the original post to reflect that the table name should be in quotes.

Share this post


Link to post
Share on other sites
rockyrocket    121

Just played with this a bit more on some other systems with mixed results.

First the good it (Ffmpeg) worked great with ...

- Visual Pinball (obviously)

- Unity3D Pinball

- Bluestacks.

But failed to capture...

- Future Pinball

- Pinball FX2

- Pinball Arcade

In most cases the windows desktop was recorded and not the game itself.

This may not be conclusive as I do not claim to be any kind of expert on this at all - maybe you can define what layer is recorded?.

All tests were done outside of PinballX from the cmdline.

Really the only one I would like to see work is FP - wonder if FRAPS works from CMD?

Share this post


Link to post
Share on other sites
Carny_Priest    205

Ah, I had not tested with FP. I have had mixed results with applications that display in full screen rather than windowed, full screen.

I had to work around this issue to mirror the DMD for SlamIt: Big Score. There was a way to force it to windowed full screen through a combination of game settings and scripting.

I'm not sure that there is a way to do something similar for FP.

Another test would include VP 9.21 running in full screen.

Share this post


Link to post
Share on other sites
chernandez    0

Carny

i have pf recording right but on my bg it records my dmd and half of bg and on my dmd it records part of bg

my screenres.txt files is

1920

1080

1920

1080

3

0

0

1012

432

1927

73

0

i used bigboss's setdmd not sure if that would effect it

do you have any ideas

thanks

chris

Share this post


Link to post
Share on other sites
Carny_Priest    205

What settings do you use for SetDMD?

Do you have your screen set up in the usual recommended way?

That's DMD (screen 3) located to the right of the BG (screen 2) which in turn is located to the right of the playfield (Screen 1). The tops of each screen are aligned on y=0.

Share this post


Link to post
Share on other sites
chernandez    0

What settings do you use for SetDMD?

Do you have your screen set up in the usual recommended way?

That's DMD (screen 3) located to the right of the BG (screen 2) which in turn is located to the right of the playfield (Screen 1). The tops of each screen are aligned on y=0.

Damn your good

i had dmd next to pf switch around now it record them right

now my only issue is some lag in video so i going to try to record them separate

thanks

chris

Share this post


Link to post
Share on other sites
Carny_Priest    205

Lag?

Having three captures at once probably does take a lot of resources. The PC in my cab is a dedicated machine. I don't have anything else running in the background. I exit out of PinballX and run this from the command line.

Another alternative is to try lowering the frame rate to 25 or even 20. If not for all three captures then perhaps for the BG especially if it is not a particularly active one.

Can also experiment with lowering the value for rtbufsize (real time buffer size), but I don't know that it will help performance.

  • Like 1

Share this post


Link to post
Share on other sites
Carny_Priest    205

Just played with this a bit more on some other systems with mixed results.

First the good it (Ffmpeg) worked great with ...

- Visual Pinball (obviously)

- Unity3D Pinball

- Bluestacks.

But failed to capture...

- Future Pinball

- Pinball FX2

- Pinball Arcade

In most cases the windows desktop was recorded and not the game itself.

This may not be conclusive as I do not claim to be any kind of expert on this at all - maybe you can define what layer is recorded?.

All tests were done outside of PinballX from the cmdline.

Really the only one I would like to see work is FP - wonder if FRAPS works from CMD?

Tested with Fullscreen VP v9.21, and didn't have any issues capturing screens with the original script.

I do have a potential solution for FP. At least, I've got something that passed some command line tests with Pinball FX2. Unfortunately, I can't test with Future Pinball. I've disassembled my cab to work on hardware, and I don't have Future Pinball installed on my test bed.

Without the cab, I don't recall the exact settings for Future Pinball + BAM + FutureDMD, the process names, Window titles, etc. So some corrections may be needed with the following script.

Otherwise, the only difference is that I am disabling Aero prior to the capture if it is Enabled by default. The script only turns Aero back on if Aero was on at the start. In my cab, I disabled Aero along with all other visual enhancements for whatever gain in performance I could get for running pinball. I don't want to inadvertently turn Aero back on. Give it a try; hopefully this will work. Turning off Aero is a trick for Vista and Windows 7. I don't know what to do for Windows 8. I don't have it.

#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:\Games\Future Pinball\BAM\fploader.exe" /open "-play "c:\Games\Future Pinball\Tables\%Table%" /play /exit /arcaderender /STAYINRAM,,UseErrorLevel
Process, wait, Future Pinball.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 -pix_fmt yuv420p -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 -pix_fmt yuv420p -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 -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, 70
Sleep 5000
Run, taskkill /IM Future Pinball.exe /F,,UseErrorLevel
; 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 "C:\PinballX\Media\Future Pinball\Table Videos\%XTable%.f4v",,UseErrorLevel
Run, ffmpeg -y -i "%A_ScriptDir%\bg.mkv" -ss 5 -to 65 -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 5 -to 65 -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.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

Share this post


Link to post
Share on other sites
rockyrocket    121

Thanks carny for trying for me, still black screen though with aero disabled.

Dtoxy or fraps work well with future pinball so we do at least have options - dtoxy is especially powerful.

The list of things that do work with Ffmpeg can now include Bigscore and TPA if you set it to full screen windowed (although I have now uninstalled it ).

Share this post


Link to post
Share on other sites
Carny_Priest    205

That's too bad for FP. I was looking for free options for simultaneous capture of all three displays. Even better if those solutions did not require extra run time environments, installers, etc. And that can also be easily called in a script to automate the task.

Other alternatives could be UScreenCapture. I think there may be a mod that overcomes the black screen. There is possibly Open Broadcaster Software but I haven't researched it.

If you have a recent NVidia card there is also ShadowPlay. I have used it to capture Pinball FX2 but I have not tried with FP. There would be no simultaneous capture of 3 screens. But if you could capture the entire desktop then you could use ffmpeg to parse out a Playfield, BG, and DMD video in separate transcodes.

Share this post


Link to post
Share on other sites
shifters67    9

Hi Carny_Priest,

I would like to put a little build on this if i may to your awesome work - the video quality is great, small, and exactly matches your tables of course!!!

I use only directB2S and B2S tables so in order to get the videos, do away with the images for table/bg/dmd i decided to render the entire contents of my VP tables directory using the following piece of simple python (2.7).

It reads the VP tables directory, and then runs capscreencab.exe on each file ending in .vpt.

__author__ = 'shifters'

import os
import shutil


src = 'c:\program files (x86)\Visual Pinball\Tables'

if __name__ == '__main__':

# get a list of the directory names
names = os.listdir(src)

print "Found: ", names

# check all the folders for sub folders and move up to current level and rename in progress
for name in names:
print "Checking: ", name
print "ext ", name[-4:]
if name[-4:] == ".vpt":
print "Rendering: ", name
os.system('CapScreenCab.exe \"' + name + '\"')

I also used a slightly modified version of your script - tailored to my layout, processing speed etc


#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

; my change to capture dmd in correct place
XDMD_X:=3200 ;Reference to Top Left of Playfield screen

Table = %1% ;Variable from VP
StringTrimRight, XTable, Table, 4 ;Trim ".vpt" for output file name

Run, "c:\Program Files (x86)\Visual Pinball\VPinball990.exe" -play "c:\Program Files (x86)\Visual Pinball\Tables\%Table%",,UseErrorLevel
Process, wait, VPinball990.exe

Sleep, 20000 ; 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 -pix_fmt yuv420p -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 -pix_fmt yuv420p -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 -pix_fmt yuv420p -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 VPinball990.exe /F,,UseErrorLevel

; 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 "C:\PinballX\Media\Visual Pinball\Table Videos\%XTable%.f4v",,UseErrorLevel
Run, ffmpeg -y -i "%A_ScriptDir%\bg.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "C:\PinballX\Media\Visual Pinball\Backglass Videos\%XTable%.f4v",,UseErrorLevel
If DMD_width > 0
Run, ffmpeg -y -i "%A_ScriptDir%\dmd.mkv" -ss 5 -to 65 -c:v libx264 -crf 26 "C:\PinballX\Media\Visual Pinball\DMD Videos\%XTable%.f4v",,UseErrorLevel

;Process, WaitClose, ffmpeg.exe
Sleep 70000

; Clean up
FileDelete, %A_ScriptDir%\playfield.mkv
FileDelete, %A_ScriptDir%\bg.mkv
If DMD_width > 0
FileDelete, %A_ScriptDir%\dmd.mkv

ExitApp

And hey presto - all BG/DMD/table vides created. I am so impressed with the quality for the size they are!

I finally went into the DMD videos folder and delete all files 74KB in size which are tables with no DMD to display for the video to capture. This allows your default DMD graphic to display which for me is a custom one, so for those tables with no DMD video (as they have no dmd) i get my custom graphic - nice!!

regards

Shifters

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now