SageTV Community  

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

Notices

SageTV Customizations This forums is for discussing and sharing user-created modifications for the SageTV application created by using the SageTV Studio or through the use of external plugins. Use this forum to discuss customizations for SageTV version 6 and earlier, or for the SageTV3 UI.

View Poll Results: Do you use batch files for various sagetv related functions?
Yes. Batch files rule.. haha.. 9 60.00%
No. I can code and write apps or do not need it. 4 26.67%
What is a batch file? 2 13.33%
Voters: 15. You may not vote on this poll

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-14-2005, 12:35 PM
seamonkey420 seamonkey420 is offline
Sage User
 
Join Date: Mar 2005
Posts: 49
Cool batch files for divx encoding, broadcast, more..

Hello everyone...


well, i think i finally am understanding how to do a few things i've wanted to do with sagetv and my files for a while..

i have finally created a script/batch file that will:

1. check folders for a .VPrj file
2. if it exists, it will then take the list of movies and then encode them to a more streamable divx format using VirtualDub
3. once it creates the avi file, it then goes back and moves the file to a new directory of encoded movies
4 and lastly, it goes through and deletes the original mpg movie, .log, .ccno, .txt and .VPrj files for that show name.

I then call it from Windows Scheduler to run each night at 4:30am.

This is a pretty basic batch file as of now, it does not remove the commercials that are detected. However, i plan to working on adding that into the batch using comskip.exe or an external comskip i've seen around that takes some good parameters...

i will post the script file for those that might be interested in using it to automate encoding and cleanup afterwards.
NOTE: this prob can be modified to do a crap load of other functions, like burn movies to a dvd. I'm also working on creating another batch files to automatically generate an html web page with teh video embeded into it..
:-)

i'll attach my batch files later in the day..


Just thought i'd share my batch file since it took me about 3 days to research and finally get it working!

peace
seamonkey420

________
NOTE: uploaded zip file with: batch file, my tvshows.vcf (virtual dub profile for divx encoding), and a copy of virtualdub mpeg version)

Admins: let me know if i need to remove the virtualdub v1.5 mpeg build or not from the zip, figured i'd include since i was having the nasty mpeg error prob from the original virtualdub build.

I worked on the script a bit more today to refine it and it seems to do quite a bit of what i want, comskip implementation and perhaps even commercial stripping will be looked at!!

edit: sorry, uploaded w/encoding command rem'd out.. hehe, was testing the cleanup part before uploading.. correct one up..
Attached Files
File Type: zip VirtualDub mpeg version and automated divx encoding.zip (680.3 KB, 408 views)

Last edited by seamonkey420; 03-15-2005 at 07:28 PM. Reason: updated title, corrected weird spacing in batches..
Reply With Quote
  #2  
Old 03-14-2005, 01:00 PM
Crashless's Avatar
Crashless Crashless is offline
Sage Icon
 
Join Date: Oct 2003
Location: Los Angeles, CA
Posts: 1,224
I'm VERY interested in your CLI for VDub. I've always gotten errors when I try it. I would LOVE to automate my movie recordings getting encoded to DIVX!

Right now I copy the files I want to encode to a folder, then use DubMan (a scripting program for VDub) to run a job on all those files.

Removing the manual copy step would be great.
Reply With Quote
  #3  
Old 03-14-2005, 01:52 PM
Juncti Juncti is offline
Sage Advanced User
 
Join Date: Dec 2004
Posts: 76
Where's this batch file? I'd be very interested in this as well. Would be awesome if this could be implemented into a stv like comskip where whenever your system isn't recording it'll use that time to process and convert to divx.
Reply With Quote
  #4  
Old 03-14-2005, 02:13 PM
Crashless's Avatar
Crashless Crashless is offline
Sage Icon
 
Join Date: Oct 2003
Location: Los Angeles, CA
Posts: 1,224
Quote:
Originally Posted by Juncti
Where's this batch file? I'd be very interested in this as well. Would be awesome if this could be implemented into a stv like comskip where whenever your system isn't recording it'll use that time to process and convert to divx.
You can kinda do this now with dirmon. You just need the cli for the program and dirmon will run whatever you want on it.

http://sage.tv/forums/showthread.php?t=10361&
Reply With Quote
  #5  
Old 03-14-2005, 05:33 PM
seamonkey420 seamonkey420 is offline
Sage User
 
Join Date: Mar 2005
Posts: 49
Cool

Here's the actual batch file from the above zip file, so others can copy and paste to create their own batch files if they don't need the other files in my zip..

here's the logic used (found the "for" command on these forums! then played with and tweaked).

