SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV v7 Customizations > Phoenix
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

Phoenix This forum is for discussing the user-created Phoenix custom interface for SageTV.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-05-2011, 01:06 AM
JonTom JonTom is offline
Sage Aficionado
 
Join Date: Apr 2005
Location: Whistler BC
Posts: 413
Triggering batch files from menu

I've created a batch file that will
1 - rip a DVD
2 - encode that DVD rip with handbrake

the file works properly when I run it by double clicking in windows, or if I execute it from the command line, but when I run it from a menuitem, part of the code doesn't seem to execute (the DVD rip works, but handbrakeCLI doesn't get called/command line never opens). any idea why that would be?
__________________
Alpine Website Design
Reply With Quote
  #2  
Old 09-05-2011, 05:30 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by JonTom View Post
I've created a batch file that will
1 - rip a DVD
2 - encode that DVD rip with handbrake

the file works properly when I run it by double clicking in windows, or if I execute it from the command line, but when I run it from a menuitem, part of the code doesn't seem to execute (the DVD rip works, but handbrakeCLI doesn't get called/command line never opens). any idea why that would be?
I'm not a windows person, but, are you sure the commandline never gets executed? Does the bat file process end, or does it appear stuck? Maybe the handbrake cli dies quickly because it cannot find the ripped file. When you execute a bat file from within sagetv the working directory is the sagetv home directory, so if the handbrake is looking for a file relative to some other location, then that could cause it to fail.
Reply With Quote
  #3  
Old 09-05-2011, 11:20 PM
JonTom JonTom is offline
Sage Aficionado
 
Join Date: Apr 2005
Location: Whistler BC
Posts: 413
I'm using absolute paths, so I don't think that's it. The file

I've put my fragment code below, and the batch code too. After a reboot, it won't even launch DVDFab anymore. Any thoughts?

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE menus SYSTEM "menus.dtd">

<menus>
  <fragment parentMenu="phoenix.menu.lz.videos" insertBefore="Movies-new">
    <menuItem name="phoenix.menu.lz.useritem.ripnick" label="Import a Nick DVD" visible="true">
		<exec cmd="C:\Program Files (x86)\SageTV\SageTV\userdata\Phoenix\RipNick.bat" />
    </menuItem>
  </fragment>
</menus>
Code:
@echo off

::DECRYPTED DVD DIRECTORY
set DVDFiles=C:\Users\jon\Videos

::VIDEO FILE OUTPUT DIRECTORY
set VidOut=\\OFFICE\sage

::VIDEO FILE OUTPUT SUBDIRECTORY - used for separating different types of import videos
set VidOutSub=NicholasVideos

::DVD DRIVE LETTER
set DVD=D:

::BODY

setlocal enableextensions enabledelayedexpansion
%DVD%
CLS
for /f "tokens=5*" %%t in ('vol') do (
	@set VolID=%%u
	goto :gotname
)

:gotname
C:
set FileName=%VolID%
@set VolID=%VolID: =_%
echo %FileName%
"C:\Program Files (x86)\DVDFab 8 Qt\dvdfab.exe" /MODE "FULLDISC" /SRC "%DVD%" /DEST "%DVDFiles%" /REMOVEPGC "yes" /OUTDISC "dvd9" /VOLUME "%VolID%" /CLOSE
"C:\Program Files (x86)\Handbrake\HandbrakeCLI.exe" -i %DVDFiles%\FullDisc\%VolID% -o "%VidOut%\%VidOutSub%\%FileName%.mkv" -e x264 -q 20.0 -a 1 -E copy -f mkv --detelecine --decomb --loose-anamorphic -m -x b-adapt=2:rc-lookahead=50 --main-feature
CLS
echo %VidOut%\%VidOutSub%\%FileName%.mkv Created
__________________
Alpine Website Design
Reply With Quote
  #4  
Old 09-06-2011, 07:16 AM
Tomahawk51's Avatar
Tomahawk51 Tomahawk51 is offline
Sage Aficionado
 
Join Date: Oct 2005
Posts: 320
Once you get your answer, I'd generally be interested if you see an approach to map a keystroke/command to call the executable. I can imagine some cool scenerios for doing things from an extender... and having a Harmony 100 means I can have lots of virtual buttons in the LCD display.
Reply With Quote
  #5  
