Program to Launch Commands

Status
Not open for further replies.

Arindrew

Ars Scholae Palatinae
1,341
Where I work, we have a batch file that launches a couple dozen VLC windows, and places them around the screen so we can watch streamed video from various sources. For reasons we cant figure out, sometimes a few of the streams don't show up and we have to relaunch them all again. Sometimes this works, sometimes other streams decide not to work that time - so we just keep trying until they all come up.

Instead of starting over each time, I am looking for a program where I can launch each VLC window (with tags and all) individually if needed. Maybe something like have a check box next to each line and I just select the ones I would like to launch.

I know this is pretty specific, and not sure if something like this already exists. Would this be difficult to make? I was thinking something simple like a vbscript or something. I have no programming experience at all, but if its something that is going to be pretty easy with a script, I might be able to delve into it enough to get something running sufficiently.
 

DebtAngel

Ars Scholae Palatinae
1,027
Some simple refactoring of the batch scripts seems like it would do the trick:
  • Create one batch file for each of the streams
  • Create a "start" batch file that runs each of the "single stream" batch files
  • Run the single stream batch file for each of the streams that doesn't open properly

Name each of the batch files something obvious, and I don't see why you would need a menu system at all. Put shortcuts in the Start menu if you really want to.
 

ronelson

Ars Legatus Legionis
21,399
Subscriptor
# Create one batch file for each of the streams
# Create a "start" batch file that runs each of the "single stream" batch files
# Run the single stream batch file for each of the streams that doesn't open properly
# Have said batch file launch a menu/GUI when complete that allows a single key-press or mouse-click to restart a window. Much better than having to find the script that corresponds to the top right window.


Also, if the batch file that exists was written properly, you might be able to pass it an arg to restart a certain window. Impossible to tell without looking at the script, though.
 

Arindrew

Ars Scholae Palatinae
1,341
Here is the beginning of the batch file, with the first stream. There are about twenty or so other streams below, and they are all the same, just with a different position and different IP.
Code:
@echo off

taskkill /f /im vlc.exe

start "" "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I rc --rc-quiet --no-video-title-show --width 460 --height 315 --video-x 6 --video-y 10 --video-title=BLAH udp://@225.1.1.1:8208

I don't want to have to create 30ish individual batch files and manually launch each one. Is there a better way to write this batch file than the simple way we have it?
 

MooseAreFun

Ars Legatus Legionis
10,827
Subscriptor
I think for a quick solution, I would make a copy of vlc.exe per stream called vlc1.exe, vlc2.exe, etc.

Then each line in the batch file can become:

Code:
tasklist /NH /FI "IMAGENAME eq vlc1.exe" | find /I "vlc1.exe"
IF ERRORLEVEL 1 start "" "...vlc1.exe" --options --n --stuff

tasklist /NH /FI "IMAGENAME eq vlc2.exe" | find /I "vlc2.exe"
IF ERRORLEVEL 1 start "" "...vlc2.exe" --options --n --stuff

That's not what I'd actually do, I'd probably play with AutoScript or Python and try and get it looping and all sorts. But that should work to automatically just start the missing ones.
 

devjames

Wise, Aged Ars Veteran
107
Arindrew":9fwt804l said:
Here is the beginning of the batch file, with the first stream. There are about twenty or so other streams below, and they are all the same, just with a different position and different IP.
Code:
@echo off

taskkill /f /im vlc.exe

start "" "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I rc --rc-quiet --no-video-title-show --width 460 --height 315 --video-x 6 --video-y 10 --video-title=BLAH udp://@225.1.1.1:8208

I don't want to have to create 30ish individual batch files and manually launch each one. Is there a better way to write this batch file than the simple way we have it?

If I knew the relationships between windows (the grid, or the placement rules) I could do some math and probably reduce this to a few lines.

Given what I have, however, "a couple dozen VLC windows" would fit a largish-monitor in a 6 wide x 4 high pattern with the dimensions of the first start command you gave. So, I assumed such a grid. Then I named the VLC's 1-1 through 4-6 in a row-column convention.