NOTE! that to get this to work, i usually will go into my recorded shows in the morning and then comm detect them, i have not setup my comskip to detect when recording yet... the trigger file can be changed too, i didn't use .mpg since it would try to encode currently recording shows and fail miserably.. what is the true file that sagetv creates when it finishes recording? i used the .VPrj since it creates it after i choose to comm detect the recorded movies. but again, can be changed very easily.

The biggest jump i had when making/testing it was to be sure to keep the batch file and the .vcf profile in the same directory as virtualdub, that way i could call virtualdub.exe in a much smoother way without a variable, etc.

I'll post new batches for others to use, cuz this seems to be an area of computer (batch files) and in sagetv thats slowly dying yet are so very useful for us non-oo coding geeks.. hehe..

oh yea, be sure to have norton/mcaffee/etc allow your script to run too if it detects it as an unknown script...

peace
seamonkey420

_________________________________
Quote:
@echo off
REM Seamonkey420's SageTV Batch File
REM Automated DIVX encoding
REM created on: 3/14/05
REM RECOMMENDED TO TEST IN A TEMP DIR FIRST!!

REM Setup as is, it will encode mpg to divx, then
REM clean up the log, txt, ccno and VPrj files
REM Then moves the avi file to a new folder (odir)
REM Then finally deletes the original mpg


REM Be sure to put this batch file in the same folder as your Virtualdub.exe file
REM ALSO Be sure to create a .vcf settings file in Virtualdub
REM This file then needs to be saved in the same folder as virtualdub.exe and this batch file


REM SETS SCRIPT VARIABLES, ie folder paths for files to be encoded
REM and where to save files and locations of WMEncoder main script

set idir=M:\TV Shows
set odir=M:\TV Shows\encoded


REM this line checks for a .VPrj file in the idir location
REM If it finds the file, it will then call virtualdub.exe w/the parameters
REM and the .vcf profile for virtualdub

for /f "tokens=1 delims=." %%i in ('dir /s/b "%idir%\*-?.VPrj"') do if EXIST "%%i.VPrj" (virtualdub.exe /s"tvshows.vcf" -p"%%i.mpg","%%i.avi" -q /r /x /c)

REM this section cleans up the old files and moves the avi to the odir

for /f "tokens=1 delims=." %%i in ('dir /b "%idir%\*-?.avi"') do if EXIST "%idir%\%%i.avi" (move "%idir%\%%i.avi" "%odir%\%%i.avi")
for /f "tokens=1 delims=." %%i in ('dir /b "%odir%\*-?.avi"') do if EXIST "%odir%\%%i.avi" (del "%idir%\%%i.log")
for /f "tokens=1 delims=." %%i in ('dir /b "%odir%\*-?.avi"') do if EXIST "%odir%\%%i.avi" (del "%idir%\%%i.txt")
for /f "tokens=1 delims=." %%i in ('dir /b "%odir%\*-?.avi"') do if EXIST "%odir%\%%i.avi" (del "%idir%\%%i.VPrj")
for /f "tokens=1 delims=." %%i in ('dir /b "%odir%\*-?.avi"') do if EXIST "%odir%\%%i.avi" (del "%idir%\%%i.ccno")

REM This line removes the original mpg movie if the avi is created and moved successfully to the odir

for /f "tokens=1 delims=." %%i in ('dir /b "%odir%\*-?.avi"') do if EXIST "%idir%\%%i.mpg" (del "%idir%\%%i.mpg
)
Reply With Quote
  #6  
Old 03-14-2005, 08:46 PM
seamonkey420 seamonkey420 is offline
Sage User
 
Join Date: Mar 2005
Posts: 49
updated to remove orphaned files (log, ccno, txt, VPrj)

an updated batch, now cleans up orphaned files too...
copy and paste into a text file, then rename to whatever.bat


Quote:
@echo off
REM Seamonkey420's SageTV Batch File
REM created on: 3/14/05
REM RECOMMENDED TO TEST IN A TEMP DIR FIRST!!

REM Setup as is, it will encode mpg to divx, then
REM clean up the log, txt, ccno and VPrj files
REM Then moves the avi file to a new folder (odir)
REM Then finally deletes the original mpg


REM Be sure to put this batch file in the same folder as your Virtualdub.exe file
REM ALSO Be sure to create a .vcf settings file in Virtualdub
REM This file then needs to be saved in the same folder as virtualdub.exe and this batch file


REM SETS SCRIPT VARIABLES, ie folder paths for files to be encoded
REM and where to save files and locations of WMEncoder main script

set idir=M:\TV Shows
set odir=M:\TV Shows\encoded