Old 09-06-2011, 07:35 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
@JonTom - I may have to add some logging to the <exec> function to provide an option that will log the output of the commands to a log file. At least then you'd be able to see what the command is echoing out to the terminal window and... maybe the process is dying for some reason. YOu can check the logs/phoenix.log or the sagetv_0.txt log file to see if it is showing any errors.

@Tomahawk51 - I don't think that we allow for a keybinding to a command or menu, yet.
Reply With Quote
  #6  
Old 09-06-2011, 10:27 AM
JonTom JonTom is offline
Sage Aficionado
 
Join Date: Apr 2005
Location: Whistler BC
Posts: 413
I'll check. Additional logging would be great too, thanks.
__________________
Alpine Website Design
Reply With Quote
  #7  
Old 09-06-2011, 10:31 AM
JonTom JonTom is offline
Sage Aficionado
 
Join Date: Apr 2005
Location: Whistler BC
Posts: 413
Quote:
Originally Posted by Tomahawk51 View Post
Once you get your answer, I'd generally be interested if you see an approach to map a keystroke/command to call the executable. I can imagine some cool scenerios for doing things from an extender... and having a Harmony 100 means I can have lots of virtual buttons in the LCD display.
Using LMGestion keycap makes that easy. Add a phantom device to your harmony for additional codes, and map them to your execs in LM. No need to involve Phoenix/sage at all.

Edit: oh, just saw you said with extenders. I don't know, then.
__________________
Alpine Website Design
Reply With Quote
  #8  
Old 09-06-2011, 09:40 PM
JonTom JonTom is offline
Sage Aficionado
 
Join Date: Apr 2005
Location: Whistler BC
Posts: 413
The logs don't show anything beyond the menu frag being loaded.

The DVDFab part is working again, but still no luck with handbrake. I checked the process explorer and I see that handbrakeCLI.exe is running but it's using 0 CPU cycles and seems stuck.

Should the terminal window not open when the batch is started? When I run the file manually, I get a command prompt/window and the script runs there (echos to the prompt, etc). That doesn't happen when I trigger the file from the menuitem, and handbrakeCLI.exe is a commandline only interface for handbrake. Is that maybe the problem? DVDFab runs the normal GUI with the attributes set from the commandline so that's a little different...
__________________
Alpine Website Design
Reply With Quote
  #9  
Old 09-06-2011, 10:11 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Try using START commands in your batch file for launching the HandbrakeCLI. It may be that they are being launched in a process tied too closely to the sagetv service, keeping handbrake from accessing something it is needing. try changing your Handbrake line to :
Code:
START "HandBrakeCLI" /WAIT "C:\Program Files (x86)\Handbrake\HandbrakeCLI.exe" -i %DVDFiles%\FullDisc\%VolID% -o "%VidOut%\%VidOutSub%\%FileName%.mkv" -e x264 -q 20.0 -a 1 -E copy -f mkv --detelecine --decomb --loose-anamorphic -m -x b-adapt=2:rc-lookahead=50 --main-feature
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #10  
Old 09-07-2011, 03:56 AM
JonTom JonTom is offline
Sage Aficionado
 
Join Date: Apr 2005
Location: Whistler BC
Posts: 413
That did it, thank you.
__________________
Alpine Website Design

Last edited by JonTom; 09-07-2011 at 03:30 PM.
Reply With Quote
  #11  
Old 09-07-2011, 09:43 PM
JonTom JonTom is offline
Sage Aficionado
 
Join Date: Apr 2005
Location: Whistler BC
Posts: 413
my working code, for anyone who wants it:

Code:
@echo off

::DECRYPTED DVD DIRECTORY
set DVDFiles=C:\Users\Jon\Documents\DVDFab

::VIDEO FILE OUTPUT TEMP DIRECTORY
set VidTemp=C:\Users\Jon\Documents\DVDFab\FullDisc

::VIDEO FILE DESTINATION DIRECTORY
set VidOut=\\OFFICE\sage

::VIDEO FILE DESTINATION SUBDIRECTORY - used for separating different types of import videos
set VidOutSub=NicholasVideos

::DVD DRIVE LETTER
set DVD=D:

::BODY

setlocal enableextensions enabledelayedexpansion
%DVD%
for /f "tokens=5*" %%t in ('vol') do (
	@set VolID=%%u
	goto :gotname
)