So, the worst case scenario would be something like the below. You could call this with filename.cmd all, filename.cmd 1-1 1-3 2-4, or any combination of the row and window number (which I've assumed is 6x4). Calling it with just filename.cmd is the same as calling it with all.

Yeah, I just realized that 6x4 is column,row and my naming convention is row-column, sorry.

Also, you need a little error checking right after the call:%1 to make sure it works, but this is all a bit rough anyway as I'm at my linux box and not my windows box, so I can't test this. If you need more help post again and I'll try to help more. If you care to disclose enough of the script so that I can discover the grid pattern, or you disclose the pattern itself, I could probably shorten this up.

If you don't change the title of each vlc instance then you could remove BLAH from :1-1 through :4-6, remove %5 from the :startvlc section and renumber :6 to :5.

Anyway, enough talk. The example.

Code:
::@echo off
::  remove this line and the :: of the line above when it works.

setlocal enableextensions enabledelayedexpansion

if /i [%1]==[] call :all
goto :ender

:looper
if /i [%1]==[] goto :ender
call :%1
shift
goto :looper

:all

taskkill /f /im vlc.exe

call :1-1
call :1-2
call :1-3
call :1-4
call :1-5
call :1-6
call :2-1
call :2-2
call :2-3
call :2-4
call :2-5
call :2-6
call :3-1
call :3-2
call :3-3
call :3-4
call :3-5
call :3-6
call :4-1
call :4-2
call :4-3
call :4-4
call :4-5
call :4-6
goto :eof

:1-1
call :startvlc 460 315 6 10 BLAH 225.1.1.1:8208
goto :eof

:1-2
:: repeat pattern for the rest
goto :eof

:startvlc
start "" "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I rc --rc-quiet --no-video-title-show --width %1 --height %2 --video-x %3 --video-y %4 --video-title=%5 udp://@%6
goto :eof

:ender
endlocal

edit: documentation, misspelling, forgot the shift command.
 

Arindrew

Ars Scholae Palatinae
1,341
Here is more of the file. What I have pasted below was designed for 4 videos horizontal and 3 videos vertical for a total of 12 videos. We needed more per screen, so its modified to 4x4 for a total of 16 videos. Each video can come from a possibility of two sources. The same video from the two sources are in the same position on the screen. So with 16 videos, coming from possibly both sources at the same time, a total of 32, but this is rare. We usually run in the teens. Enough talk, here are the first two sources.

Code:
start "" "C:\PATH\vlc.exe" -I rc --rc-quiet --no-video-title-show --width 460 --height 315 --video-x 6 --video-y 10 --video-title=Video1a udp://@IP:8208
start "" "C:\PATH\vlc.exe" -I rc --rc-quiet --no-video-title-show --width 460 --height 315 --video-x 6 --video-y 10 --video-title=Video1b udp://@IP:8209

start "" "C:\PATH\vlc.exe" -I rc --rc-quiet --no-video-title-show --width 460 --height 315 --video-x 489 --video-y 10 --video-title=Video2a udp://@IP:8208
start "" "C:\PATH\vlc.exe" -I rc --rc-quiet --no-video-title-show --width 460 --height 315 --video-x 489 --video-y 10 --video-title=Video2b udp://@IP:8209

I think that latest script would still work, but just wanted to verify now that you have more information about the rest of our script.
 

ronelson

Ars Legatus Legionis
21,399
Subscriptor
Have you looked into something like WinSplit (http://www.winsplit-revolution.com/)? Seems like it would solve your problems for you.

I stumbled upon when thinking of those "look how I made Windows 7" commercials where they showed some tiling, but it looks like you can only do horizontal or vertical, not both at the same time. Lame.
 

devjames

Wise, Aged Ars Veteran
107
Arindrew":320kao7k said:
Code:
start "" "C:\PATH\vlc.exe" -I rc --rc-quiet --no-video-title-show --width 460 --height 315 --video-x 6 --video-y 10 --video-title=Video1a udp://@IP:8208
start "" "C:\PATH\vlc.exe" -I rc --rc-quiet --no-video-title-show --width 460 --height 315 --video-x 6 --video-y 10 --video-title=Video1b udp://@IP:8209

start "" "C:\PATH\vlc.exe" -I rc --rc-quiet --no-video-title-show --width 460 --height 315 --video-x 489 --video-y 10 --video-title=Video2a udp://@IP:8208
start "" "C:\PATH\vlc.exe" -I rc --rc-quiet --no-video-title-show --width 460 --height 315 --video-x 489 --video-y 10 --video-title=Video2b udp://@IP:8209

I think that latest script would still work, but just wanted to verify now that you have more information about the rest of our script.

Thanks. I made more assumptions, though.

I also buried up most of my assumptions as variables you can play with setting in the code.

To get this to work for you you will have to change the values in the :returnip subroutine. I don't have the resources to duplicate your environment, so I made do with the ECHO statement output the script provides. You will also have to change the vlcpath environment variable to match your install location.

If you have questions, ask. If you think about changing random things, be careful. Batch scripts are quite picky about obtuse formatting requirements. You have been warned. ;)

Code:
Find corrected code a couple of posts below.  Bugs, don'tcha know.

Use cases:
Code:
C:\data\batch>startmonitor h
Usage is startmonitor [?|/?|-?|h|-h|/h|help] - show this help
         startmonitor                        - show all sources
         startmonitor source [source [...]]  - show a specific source
 Source varies from 1 to 16
 Note that each use of the same source will create
      1 or 2 windows at that position on the screen.

 Configured sources are:
  numericsourceid 1 IP 127.0.0.1 serving 2 stream[s]
  numericsourceid 2 IP 127.0.0.2 serving 2 stream[s]
  numericsourceid 3 IP 127.0.0.3 serving 2 stream[s]
  numericsourceid 4 IP 127.0.0.4 serving 2 stream[s]
  numericsourceid 5 IP 127.0.0.5 serving 2 stream[s]
  numericsourceid 6 IP 127.0.0.6 serving 2 stream[s]
  numericsourceid 7 IP 127.0.0.7 serving 2 stream[s]
  numericsourceid 8 IP 127.0.0.8 serving 2 stream[s]
  numericsourceid 9 IP 127.0.0.9 serving 2 stream[s]
  numericsourceid 10 IP 127.0.0.10 serving 2 stream[s]
  numericsourceid 11 IP 127.0.0.11 serving 2 stream[s]
  numericsourceid 12 IP 127.0.0.12 serving 2 stream[s]
  numericsourceid 13 IP 127.0.0.13 serving 2 stream[s]
  numericsourceid 14 IP 127.0.0.14 serving 2 stream[s]
  numericsourceid 15 IP 127.0.0.15 serving 2 stream[s]
  numericsourceid 16 IP 127.0.0.16 serving 2 stream[s]

Code:
C:\data\batch>startmonitor
Starting source 1a with --video-x 489 --video-y 10 --upd://@127.0.0.1:8208
Starting source 1b with --video-x 489 --video-y 10 --upd://@127.0.0.1:8209
Starting source 2a with --video-x 972 --video-y 10 --upd://@127.0.0.2:8208
Starting source 2b with --video-x 972 --video-y 10 --upd://@127.0.0.2:8209
Starting source 3a with --video-x 1455 --video-y 10 --upd://@127.0.0.3:8208
Starting source 3b with --video-x 1455 --video-y 10 --upd://@127.0.0.3:8209
Starting source 4a with --video-x 6 --video-y 345 --upd://@127.0.0.4:8208
Starting source 4b with --video-x 6 --video-y 345 --upd://@127.0.0.4:8209
Starting source 5a with --video-x 489 --video-y 345 --upd://@127.0.0.5:8208
Starting source 5b with --video-x 489 --video-y 345 --upd://@127.0.0.5:8209
Starting source 6a with --video-x 972 --video-y 345 --upd://@127.0.0.6:8208
Starting source 6b with --video-x 972 --video-y 345 --upd://@127.0.0.6:8209
Starting source 7a with --video-x 1455 --video-y 345 --upd://@127.0.0.7:8208
Starting source 7b with --video-x 1455 --video-y 345 --upd://@127.0.0.7:8209
Starting source 8a with --video-x 6 --video-y 680 --upd://@127.0.0.8:8208
Starting source 8b with --video-x 6 --video-y 680 --upd://@127.0.0.8:8209
Starting source 9a with --video-x 489 --video-y 680 --upd://@127.0.0.9:8208
Starting source 9b with --video-x 489 --video-y 680 --upd://@127.0.0.9:8209
Starting source 10a with --video-x 972 --video-y 680 --upd://@127.0.0.10:8208
Starting source 10b with --video-x 972 --video-y 680 --upd://@127.0.0.10:8209
Starting source 11a with --video-x 1455 --video-y 680 --upd://@127.0.0.11:8208
Starting source 11b with --video-x 1455 --video-y 680 --upd://@127.0.0.11:8209
Starting source 12a with --video-x 6 --video-y 1015 --upd://@127.0.0.12:8208
Starting source 12b with --video-x 6 --video-y 1015 --upd://@127.0.0.12:8209
Starting source 13a with --video-x 489 --video-y 1015 --upd://@127.0.0.13:8208
Starting source 13b with --video-x 489 --video-y 1015 --upd://@127.0.0.13:8209
Starting source 14a with --video-x 972 --video-y 1015 --upd://@127.0.0.14:8208
Starting source 14b with --video-x 972 --video-y 1015 --upd://@127.0.0.14:8209
Starting source 15a with --video-x 1455 --video-y 1015 --upd://@127.0.0.15:8208
Starting source 15b with --video-x 1455 --video-y 1015 --upd://@127.0.0.15:8209
Starting source 16a with --video-x 6 --video-y 1350 --upd://@127.0.0.16:8208
Starting source 16b with --video-x 6 --video-y 1350 --upd://@127.0.0.16:8209

Code:
C:\data\batch>startmonitor 1 3 5
Starting video source id 1
Starting source 1a with --video-x 489 --video-y 10 --upd://@127.0.0.1:8208
Starting source 1b with --video-x 489 --video-y 10 --upd://@127.0.0.1:8209
Starting video source id 3
Starting source 3a with --video-x 1455 --video-y 10 --upd://@127.0.0.3:8208
Starting source 3b with --video-x 1455 --video-y 10 --upd://@127.0.0.3:8209
Starting video source id 5
Starting source 5a with --video-x 489 --video-y 345 --upd://@127.0.0.5:8208
Starting source 5b with --video-x 489 --video-y 345 --upd://@127.0.0.5:8209

Code:
C:\data\batch>startmonitor 300
Starting video source id 300
300 would be on row 75, max row is 4

Code:
C:\data\batch>startmonitor 1 bob 2 carol 4 ted 7 alice 300
Starting video source id 1
Starting source 1a with --video-x 489 --video-y 10 --upd://@127.0.0.1:8208
Starting source 1b with --video-x 489 --video-y 10 --upd://@127.0.0.1:8209
Starting video source id bob
bob is not a valid source - 1 to 16
Starting video source id 2
Starting source 2a with --video-x 972 --video-y 10 --upd://@127.0.0.2:8208
Starting source 2b with --video-x 972 --video-y 10 --upd://@127.0.0.2:8209
Starting video source id carol
carol is not a valid source - 1 to 16
Starting video source id 4
Starting source 4a with --video-x 6 --video-y 345 --upd://@127.0.0.4:8208
Starting source 4b with --video-x 6 --video-y 345 --upd://@127.0.0.4:8209
Starting video source id ted
ted is not a valid source - 1 to 16
Starting video source id 7
Starting source 7a with --video-x 1455 --video-y 345 --upd://@127.0.0.7:8208
Starting source 7b with --video-x 1455 --video-y 345 --upd://@127.0.0.7:8209
Starting video source id alice
alice is not a valid source - 1 to 16
Starting video source id 300
300 would be on row 75, max row is 4

As you can see, it does the best that it can to start _something_ and it will always put a source id in the same spot on the screen, so you can use it to fill in holes.

Also, I only typed in the taskkill command in this message. You might check the syntax, I didn't know about that command before. I like it, thanks.

I also didn't see what good the start command did for vlc, since it releases its hold on the terminal (here, anyway). If you need it edit those two %vlcpath% lines.

good luck!

EDIT: removed an initilization of dynamicoptsa and dynamicoptsb just before the call :returnip. It didn't hurt anything by being there because it was reinitialized to correctness later, but it was stupid. Sorry.

EDIT2: Removed code in this post for corrected version, in a later post.
 

devjames

Wise, Aged Ars Veteran
107
Fixed.

Also found out why you use the 'start' command. I made start's window title 'Source ID x (a)' or (b), so that you can easily tell which one to re-run.

Fixed version, all the use cases now show the correct vlc video title. I won't post them again.
(My leading spaces for most or all lines are gone in the post, but there in the post edit box. It should work, but I had formatted it better.)

Code:
@echo off

:: do this because registry settings can default these off.  see 'cmd.exe /?'
setlocal enableextensions enabledelayedexpansion

:: These are used in usage info.
set maxcols=4
set maxrows=4
set /a maxsources= (maxrows * maxcols) - 1
set vidip=
set numports=

set sourcecmd=%1
set showhelp=no
if /i [%sourcecmd:~-1%]==[?] set showhelp=yes
if /i [%sourcecmd:~-1%]==[h] set showhelp=yes
if /i [%sourcecmd%]==[help] set showhelp=yes
if /i not [%showhelp%]==[yes] goto initializer
echo Usage is %0 [?^|/?^|-?^|h^|-h^|/h^|help] - show this help
echo          %0                        - show all sources
echo          %0 source [source [...]]  - show a specific source
echo  Source varies from 0 to %maxsources%
echo  Note that each use of the same source will create
echo       1 or 2 windows at that position on the screen.
echo.
echo  Configured sources are:
for /l %%i in (0,1,%maxsources%) do (
 call :returnip %%i
 echo   numericsourceid %%i IP !vidip! serving !numports! stream[s]
)
goto ender

:initializer
:: The full path and file name of vlc on your system, in quotes.
set vlcpath="c:\program files\videolan\vlc\vlc.exe"

:: Supplied width and height
set vlcwidth=460
set vlcheight=315

:: Static vlc opts for all vlc.exe invocations.
set staticopts=-I rc --rc-quiet --no-video-title-show
set staticopts=%staticopts% --width %vlcwidth% --height %vlcheight%

:: Some random arsian's wild guess at vlc video window border values.
set lborder=6
set rborder=17
set tborder=10
set bborder=10

:: handle the special case of no argument starts them all.
if [%sourcecmd%]==[] (
 taskkill /f /im vlc.exe >nul 2>&1
 for /l %%i in (0,1,%maxsources%) do call :start1vlc %%i
 goto ender
)

:looper
:: Anything else is assumed to be a valid source and we'll
:: catch it later in start1vlc.
if [%sourcecmd%]==[] goto ender
echo Starting video source id %sourcecmd%
call :start1vlc %sourcecmd%
shift
set sourcecmd=%1
goto looper

:start1vlc
:: Call start1vlc with numericsourceid
 set numericsourceid=%1
 set vlcrow=0
 set vlccol=0
 set /a vlcrow=numericsourceid / maxcols
 if %vlcrow% GTR %maxrows% (
  echo %numericsourceid% would be on row %vlcrow%, max row is %maxrows%
  goto :eof
 )
 set /a "vlccol=numericsourceid %% maxcols"
 set /a videox=(lborder * (vlccol + 1)) + ((vlcwidth + rborder) * vlccol)
 set /a videoy=(tborder * (vlcrow + 1)) + ((vlcheight + bborder) * vlcrow)
 set /a vlctitleid=numericsourceid + 1
 set dynamicopts=--video-x %videox% --video-y %videoy%
 set dynamicoptsa=%dynamicopts% --video-title=Video%vlctitleid%a
 set dynamicoptsb=%dynamicopts% --video-title=Video%vlctitleid%b
 call :returnip %numericsourceid%
 if [%vidip%]==[] (
  echo %numericsourceid% is not a valid source - 0 to %maxsources%
  goto :eof
 )
 set dynamicoptsa=%dynamicoptsa% --upd://@%vidip%:8208
 set dynamicoptsb=%dynamicoptsb% --upd://@%vidip%:8209

 echo Starting source %numericsourceid% a with %dynamicoptsa%
 start "Source ID %numericsourceid% a" %vlcpath% %staticopts% %dynamicoptsa%
if [%numports%]==[2] (
 echo Starting source %numericsourceid% b with %dynamicoptsb%
 start "Source ID %numericsourceid% b" %vlcpath% %staticopts% %dynamicoptsb%
)
goto :eof

:returnip
:: Call returnip with a video source number.
:: This must be set up for the whole thing to work.
:: Each video source number corresponds to the IP address
:: and the number of source ports at that IP address.
 set vidip=
 set numports=
 if [%1]==[0] set vidip=127.0.0.1&& set numports=2
 if [%1]==[1] set vidip=127.0.0.2&& set numports=2
 if [%1]==[2] set vidip=127.0.0.3&& set numports=2
 if [%1]==[3] set vidip=127.0.0.4&& set numports=2
 if [%1]==[4] set vidip=127.0.0.5&& set numports=2
 if [%1]==[5] set vidip=127.0.0.6&& set numports=2
 if [%1]==[6] set vidip=127.0.0.7&& set numports=2
 if [%1]==[7] set vidip=127.0.0.8&& set numports=2
 if [%1]==[8] set vidip=127.0.0.9&& set numports=2
 if [%1]==[9] set vidip=127.0.0.10&& set numports=2
 if [%1]==[10] set vidip=127.0.0.11&& set numports=2
 if [%1]==[11] set vidip=127.0.0.12&& set numports=2
 if [%1]==[12] set vidip=127.0.0.13&& set numports=2
 if [%1]==[13] set vidip=127.0.0.14&& set numports=2
 if [%1]==[14] set vidip=127.0.0.15&& set numports=2
 if [%1]==[15] set vidip=127.0.0.16&& set numports=2
goto :eof

:ender
endlocal
goto :eof

EDIT: really fixed this time. I hope. The vlc window offsets were off, it was an Obi-Wan error.
 

devjames

Wise, Aged Ars Veteran
107
ronelson":14vx181w said:
MooseAreFun":14vx181w said:
I'm not sure whether to applaud your effort and dedication, or flee from your overengineering ;).
I think the latter, but more because of whatever has got him on codeine :)