REM this line checks for a .VPrj file in the idir location
REM If it finds the file, it will then call virtualdub.exe w/the parameters
REM and the .vcf profile for virtualdub

for /f "tokens=1 delims=." %%i in ('dir /s/b "%idir%\*-?.VPrj"') do if EXIST "%%i.VPrj" (virtualdub.exe /s"tvshows.vcf" -p"%%i.mpg","%%i.avi" -q /r /x /c)

REM this section cleans up the old files and moves the avi to the odir

for /f "tokens=1 delims=." %%i in ('dir /b "%idir%\*-?.avi"') do if EXIST "%idir%\%%i.avi" (move "%idir%\%%i.avi" "%odir%\%%i.avi")
for /f "tokens=1 delims=." %%i in ('dir /b "%odir%\*-?.avi"') do if EXIST "%odir%\%%i.avi" (del "%idir%\%%i.log")
for /f "tokens=1 delims=." %%i in ('dir /b "%odir%\*-?.avi"') do if EXIST "%odir%\%%i.avi" (del "%idir%\%%i.txt")
for /f "tokens=1 delims=." %%i in ('dir /b "%odir%\*-?.avi"') do if EXIST "%odir%\%%i.avi" (del "%idir%\%%i.VPrj")
for /f "tokens=1 delims=." %%i in ('dir /b "%odir%\*-?.avi"') do if EXIST "%odir%\%%i.avi" (del "%idir%\%%i.ccno")

REM This line removes the original mpg movie if the avi is created and moved successfully to the odir

for /f "tokens=1 delims=." %%i in ('dir /b "%odir%\*-?.avi"') do if EXIST "%idir%\%%i.mpg" (del "%idir%\%%i.mpg
)

REM Cleans up any orphaned files, looks to see if there the mpg exists, if not, deletes the
REM orphaned files

for /f "tokens=1 delims=." %%i in ('dir /b "%idir%\*-?.txt"') do if NOT EXIST "%idir%\%%i.mpg" (del "%idir%\%%i.log")
for /f "tokens=1 delims=." %%i in ('dir /b "%idir%\*-?.txt"') do if NOT EXIST "%idir%\%%i.mpg" (del "%idir%\%%i.ccno")
for /f "tokens=1 delims=." %%i in ('dir /b "%idir%\*-?.txt"') do if NOT EXIST "%idir%\%%i.mpg" (del "%idir%\%%i.VPrj")
for /f "tokens=1 delims=." %%i in ('dir /b "%idir%\*-?.txt"') do if NOT EXIST "%idir%\%%i.mpg" (del "%idir%\%%i.txt")
peace
seamonkey420

Last edited by seamonkey420; 03-15-2005 at 07:26 PM.
Reply With Quote
  #7  
Old 03-14-2005, 09:12 PM
seamonkey420 seamonkey420 is offline
Sage User
 
Join Date: Mar 2005
Posts: 49
Smile Another quickie batch file for windows media encoder and broadcasting

a quickie script to broadcast/stream movie/tv files in a specific folder via windows media encoder to the web or network

Use windows scheduler to setup a broadcast schedule!

Requirementes/Notes:
-this requires to have Windows Media Encoder installed
-requires a .prx windows media encoder profile to be saved in same folder as encoder folder (ie C:\Program Files\Windows Media Components\Encoder )
-also put batch file in same folder as .prx (C:\Program Files\Windows Media Components\Encoder)


Be sure to configure the bdir parameter for the folder of files, you want to broadcast, also the port parameter, and the filetype parameter.

To view the broadcast, just open up winamp or windows media player and open the IP of the computer broadcaster or if on the network, computer name and port
examples:

tvserver:8001
http://mytvserver.dyndns.org:8001

here's the quickie batch file. this is another batch file that could prob be used with a few more options/lines to be super useful, i'm thinking of having it broadcast a simpsons episode at 4pm each day... hehe..

Quote:
@echo on
REM Seamonkey420's SageTV Windows Media Encoder
REM autostreamer batch file
REM
REM created on: 3/14/05
REM RECOMMENDED TO TEST IN A TEMP DIR FIRST!!


REM SETS SCRIPT VARIABLES, set folder where files to be streamed are located
REM and set the port, default to 8001 and the file type to broadcast, default avi

set bdir=M:\TV Shows\encoded
set port=8001
set filetype=avi


REM this line checks for a .avi file in the bdir location
REM If it finds the file(s), it will then call cscript (windows media encoder)
REM and broadcast the playback of ALL files in the directory with an .avi extension using profile tvshows.prx