:gotname
C:
@set FileName=%VolID%
@set VolID=%VolID: =_%
@set Filename=%FileName:_= %
"C:\Program Files (x86)\DVDFab 8 Qt\dvdfab.exe" /MODE "FULLDISC" /SRC "%DVD%" /DEST "%DVDFiles%" /REMOVEPGC "yes" /OUTDISC "dvd9" /VOLUME "%VolID%" /CLOSE
START "HandBrakeCLI" /WAIT "C:\Program Files (x86)\Handbrake\HandbrakeCLI.exe" -i %DVDFiles%\FullDisc\%VolID% -o "%VidTemp%\%FileName%.mkv" --main-feature --preset="Normal" -a 1 -E copy:ac3 -f mkv --detelecine --decomb
move /y "%VidTemp%\%FileName%.mkv" "%VidOut%\%VidOutSub%\"
rmdir /s /q "%DVDFiles%\FullDisc\%VolID%"
__________________
Alpine Website Design
Reply With Quote
  #12  
Old 09-09-2011, 06:43 PM
JonTom JonTom is offline
Sage Aficionado
 
Join Date: Apr 2005
Location: Whistler BC
Posts: 413
I'm now trying to pass the subdirectory via a command line parameter in the menufragment so that I can have only one version of the batch file (
::VIDEO FILE DESTINATION SUBDIRECTORY - used for separating different types of import videos
set VidOutSub=%1
)

but that's not working from the fragment (commandline works fine). I looked at trying START again but the use of "" is problematic. Any ideas why the below cmd line isn't passing the parameter to the batch file (files end up in %VidOut% instead of %VidOut%\%VidOutSub%)

Thanks



Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE menus SYSTEM "menus.dtd">

<menus>
  <fragment parentMenu="phoenix.menu.lz.videos" insertBefore="Movies-new">
    <menuItem name="phoenix.menu.lz.useritem.ripnick" label="Import a Nick DVD" visible="true">
		<exec cmd="C:\Program Files (x86)\SageTV\SageTV\userdata\Phoenix\RipConvert.bat NicholasVideos" />
    </menuItem>
  </fragment>
</menus>
Code:
@echo off

::DECRYPTED DVD DIRECTORY
set DVDFiles=%USERPROFILE%\Documents\DVDFab

::VIDEO FILE OUTPUT TEMP DIRECTORY
set VidTemp=%USERPROFILE%\Documents\DVDFab\FullDisc

::VIDEO FILE DESTINATION DIRECTORY
set VidOut=\\OFFICE\sage

::VIDEO FILE DESTINATION SUBDIRECTORY - used for separating different types of import videos
set VidOutSub=%1

::DVD DRIVE LETTER
set DVD=D:

::BODY

setlocal enableextensions enabledelayedexpansion
%DVD%
for /f "tokens=5*" %%t in ('vol') do (
	@set VolID=%%u
	goto :gotname
)

:gotname
C:
@set FileName=%VolID%
@set VolID=%VolID: =_%
@set Filename=%FileName:_= %
"%ProgramFiles(x86)%\DVDFab 8 Qt\dvdfab.exe" /MODE "FULLDISC" /SRC "%DVD%" /DEST "%DVDFiles%" /REMOVEPGC "yes" /OUTDISC "dvd9" /VOLUME "%VolID%" /CLOSE
START "HandBrakeCLI" /WAIT "%ProgramFiles(x86)%\Handbrake\HandbrakeCLI.exe" -i %DVDFiles%\FullDisc\%VolID% -o "%VidTemp%\%FileName%.mkv" --main-feature --preset="Normal" -a 1 -E copy:ac3 -f mkv --detelecine --decomb
move /y "%VidTemp%\%FileName%.mkv" %VidOut%\%VidOutSub%\
rmdir /s /q "%DVDFiles%\FullDisc\%VolID%"
__________________
Alpine Website Design
Reply With Quote
  #13  
Old 09-11-2011, 07:02 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
I answered that in your other post... you need to use the 'args' attribute on the <exec> item to pass args to a command.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sage TV triggering BSOD AlphaWolf Hardware Support 7 06-01-2013 05:30 PM
Automated VideoRedo (DOS batch files) grauchy SageTV Customizations 3 09-08-2011 10:01 PM
Batch Rename Files ldavis Batch Metadata Tools 1 07-24-2011 06:25 AM
Batch files for CD rips JUC General Discussion 4 04-09-2005 05:02 PM


All times are GMT -6. The time now is 04:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.