Thank you, thank you. No applause, just throw money. :)

I will agree that it is a bit wordy. ;) Only because OP expressed unfamiliarity with scripting a solution so I broke out operations in an attempt to make maintenance and bug-pinpointing a bit more straightforward and because, as with any program, 10% is real work and 90% is defending yourself against errors.

This next I ask in an inquiring and non-defensive manner: Really overengineered, and if so, how?
 

MooseAreFun

Ars Legatus Legionis
10,827
Subscriptor
If I'm reading the OP correctly, you've written a lot to solve a problem they don't have (automatically calculating size and positioning), without doing much to address the problem they do have.

They can run the script with command line arguments for the missing windows, but Arindrew says "Maybe something like have a check box next to each line and I just select the ones I would like to launch", and a bit later comments "I don't want to have to create 30ish individual batch files and manually launch each one". Since there isn't much difference between clicking to select some batchfiles and clicking to select some checkboxes, I think identifying which windows are missing and running the batch file with those window numbers will be an annoyance.

So, 'overengineered' because most of its complexity comes from solving a non-problem. (The real problem being *why* some of the windows just don't start, of course).

All IMHO, etc. I feel kind of bad saying this because of the effort you've put in and the fact that you are actually helping, but as you asked for an explanation of why I described it like that...
 

devjames

Wise, Aged Ars Veteran
107
Don't feel badly at all, I was genuinely curious and you answered.

As for what you identified as overengineering, I do completely agree. In my own terminology I "solved a different problem". Merely as a point of reference: to me overengineering is putting in additional, unnecessary complexity into solving some problem.

Upon re-reading this thread this morning I arrived at exactly your conclusions. I solved the problem my addled brain interpreted, not the one the OP defined. ;)