for /f "tokens=1 delims=." %%i in ('dir /b "%bdir%\*-?.%filetype%"') do if EXIST "%bdir%\%%i.%filetype%"

(cscript.exe wmcmd.vbs -input "%bdir%\%%i.%filetype%" -author seamonkey420 -description %%i -broadcast %port% -loadprofile tvshows.prx)
peace
seamonkey420
Attached Files
File Type: zip stream.zip (628 Bytes, 310 views)

Last edited by seamonkey420; 03-15-2005 at 07:27 PM.
Reply With Quote
  #8  
Old 03-15-2005, 07:22 PM
seamonkey420 seamonkey420 is offline
Sage User
 
Join Date: Mar 2005
Posts: 49
Lightbulb another udpated batch, now creates folder with current date!

well.. been doing more tweaking and realized that my files are starting to be come very unorganized and hard to deal with...


so now i updated the batch file to create a subfolder in the odir location with the current date in the mmddyyyy format (ie 03152005 ).

i have been thinking of trying to get it to create more subfolders with just the show name but thats pretty hard right now with the way sagetv names files, no delimiter just case changes...

oh well..

but here's a zip of the new divx encoding/cleanup batch and virtualdub and a sample .vcf profile of mine and a .prx (windows media encoder) profile.

peace
seamonkey420


ps i'm planning on doing another updated batch file to do the same thing that this one does but also have it create a new batch file with the movie names in it that will in turn broadcast the finished encoded avis using windows media encoder...

:-P
Attached Files
File Type: zip VirtualDub mpeg version and automated divx encoding.zip (682.8 KB, 345 views)
Reply With Quote
  #9  
Old 03-19-2005, 12:30 PM
seamonkey420 seamonkey420 is offline
Sage User
 
Join Date: Mar 2005
Posts: 49
FINALLY! integration into SageTV (cayars stv) and more!

another update to my original batch file for
MPG to Divx encoding, automated solutions..
and integrating into Cayars STV!


this new update did the same things as the original but now can be integrated into Cayars STV or anyother STV that uses the Dyanmic Menu addon.

This also creates a webpage where it embeds the encoded avi file into so you can then just view the webpage and watch the avi in a browser...

to integrate it into Cayars, i did the following:

in the C:\Program Files\Frey Technologies\SageTV\STVs\OriginalV2\cayars\External folder, i copied the DVDrip.cmd to Encode.cmd

then i edited the Encode.cmd file with this info (again, this needs to be changed to how your system/virtualdub folders)
___
REM Modified by seamonkey420
REM 3/19/05 for Cayars Ultimate STV
REM This will let you add a new menu item in Cayars STV
REM to encode archived/watched shows in SageTV!!!
REM below i first go to the P: drive
REM Then change directory to the where my virtualdub is installed
REM Then run it in a miminized window, in the background!!!!


P:
cd "Audio Video and DVD\DVD Ripping\VirtualDub1.5"
start /MIN cmd /C "P:\Audio Video and DVD\DVD Ripping\VirtualDub1.5\convert.bat"
exit
____________


then i opened up SageTV and loaded Cayars Ultimate STV

then i right clicked, add new menu item > external program:

then for external program, use:
cmd.exe

then for parameters use:
/c "C:\Program Files\Frey Technologies\SageTV\STVs\OriginalV2\cayars\External folder, i copied the DVDrip.cmd to Encode.cmd"

(points to the Encode.cmd which in turns calls our convert.bat script!)

then enter a menu name:

now just right click and do a Save Definitions.

and BOOM! you now have an easy quick link to encode watched movies to divx.. it will run the encode batch in a minimized window and does not kill your system resourcse too bad either!


oh yea, be sure to again put the convert.bat file in your virtual dub folder, along wtih the tvshows.vcf and also be sure to modify the odir and idir variables to match your system in the convert.bat..
and also put the embedE.txt and embedS.txt into your virtualdub folder too...!

oh yea, i also included virtualdub mpeg version too (in case you don't have the mpg version..)

peace
seamonkey420
peace
Attached Files
File Type: zip encode and embed batch.zip (681.8 KB, 316 views)
__________________
My HTPC:
Athon 64 3000+ 939 | MSI ATI Xpress2 Chipset mobo
ATI X600XT pci-e | Avermedia PVR 150MCE
200GB + 80GB int HD, 100GB ext
NmediaPC HTPC case w/remote/keyboard
19" & 15" LCD monitors

Sony PSP
"knowledge is power, spread the power"
http://seamonkey420.tech-recipes.com
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


All times are GMT -6. The time now is 11:09 PM.


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