A long-time command line guy, I read: some way to start all vlcs; some way to start individual vlcs; sometimes re-configures number of rows, columns. I thought: admin? dunno. can install programs? dunno. batch file!; hard-code window pos like in example? nope, let the computer do the work. I saw: currently a batch file, let's modify that. Add calculation, help that prints configuration, easy 'configuraton' section (though I didn't get that down too well, too many variables in too many places).

At the very least perhaps I can remember that 'posting while codeined' should fall under the same heading as 'posting while drunk'! :) 'Twas fun, though. I did think the calculate-window-position portion pretty cool.

Thanks very much for taking the time to reply. From your postings I've gathered that you're a pretty reasonable individual, or I wouldn't have asked your opinion. :D
 

devjames

Wise, Aged Ars Veteran
107
ronelson":271iro3f said:
It does not look over-engineered to me, it is just missing a menu function that displays the list of windows and allows the user to enter 1-16 to renew one.

Hmph. Had I been thinking, 'set /p SourceCmd=' would have been my friend. :bigdumbgrin: Unfortunately it is 0-15 now, the result of my Obi-Wan error. :(

EDIT: and, of course, thanks for taking the time to comment.
 

Arindrew

Ars Scholae Palatinae
1,341
Everything seems to be working great with the above, except for two small oversights on my part. Where I mentioned that the two overlapping videos are the same picture, but from different sources: the IP on each source is also different. So would the following fix work, or would it require more rewriting:
Code:
if [%1]==[0] set vidip=127.0.0.1&& set numports=2
if [%1]==[0] set vidip=127.1.0.1&& set numports=2
if [%1]==[1] set vidip=127.0.0.2&& set numports=2
if [%1]==[1] set vidip=127.1.0.2&& set numports=2

Secondly, we have four plasma TVs hooked up to the machine, with our videos displaying on the bottom left (primary is top left). So I need to add 1080 to the Y axis on each feed. I was able to figure out where you set the coords for each window, but was unable to be able to figure out how to add it in myself.

Again, thanks for all your help!
 

devjames

Wise, Aged Ars Veteran
107
Arindrew":swmk3r7h said:
Everything seems to be working great with the above, except for two small oversights on my part. Where I mentioned that the two overlapping videos are the same picture, but from different sources: the IP on each source is also different. So would the following fix work, or would it require more rewriting:
Code:
if [%1]==[0] set vidip=127.0.0.1&& set numports=2
if [%1]==[0] set vidip=127.1.0.1&& set numports=2
if [%1]==[1] set vidip=127.0.0.2&& set numports=2
if [%1]==[1] set vidip=127.1.0.2&& set numports=2

Secondly, we have four plasma TVs hooked up to the machine, with our videos displaying on the bottom left (primary is top left). So I need to add 1080 to the Y axis on each feed. I was able to figure out where you set the coords for each window, but was unable to be able to figure out how to add it in myself.

Again, thanks for all your help!

You're very welcome, glad to be of help.

You're close on the above, but not quite. The only way for a batch file subroutine to return a value is for the caller and subroutine to use a variable that both know the name of.

So, in your example, for source 0 you'd first set vidip to the first source, then you'd set it to the second source, and only return that.

We'll introduce some new variables that make configuration slightly different. The second part (absolute x or y offset) I'll fix by introducing some absxoffset, absyoffset variables that I simply add once to the calculation of videox and videoy.

Let me make a slightly-changed, new version and post it. It'll probably even be right the first time. ;v)
 

devjames

Wise, Aged Ars Veteran
107
Ok, don't try to find differences and apply changes, just save a new file.

I rearranged the configuration variables, now they're all at the top-ish.

I added absolute x and y offsets so that you can start the grid of windows at any point. I added the rough x and y grid start to the help so if your grid appears off screen the operator may have a clue as to why. ;) (meta-comment: You know, I'm treating the vlc windows like they each have an invisible frame. You probably didn't think of them that way, so strictly speaking the tborder and lborder probably don't do you any good. I dunno, I'll leave 'em. You can experiment with setting tborder and lborder to 0, adding their now-missing 10 and 6 values to bborder and rborder instead, or set all four border values to zero to have the vlc windows jammed together.)

I renamed some subroutine names.

I added a bunch more comments.

I reengineered the vidip and numports functionality, now ip and port are expressed together. I also allowed for any vidipb being null, but require vidipa. I do hope that the a,b assumption from your example is okay.

I added a for loop to wait for a bit between starting vlcs. I had a thought that perhaps starting them too quickly just touched a border condition, not a guarantee of a fix. You might try increasing the WAIT variable to some unreasonably high value to see if it makes a difference. Or, you can cut all that stuff out. I think I commented it okay to find it.

Code:
@echo off

:: do this because registry settings can default these off.  see 'cmd.exe /?'
setlocal enableextensions enabledelayedexpansion

:: Set our configuration variables.

:: These three are for the rows and columns of the vlc window matrix.
set maxrows=4
set maxcols=4
set /a maxsources= (maxrows * maxcols) - 1

:: The full path and file name of vlc on your system, in quotes.
set vlcpath="c:\program files\videolan\vlc\vlc.exe"

:: Supplied vlc window width and height
set vlcwidth=460
set vlcheight=315

:: Absolute left edge (x) and top (y) offsets to allow for positioning
:: at other than the top and left edges of a (big) screen.
set absolutexoffset=0
set absoluteyoffset=1080

:: Some random arsian's wild guess at vlc video window border values.
:: These space them apart in the vlc window grid.
set lborder=6
set rborder=17
set tborder=10
set bborder=10

:: Static vlc opts for all vlc.exe invocations.
set staticopts=-I rc --rc-quiet --no-video-title-show
set staticopts=%staticopts% --width %vlcwidth% --height %vlcheight%

:: These two are shared between :calcposandstart and :returnip
set vidipa=
set vidipb=

:: Wait loop for OP testing, try increasing or decreasing to see if that
:: affects how many vlc windows go missing.
set wait=5000

:: Capture the first argument.
set sourcecmd=%1
set showhelp=no
if /i [%sourcecmd:~-1%]==[?] set showhelp=yes
if /i [%sourcecmd:~-1%]==[h] set showhelp=yes
if /i [%sourcecmd%]==[help] set showhelp=yes
if /i not [%showhelp%]==[yes] goto starter
echo Usage is %~nx0 [?^|/?^|-?^|h^|-h^|/h^|help] - show this help
echo          %~nx0                        - show all sources
echo          %~nx0 source [source [...]]  - show a specific source
echo  Source varies from 0 to %maxsources%
echo  Note that each use of the same source will create
echo       1 or 2 windows at that position on the screen.
echo.
echo  The VLC windows grid will begin at roughly
echo  %absolutexoffset% x (over) and %absoluteyoffset% y (down)
echo.
echo  Configured sources are:
:: Because of parser behavior variables inside a loop do not necessarily take
:: on new values.  Use delayed expansion (the exclamation mark) in that case.
for /l %%i in (0,1,%maxsources%) do (
 call :returnip %%i
 if [!vidipb!]==[] set vidipb=not configured
 echo   source %%i IPa !vidipa! IPb !vidipb!
)
goto ender

:starter
:: handle the special case of no argument starts them all.
if [%sourcecmd%]==[] (
 taskkill /f /im vlc.exe >nul 2>&1
 for /l %%i in (0,1,%maxsources%) do call :calcposandstart %%i
 goto ender
)

:looper
:: Anything else is assumed to be a valid source and we'll
:: catch it later in calcposandstart.
if [%sourcecmd%]==[] goto ender
echo Starting video source id %sourcecmd%
call :calcposandstart %sourcecmd%
shift
set sourcecmd=%1
goto looper

:calcposandstart
:: Call calcposandstart with numericsourceid
 set numericsourceid=%1

:: Calculate which vlc window grid position the source id occupies.
 set vlcrow=0
 set vlccol=0
 set /a vlcrow=numericsourceid / maxcols
 if %vlcrow% GTR %maxrows% (
  echo %numericsourceid% would be on row %vlcrow%, max row is %maxrows%
  goto :eof
 )
 set /a "vlccol=numericsourceid %% maxcols"

:: First set the absolute x,y offsets configured above.
 set /a videox=absolutexoffset
 set /a videoy=absoluteyoffset

:: Then add in the calculated offsets for the vlc window identified by
:: numericsourcid in the overall vlc matrix.  We could do the videox, videoy
:: on one line each but the dev hates >80 column batch files.
 set /a videox+=(lborder * (vlccol + 1)) + ((vlcwidth + rborder) * vlccol)
 set /a videoy+=(tborder * (vlcrow + 1)) + ((vlcheight + bborder) * vlcrow)

:: Set some specific values for the two vlc windows that might end up being
:: shown for this numericsourceid.
 set /a vlctitleid=numericsourceid + 1
 set dynamicopts=--video-x %videox% --video-y %videoy%
 set dynamicoptsa=%dynamicopts% --video-title=Video%vlctitleid%a
 set dynamicoptsb=%dynamicopts% --video-title=Video%vlctitleid%b

:: Get populate vidipa and maybe vidipb for this video source.
 call :returnip %numericsourceid%
 if [%vidipa%]==[] (
  echo %numericsourceid% is not a valid source - 0 to %maxsources%
  goto :eof
 )

:: Finish with the variables dynamic for each vlc.
 set dynamicoptsa=%dynamicoptsa% --upd://@%vidipa%
 set dynamicoptsb=%dynamicoptsb% --upd://@%vidipb%

 echo Starting source %numericsourceid% a with %dynamicoptsa%
 start "Source ID %numericsourceid% a" %vlcpath% %staticopts% %dynamicoptsa%
:: I'm wondering if starting lots of vlcs too quickly causes OPs problem
:: with missing vlcs.
:: Let us stick in a wait loop.  He can remove these four lines of desired.
 for %%w in (1,1,%wait%) do echo waiting >nul

:: If vidipb is not null we better show it, too.
 if not [%vidipb%]==[] (
  echo Starting source %numericsourceid% b with %dynamicoptsb%
  start "Source ID %numericsourceid% b" %vlcpath% %staticopts% %dynamicoptsb%
:: Wait here, too.
 for %%w in (1,1,%wait%) do echo waiting >nul
 )
goto :eof

:returnip
:: Call returnip with a numericsourceid (video source number).
:: This must be set up for the whole thing to work.
:: Each video source number corresponds to the IP address and port number for
:: up to two video sources.
:: Since we can't return structures, classes, or anything but variables we
:: have to hard-code the variable names and the caller has to use the same
:: names.
:: It is easy enough for the maintainer to set the port number
:: as part of the ip address since the ip addresses may be different
:: and the ports could be different as well.

:: First, initialize the shared variables to clear out old values.
 set vidipa=
 set vidipb=

:: Next, set the variables based upon the source number given.
:: While vidipb may be null, vidipa may not be.
:: Spaces after the = are bad.
 if [%1]==[0]  set vidipa=127.0.0.1:1
 if [%1]==[0]  set vidipb=127.0.0.2:2
 if [%1]==[1]  set vidipa=127.0.0.3:3
 if [%1]==[1]  set vidipb=127.0.0.4:4
 if [%1]==[2]  set vidipa=127.0.0.5:5
 if [%1]==[2]  set vidipb=127.0.0.6:6
 if [%1]==[3]  set vidipa=127.0.0.7:7
 if [%1]==[3]  set vidipb=127.0.0.8:8
 if [%1]==[4]  set vidipa=127.0.0.9:9
 if [%1]==[4]  set vidipb=127.0.0.10:10
 if [%1]==[5]  set vidipa=127.0.0.11:11
 if [%1]==[5]  set vidipb=127.0.0.12:12
 if [%1]==[6]  set vidipa=127.0.0.13:13
 if [%1]==[6]  set vidipb=127.0.0.14:14
 if [%1]==[7]  set vidipa=127.0.0.15:15
 if [%1]==[7]  set vidipb=127.0.0.16:16
 if [%1]==[8]  set vidipa=127.0.0.17:17
 if [%1]==[8]  set vidipb=127.0.0.18:18
 if [%1]==[9]  set vidipa=127.0.0.19:19
 if [%1]==[9]  set vidipb=127.0.0.20:20
 if [%1]==[10] set vidipa=127.0.0.21:21
 if [%1]==[10] set vidipb=127.0.0.22:22
 if [%1]==[11] set vidipa=127.0.0.23:23
 if [%1]==[11] set vidipb=127.0.0.24:24
 if [%1]==[12] set vidipa=127.0.0.25:25
 if [%1]==[12] set vidipb=127.0.0.26:26
 if [%1]==[13] set vidipa=127.0.0.27:27
 if [%1]==[13] set vidipb=127.0.0.28:28
 if [%1]==[14] set vidipa=127.0.0.29:29
 if [%1]==[14] set vidipb=
 if [%1]==[15] set vidipa=127.0.0.31:31
 if [%1]==[15] set vidipb=
goto :eof

:ender
endlocal
goto :eof

I went with providing use cases again, for completeness:
Code:
C:\data\batch>startmonitor ?
Usage is startmonitor.cmd [?|/?|-?|h|-h|/h|help] - show this help
         startmonitor.cmd                        - show all sources
         startmonitor.cmd source [source [...]]  - show a specific source
 Source varies from 0 to 15
 Note that each use of the same source will create
      1 or 2 windows at that position on the screen.

 The VLC windows grid will begin at roughly
 0 x (over) and 1080 y (down)

 Configured sources are:
  source 0 IPa 127.0.0.1:1 IPb 127.0.0.2:2
  source 1 IPa 127.0.0.3:3 IPb 127.0.0.4:4
  source 2 IPa 127.0.0.5:5 IPb 127.0.0.6:6
  source 3 IPa 127.0.0.7:7 IPb 127.0.0.8:8
  source 4 IPa 127.0.0.9:9 IPb 127.0.0.10:10
  source 5 IPa 127.0.0.11:11 IPb 127.0.0.12:12
  source 6 IPa 127.0.0.13:13 IPb 127.0.0.14:14
  source 7 IPa 127.0.0.15:15 IPb 127.0.0.16:16
  source 8 IPa 127.0.0.17:17 IPb 127.0.0.18:18
  source 9 IPa 127.0.0.19:19 IPb 127.0.0.20:20
  source 10 IPa 127.0.0.21:21 IPb 127.0.0.22:22
  source 11 IPa 127.0.0.23:23 IPb 127.0.0.24:24
  source 12 IPa 127.0.0.25:25 IPb 127.0.0.26:26
  source 13 IPa 127.0.0.27:27 IPb 127.0.0.28:28
  source 14 IPa 127.0.0.29:29 IPb not configured
  source 15 IPa 127.0.0.31:31 IPb not configured

C:\data\batch>startmonitor
Starting source 0 a with --video-x 6 --video-y 1090 --video-title=Video1a --upd://@127.0.0.1:1
Starting source 0 b with --video-x 6 --video-y 1090 --video-title=Video1b --upd://@127.0.0.2:2
Starting source 1 a with --video-x 489 --video-y 1090 --video-title=Video2a --upd://@127.0.0.3:3
Starting source 1 b with --video-x 489 --video-y 1090 --video-title=Video2b --upd://@127.0.0.4:4
Starting source 2 a with --video-x 972 --video-y 1090 --video-title=Video3a --upd://@127.0.0.5:5
Starting source 2 b with --video-x 972 --video-y 1090 --video-title=Video3b --upd://@127.0.0.6:6
Starting source 3 a with --video-x 1455 --video-y 1090 --video-title=Video4a --upd://@127.0.0.7:7
Starting source 3 b with --video-x 1455 --video-y 1090 --video-title=Video4b --upd://@127.0.0.8:8
Starting source 4 a with --video-x 6 --video-y 1425 --video-title=Video5a --upd://@127.0.0.9:9
Starting source 4 b with --video-x 6 --video-y 1425 --video-title=Video5b --upd://@127.0.0.10:10
Starting source 5 a with --video-x 489 --video-y 1425 --video-title=Video6a --upd://@127.0.0.11:11
Starting source 5 b with --video-x 489 --video-y 1425 --video-title=Video6b --upd://@127.0.0.12:12
Starting source 6 a with --video-x 972 --video-y 1425 --video-title=Video7a --upd://@127.0.0.13:13
Starting source 6 b with --video-x 972 --video-y 1425 --video-title=Video7b --upd://@127.0.0.14:14
Starting source 7 a with --video-x 1455 --video-y 1425 --video-title=Video8a --upd://@127.0.0.15:15
Starting source 7 b with --video-x 1455 --video-y 1425 --video-title=Video8b --upd://@127.0.0.16:16
Starting source 8 a with --video-x 6 --video-y 1760 --video-title=Video9a --upd://@127.0.0.17:17
Starting source 8 b with --video-x 6 --video-y 1760 --video-title=Video9b --upd://@127.0.0.18:18
Starting source 9 a with --video-x 489 --video-y 1760 --video-title=Video10a --upd://@127.0.0.19:19
Starting source 9 b with --video-x 489 --video-y 1760 --video-title=Video10b --upd://@127.0.0.20:20
Starting source 10 a with --video-x 972 --video-y 1760 --video-title=Video11a --upd://@127.0.0.21:21
Starting source 10 b with --video-x 972 --video-y 1760 --video-title=Video11b --upd://@127.0.0.22:22
Starting source 11 a with --video-x 1455 --video-y 1760 --video-title=Video12a --upd://@127.0.0.23:23
Starting source 11 b with --video-x 1455 --video-y 1760 --video-title=Video12b --upd://@127.0.0.24:24
Starting source 12 a with --video-x 6 --video-y 2095 --video-title=Video13a --upd://@127.0.0.25:25
Starting source 12 b with --video-x 6 --video-y 2095 --video-title=Video13b --upd://@127.0.0.26:26
Starting source 13 a with --video-x 489 --video-y 2095 --video-title=Video14a --upd://@127.0.0.27:27
Starting source 13 b with --video-x 489 --video-y 2095 --video-title=Video14b --upd://@127.0.0.28:28
Starting source 14 a with --video-x 972 --video-y 2095 --video-title=Video15a --upd://@127.0.0.29:29
Starting source 15 a with --video-x 1455 --video-y 2095 --video-title=Video16a --upd://@127.0.0.31:31

C:\data\batch>startmonitor 1 bob 2 carol 3 ted 4 alice -1 300
Starting video source id 1
Starting source 1 a with --video-x 489 --video-y 1090 --video-title=Video2a --upd://@127.0.0.3:3
Starting source 1 b with --video-x 489 --video-y 1090 --video-title=Video2b --upd://@127.0.0.4:4
Starting video source id bob
bob is not a valid source - 0 to 15
Starting video source id 2
Starting source 2 a with --video-x 972 --video-y 1090 --video-title=Video3a --upd://@127.0.0.5:5
Starting source 2 b with --video-x 972 --video-y 1090 --video-title=Video3b --upd://@127.0.0.6:6
Starting video source id carol
carol is not a valid source - 0 to 15
Starting video source id 3
Starting source 3 a with --video-x 1455 --video-y 1090 --video-title=Video4a --upd://@127.0.0.7:7
Starting source 3 b with --video-x 1455 --video-y 1090 --video-title=Video4b --upd://@127.0.0.8:8
Starting video source id ted
ted is not a valid source - 0 to 15
Starting video source id 4
Starting source 4 a with --video-x 6 --video-y 1425 --video-title=Video5a --upd://@127.0.0.9:9
Starting source 4 b with --video-x 6 --video-y 1425 --video-title=Video5b --upd://@127.0.0.10:10
Starting video source id alice
alice is not a valid source - 0 to 15
Starting video source id -1
-1 is not a valid source - 0 to 15
Starting video source id 300
300 would be on row 75, max row is 4

C:\data\batch>

Hitting the post button, here's hoping!
 

devjames

Wise, Aged Ars Veteran
107
Arindrew":123axjun said:
Thanks for the quick update! I wont be able to test this until Saturday though.

I assume the wait loop is in ms?

Nope, the wait loop is in integers. :(

AFAIK, windows doesn't come natively with a sleep or wait command. There have been a lot written (sleep, choice) and a lot of different ones with the same name, but a native wait I'd have had to code in a busy loop parsing out time values and handling changes to lower seconds at each minute change.

So, integers for the win! 5000, 10000, 15000, just until you see a slight delay between each vlc starting and see if more start that way.
 

devjames

Wise, Aged Ars Veteran
107
It would be so nice to be right the first time.

Of course, there is the windows xp ping trick. You supply milliseconds to wait and an ip address with nothing on the other end, and !poof!

So, you can delete the naughty for loops and replace them with:
Code:
ping -n 1 -w %wait% 1.1.1.1 >nul 2>&1
and get a 5 second wait. This isn't millisecond accurate by any means, it only seems to change in 1/2 second increments, but for your purpose I'd try 2000 or 3000 to see if any difference is noticed.

By the way, I didn't address ronelson's and MooseAreFun's comments that I'm missing a menu or loop to restart missing windows. What makes it worse is that I agreed with them...

My assumption is that you'll start a cmd.exe session and then issue commands like 'startmonitor' followed by 'startmonitor 1 3 13' until you get them all.

It doesn't have to be that way. If you plan to start this by clicking an icon on the desktop you certainly don't have an easy way to add missing sources.

It wouldn't be too hard to replace looper with something that will ask you if there are any sources to add, and to make the 'smartmonitor' call with no arguments then fall into looper.

Would you like such a patch? That way, you'd click on the desktop icon, it would try to start all sources, then it would ask if you need to re-add any sources until you entered either an empty line or a 'q' or 'x' or something.

This would be of value if the wait doesn't fix your original problem.
 

ronelson

Ars Legatus Legionis
21,399
Subscriptor
By the way, I didn't address ronelson's and MooseAreFun's comments that I'm missing a menu or loop to restart missing windows. What makes it worse is that I agreed with them...
LOL, funny. It has been at least a decade since I wrote a menu in batch or I would help out. In the meantime, watching you has brought back a lot of memories, some good and some bad. Not sure whether to laugh or cry :)
 

devjames

Wise, Aged Ars Veteran
107
ronelson":2y9mjmvq said:
By the way, I didn't address ronelson's and MooseAreFun's comments that I'm missing a menu or loop to restart missing windows. What makes it worse is that I agreed with them...
LOL, funny. It has been at least a decade since I wrote a menu in batch or I would help out. In the meantime, watching you has brought back a lot of memories, some good and some bad. Not sure whether to laugh or cry :)

Nah, it really is easy and I really do it for work. No, really. ;) I'm claiming the drugs and illness. Made it in to work one day so far this week. I can feel the fuzzy in my thought processes and I don't like it.

My ulterior motive is that I can minimally pervert this script into my long-thought-of "wall of Dr. Who", each streaming from the dvd drive of one of my computers in the house.

And that, sir, is a worthy goal. :D
 

Arindrew

Ars Scholae Palatinae
1,341
Almost working perfectly. Couple of changes I had to make though:

there is no -- before upd://
upd:// is actually udp://
needed to remove "--no-video-title-show" (this one is my fault actually)
added %staticopts% to the "echo Starting source" line (preference really, not an error)

=== EDIT ===

Disregard below, I figured it out. After typing up the paragraph below, I had some inspiration. :)

Code:
set vlcwidth=432
set vlcheight=243
...
set lborder=24
set rborder=24
set tborder=0
set bborder=28

=== EDIT ===

Also, I'm having trouble getting the windows to sit correctly on the screen. Partly my fault for not specifying how we have them laid out. I didn't think you would try to "variablize" it. :p

Our background is a 1920x1080 image with a 4x4 grid. Each cell in the grid is a different color, and is 480x270 in size. Each VLC window is 432x243 in size, giving us a horizontal space of 48 pixels between each window in a row (or 24 on each side of each window). The title bar for each window is 27 pixels, which leaves us the remaining 243 pixels left over to fit in our 270 tall cell. Vertically, each window is right below the one on top of it (no space). I wasn't able to quite figure out how to set this up properly with your script.

Here is the stripped down code for how we position:
Code:
 --video-x 20 --video-y 1081 
 --video-x 500 --video-y 1081 
 --video-x 980 --video-y 1081 
 --video-x 1460 --video-y 1081 

 --video-x 20 --video-y 1350 
 --video-x 500 --video-y 1350 
 --video-x 980 --video-y 1350 
 --video-x 1460 --video-y 1350 

 --video-x 20 --video-y 1620 
 --video-x 500 --video-y 1620 
 --video-x 980 --video-y 1620 
 --video-x 1460 --video-y 1620 

 --video-x 20 --video-y 1890 
 --video-x 500 --video-y 1890
 --video-x 980 --video-y 1890
 --video-x 1460 --video-y 1890
 

devjames

Wise, Aged Ars Veteran
107
From what you've tryped above, that ought to do it. And I understand that you have no outstanding questions of me.

Before we leave this thread to molder on the dustheap of history, a couple more questions of you. Are you happy with the way it functions now, or would you rather have the change to looper I mentioned that would stay in a loop asking for more windows to start?

Which wait method did you use, for loop integers or ping trick?

Did it help? :)

Considering everything, are you better off now or before? (Consider the amount of editing now to change grid size vs. using the before method)

thanks!
 

Arindrew

Ars Scholae Palatinae
1,341
I am happy with the way the script functions, and the looper (integer) works fine.

I am very happy with the results and I can almost say that we are better off now than we were before. I have one last request before I let this molder. I am starting to feel bad for all these requests. I started this thinking it would be something quick and dirty. I'm thinking I need to start paying you lol.

My last request is that when I change maxrows and maxcols (for when we have to pull more streams in the future) I would like the size of the windows to change dynamically from that. I already have the math for it figured out, I'm just not sure of the correct syntax. Basically, I need to replace:

Code:
:: Supplied vlc window width and height
set vlcwidth=432
set vlcheight=243
with:
Code:
:: Formula to determine vlc width and height
set vlcwidth = 1920 - (maxrows * (lborder + rborder)) / maxrows
set vlcheight = 1080 - (maxcols * (bborder + tborder)) / maxcols

This will be my last request! Promise! Maybe..

Seriously though, the script works great, and I've replaced my current script with it. In all this testing though, Ive found out why some of the windows weren't launching. I added an extra tag in the VLC command, and now all the windows launch when they are suppose to. I still like your script better, due to its versatility. I just need this last change to future proof it.
 

devjames

Wise, Aged Ars Veteran
107
Arindrew":8w8gfufk said:
I am happy with the way the script functions, and the looper (integer) works fine.

I am very happy with the results and I can almost say that we are better off now than we were before. I have one last request before I let this molder. I am starting to feel bad for all these requests. I started this thinking it would be something quick and dirty. I'm thinking I need to start paying you lol.

My last request is that when I change maxrows and maxcols (for when we have to pull more streams in the future) I would like the size of the windows to change dynamically from that. I already have the math for it figured out, I'm just not sure of the correct syntax. Basically, I need to replace:

Code:
:: Supplied vlc window width and height
set vlcwidth=432
set vlcheight=243
with:
Code:
:: Formula to determine vlc width and height
set vlcwidth = 1920 - (maxrows * (lborder + rborder)) / maxrows
set vlcheight = 1080 - (maxcols * (bborder + tborder)) / maxcols

This will be my last request! Promise! Maybe..

Seriously though, the script works great, and I've replaced my current script with it. In all this testing though, Ive found out why some of the windows weren't launching. I added an extra tag in the VLC command, and now all the windows launch when they are suppose to. I still like your script better, due to its versatility. I just need this last change to future proof it.

Replace this original set of code:
Code:
:: These three are for the rows and columns of the vlc window matrix.
set maxrows=4
set maxcols=4
set /a maxsources= (maxrows * maxcols) - 1

:: The full path and file name of vlc on your system, in quotes.
set vlcpath="c:\program files\videolan\vlc\vlc.exe"

:: Supplied vlc window width and height
set vlcwidth=460
set vlcheight=315

:: Absolute left edge (x) and top (y) offsets to allow for positioning
:: at other than the top and left edges of a (big) screen.
set absolutexoffset=0
set absoluteyoffset=1080

:: Some random arsian's wild guess at vlc video window border values.
:: These space them apart in the vlc window grid.
set lborder=6
set rborder=17
set tborder=10
set bborder=10

with this set of code
Code:
:: These two are for the dimensions of the vlc window matrix
set vlcgridx=1920
set vlcgridy=1080

:: These three are for the rows and columns of the vlc window matrix.
set maxrows=4
set maxcols=4
set /a maxsources= (maxrows * maxcols) - 1

:: Some random arsian's wild guess at vlc video window border values.
:: These space them apart in the vlc window grid.
set lborder=6
set rborder=17
set tborder=10
set bborder=10

:: Formula to determine vlc width and height
set /a vlcwidth = (vlcgridx - (maxrows * (lborder + rborder))) / maxrows
set /a vlcheight = (vlcgridy - (maxcols * (bborder + tborder))) / maxcols

:: Absolute left edge (x) and top (y) offsets to allow for positioning
:: at other than the top and left edges of a (big) screen.
set absolutexoffset=0
set absoluteyoffset=1080

:: The full path and file name of vlc on your system, in quotes.
set vlcpath="c:\program files\videolan\vlc\vlc.exe"

Note that I had to change your formula, I believe that you didn't take into consideration that operator precedence of / is greater than that of -.

Note also that this has gone back and forth several times because of two factors that shouldn't be allowed to happen in a professional setting (at work with your IT dept, for instance). 1) I didn't do proper requirements gathering, pushing you for details before I ever wrote one line. 2) You didn't properly divulge requirements.

I realize that those things couldn't really happen in an open forum; and I'm not faulting you. However, if you re-read this thread and think about it please realize (everyone!) that this back and forth would have been avoided had 1 and 2 above happened.

Just food for thought. Hope all this works well for you. Hope also that you remembered to remove the nasty for-loop wait code when you found the real problem with missing windows.

Sorry for all the false starts, I'm still blaming the drugs. ;)
 
Status
Not open for further replies.