AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VideoCut-&-Convert DVD/VOB/TV to MPEG2 _TV-RECORD

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
garry



Joined: 19 Apr 2005
Posts: 1186
Location: switzerland

PostPosted: Sat Aug 23, 2008 6:21 pm    Post subject: VideoCut-&-Convert DVD/VOB/TV to MPEG2 _TV-RECORD Reply with quote

MODIFIED=20080824
example with mencoder.exe and mplayer.exe and vlc.exe
convert DVD/VOB/TV to MPEG2
Cut MPEG2 [begintime-endtime]
Television play and record to MPEG2






Code:
MODIFIED   =20080824
FILENAMERTS=VIDEOCUT_%MODIFIED%

;========================================================================================================================
/*
NEEDS ....................  mencoder.exe  mplayer.exe
                            VLC.exe
DOWNLOAD here ............  http://www1.mplayerhq.hu/MPlayer/releases/win32/MPlayer-mingw32-1.0rc1.zip
                            http://www.videolan.org/


How To use ...............  DVD/VOB/TV convert to MPEG2
                            TV play and record to MPEG2
                            CUT selected MPEG2 [ begintime-endtime ]


                            PLAY selected file or drive  like >  d 3-6  plays tracks 3-6 from DVD
                            PLAY from selected track / chapter / time



                            select drive [example d:\ ]  ( or select file )
                            d 2-3           > PLAY    plays    tracks 2-3
                                            > CONVERT converts tracks 2-3 to MPEG2



LINKs ....................  http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide
                            http://www.heise.de/software/download/o0g0s0l11k65
                            http://www.mydigitallife.info/2006/12/14/free-online-flv-converters/
                            http://www.mplayerhq.hu/design7/dload.html
                            http://wiki.videolan.org/Main_Page


*/
;========================================================================================================================



#NoEnv
setworkingdir, %a_scriptdir%
;DetectHiddenWindows On

transform,TFF,chr,127

Gui,3:Color,black
Gui,3:Font,  S10 CDefault , Lucida Console



REC         =c:\_RECORDED1                                ;---- <<< place for recorded
MPLC        ="C:\Programme\K-Lite Codec Pack\Media Player Classic\mplayerc.exe"   ;for TEST
VLC         =%A_programfiles%\VideoLAN\VLC\vlc.exe

;================== BEGIN MENU ===========================================
;---------- SUBMENUS ----------------------------
Menu, SOUND  , Add, Volume        ,volume
Menu, SOUND  , Add, Volume-Record ,volumeRecord


;------ tools ----------------------
Menu, BBBB, Add, Sound           ,:Sound          ;<<
Menu, BBBB, Add,
Menu, BBBB, Add, Display         , Display1


;------ file -----------------------
Menu, AAAA, Add, &About          , Help
Menu, AAAA, Add, &Exit           , FileExit


;---------- LINKS -----------------
Menu, CCCC, Add, Downloads1              ,Downloads1
Menu, CCCC, Add, Downloads2              ,Downloads2
Menu, CCCC, Add, Download VLC            ,Downloads3
Menu, CCCC, Add, MencoderWIKI1           ,Mencoderwiki1
Menu, CCCC, Add, MencoderWIKI2           ,Mencoderwiki2


Menu, MyMenuBar, Add, &File , :AAAA
Menu, MyMenuBar, Add, &TOOLS, :BBBB
Menu, MyMenuBar, Add, &Links, :CCCC

Gui,3: Menu, MyMenuBar
;==============  END MENU =================================================

TEXTCOLOR=Yellow
EDITCOLOR=Red

Gui,3:Add,Text,c%textcolor%  x5     y10     h20  w105                      ,DESTINATION
Gui,3:Add,Edit,c%editcolor%  x120   y10     h20  w500  vSDEST   Readonly   ,

Gui,3:Add,Text,c%textcolor%  x5     y40     h20  w105                       ,FILE conv=vob
Gui,3:Add,Edit,c%editcolor%  x120   y40     h20  w350  vSSOURCE1 Readonly   ,

Gui,3:Add,Button,            x480   y40     h20   w70   gFileselect       ,<SELECT
Gui,3:Add,Button,            x560   y40     h20   w65   gPLAY1            ,<PLAY       ;play file mplayerc

Gui,3:Add,Text,c%textcolor%    x5     y70     h20  w105            ,DVD
Gui,3:Add,Edit,c%editcolor%    x120   y70     h20  w40   vDRIVEX   ,
Gui,3:Add,Edit,c%editcolor%    x170   y70     h20  w70   vTRACK    ,
Gui,3:Add,Edit,c%editcolor%    x250   y70     h20  w70   vCHAPTER  ,
Gui,3:Add,Text,c%textcolor%    x120   y93     h20  w40             ,DRIVE
Gui,3:Add,Text,c%textcolor%    x170   y93     h20  w40             ,TRACK
Gui,3:Add,Text,c%textcolor%    x250   y93     h20  w80             ,CHAPTER

Gui,3:Add,Edit,c%editcolor%    x340   y70     h20  w100   vBEGINPLAY      ,00:00:00
Gui,3:Add,Text,c%textcolor%    x340   y93     h20  w105                   ,hh:mm:ss


Gui,3:Add,Button,              x120   y130    h20   w270   gSTART1  ,CONVERT DVD or xy.VOB > MPG
Gui,3:Add,Button,              x120   y160    h20   w270   gTEST1   ,CONVERT FLV > AVI

Gui,3:Add,Button,              x560   y130    h20   w65    gCLEAR1  ,CLEAR

Gui,3:Add,Button,              x480   y70    h20   w70   gFileselectFolder ,<SELECT
Gui,3:Add,Button,              x560   y70    h20   w65   gPLAY2            ,<PLAY       ;play drive
Gui,3:Add,Button,              x480   y95    h20   w145  gPLAYMENU2        ,<PLAY-MENU


Gui,3:Add,Text,c%textcolor%    x10    y200    h20  w105                   ,CUT
Gui,3:Add,Edit,c%editcolor%    x120   y200    h20  w100   vBEGINTIME      ,00:00:00.00
Gui,3:Add,Edit,c%editcolor%    x230   y200    h20  w100   vENDTIME        ,00:00:00.00
Gui,3:Add,Text,c%textcolor%    x123   y223    h20  w105                   ,hh:mm:ss.ms
Gui,3:Add,Text,c%textcolor%    x233   y223    h20  w105                   ,hh:mm:ss.ms

Gui,3:Add,Button,              x350   y200    h20   w100   gSTART3  ,<CUT-MPG



;------ LASTLINE TEST
Gui,3:Add,Text,c%textcolor%    x10    y250    h20  w105                          ,PROCESS
Gui,3:Add,Edit,c%editcolor%    x120   y250    h20  w500   vLASTLINE    ReadOnly  ,

Gui,3:Add,Edit,c%editcolor%    x350   y300    h20  w275   vRECORDLINE  ReadOnly   ,


Gui,3:Add,Button,              x10    y300    h20  w100   gHILVERSUM        ,HILVERSUM
Gui,3:Add,Button,              x120   y300    h20  w100   gHILVERSUMRECORD  ,<RECORD
Gui,3:Add,Button,              x230   y300    h20  w100   gFOLDER2          ,FOLDER


GuiControl,3:Focus,DRIVEX
Gui,3:Show,            x100   y20     h340  w640 ,%FILENAMERTS%
return
;-------------------------------------------------------------------




;------------TELEVISION EXAMPLE make a listview -------------------------------------------
;================ TV PLAY RECORD ==========================================================

hilversum:
PID3=
URL1=mms://livemedia.omroep.nl/nos_hilversumbest-bb
run,%VLC% %URL1%,,,PID1
GuiControl,3:,Lastline,TV HILVERSUM PLAY
settimer,AAS5,1000
return

hilversumrecord:
URL1 =mms://livemedia.omroep.nl/nos_hilversumbest-bb
WHERE=%REC%\%A_now%_HILVERSUM.mpg
BBBB= :sout=#transcode{vcodec=mp2v,vb=1024,scale=1,acodec=mp3,ab=192,channels=2}:duplicate{dst=std{access=file,mux=ts,dst="%WHERE%"}}
run,%vlc% %URL1% %BBBB%,,,PID2
GuiControl,3:,Recordline,%TFF%%TFF%--TV HILVERSUM RECORD
settimer,AAS6,1200
return


AAS5:
Process, WaitClose, %PID1%,.2
if ErrorLevel ; The PID still exists.
       return
   else
   {
   GuiControl,3:,Lastline,
   settimer,AAS5,off
   return
   }
return


AAS6:
Process, WaitClose, %PID2%,.2
if ErrorLevel ; The PID still exists.
       return
   else
   {
   GuiControl,3:,Recordline,
   settimer,AAS6,off
   return
   }
return
;=======================================================================================



FOLDER2:
run,%rec%
return


downloads1:
run,http://www.mplayerhq.hu/design7/dload.html
return

downloads2:
run,http://www1.mplayerhq.hu/MPlayer/releases/win32/MPlayer-mingw32-1.0rc1.zip
return

downloads3:
run,http://www.videolan.org/
return

mencoderwiki1:
run,http://gentoo-wiki.com/TIP_MEncoder_Tips_and_Tricks
return

mencoderwiki2:
run,http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide
return


help:
msgbox,%MODIFIED%`nThis is a small programm to Convert DVD/VOB to MPEG2 and CUT MPEG
return

volume:
run,sndvol32
return

volumerecord:
run,sndvol32 /rec
return

display1:
run,c:\windows\system32\Desk.cpl
return
;--------------------------------------------------------------------------






FILESELECT:
DRIVEX=
TRACK=
CHAPTER=
 GuiControl,3:,DRIVEX,
 GuiControl,3:,TRACK,
 GuiControl,3:,CHAPTER,
 GuiControl,3:,Lastline,

SelectedFile=
FileSelectFile, SelectedFile, 3, , Select file to open, Video files (*.flv;*.vob;*.mpg;*.avi;*.divx)
GuiControl,3:,SSOURCE1,%SelectedFile%
SplitPath,SelectedFile, name, dir, ext, name_no_ext, drive
GuiControl,3:,SDEST,
return
;------------------------------------------------------------------



FILESELECTFOLDER:
DRIVEX=
TRACK=
CHAPTER=
 GuiControl,3:,DRIVEX,
 GuiControl,3:,TRACK,
 GuiControl,3:,CHAPTER,
 GuiControl,3:,SDEST,
 GuiControl,3:,SSOURCE1,
 GuiControl,3:,Lastline,

FileSelectFolder, OutputVar, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}
DRIVE2=%OUTPUTVAR%
stringmid,OV22,outputvar,1,1
GuiControl,3:,DRIVEX,%OV22%
return
;------------------------------------------------------------------






CLEAR1:
 GuiControl,3:,SSOURCE1,
 GuiControl,3:,DRIVEX,
 GuiControl,3:,TRACK,
 GuiControl,3:,CHAPTER,
 GuiControl,3:,SDEST,
 GuiControl,3:,Lastline,

return


;========================= PLAY-1 FILE MPLAYERC =======================================
PLAY1:
Gui,3:submit,nohide
   if selectedfile=
      return
   INPUT ="%selectedfile%"
   SplitPath,SELECTEDFILE, name, dir, ext, name_no_ext, drive
   stringmid,ext,ext,1,3
   INPUTNAME=%name_no_ext%.%ext%

GuiControl,3:,lastline,Plays %inputname%
;runwait,%MPLC% %INPUT%
runwait,%input%
GuiControl,3:,lastline,Play finished
  sleep,3000
  GuiControl,3:,lastline,
return
;=================== END PLAY ==============================================


;========================= PLAY-2 DRIVE VLC or mplayer =====================
PLAYMENU2:
Gui,3:submit,nohide
   if DRIVEX=
      return

;run,%vlc% dvd://d:

INPUT   =dvd://%DRIVEX%:
GuiControl,3:,lastline,Plays %DRIVEX%
runwait,%VLC% %INPUT%
GuiControl,3:,lastline,PLAY finished
    sleep,3000
    GuiControl,3:,lastline,
return


;------------------------------------------------------------
PLAY2:
Gui,3:submit,nohide
   if DRIVEX=
      return

gosub,playtimecalculation     ;>>>>>>>>>>>>>>>> (VLC)


   stringlen,L2,DRIVEX
     if L2=1
        drive2=%DRIVEX%:\

DriveGet, status, statusCD,%drive2%
if status=open
  {
  msgbox,Drive %drive2%  is  %status%  or not ready
  return
  }

   if TRACK=
      TRACK=1

/*
;------- for mplayer ------------------
   if chapter<>
      CHAPTER1=-chapter %CHAPTER%
     else
      CHAPTER1=
;--------------------------------------
*/


;--------- for VLC --------------------
   if chapter<>
      CHAPTER1=%CHAPTER%
     else
      CHAPTER1=
;--------------------------------------

    ;INPUT   =-ss %BEGINPLAY% -dvd-device %DRIVEX%: dvd://%TRACK% %CHAPTER1%      ;<<< for mplayer

    INPUT   =--start-time %SEC% dvdsimple://%DRIVEX%:\@%TRACK%:%CHAPTER1%         ;  (VLC)

msgbox,%INPUT%
GuiControl,3:,lastline,Plays %DRIVEX% TRACK=%TRACK% CHAPTER=%CHAPTER1%
;runwait,%comspec% /c mplayer %INPUT% -softvol,,hide
runwait,%VLC% %INPUT%
GuiControl,3:,lastline,PLAY finished
    sleep,3000
    GuiControl,3:,lastline,
return
;=================== END PLAY ==============================================










;======================== CONVERT DVD-VOB>MPG =====================================
START1:
Gui,3:submit,nohide
FAIL=0
gosub,namecontrol
if FAIL=1
   {
   msgbox,FAIL=1
   return
   }


   SplitPath,input, name, dir, ext5, name_no_ext, drive
   stringmid,ext5,ext5,1,3
   if selectedFile<>
      {
      if ext5<>vob
        {
        msgbox,Not a FILE.vob
        return
        }
      }


     GuiControl,3:,lastline,Converts %inputname% to %destname% MPEG2
     runwait, %comspec% /c mencoder %INPUT% -of mpeg -oac copy -ovc copy -o %DESTFILE%


GuiControl,3:,lastline,Plays converted %destname%
;runwait,%comspec% /c mplayer %DESTFILE% -softvol,,hide
runwait,%DESTFILE%
     GuiControl,3:,lastline,PLAY finished
     sleep,3000
     GuiControl,3:,lastline,
return
;--------------------------------------------------------------------







;----- EXAMPLE ------------------------ CUT MPEG2 ----------------------------------------
START3:
Gui,3:submit,nohide
if (selectedfile="" AND DRIVEX="")
   {
   msgbox,Nothing selected
   return
   }

SplitPath,SELECTEDFILE, name, dir, ext, name_no_ext, drive
if ext<>mpg
   {
   msgbox,Cut only MPG files
   return
   }


CUTMPG=1
INPUT=
DESTFILE=
FAIL=0
gosub,namecontrol
CUTMPG=0
gosub,datecalculation
if FAIL=1
   return

if SEC<3
   {
   msgbox,DIFFERENCE is smaller then 3 seconds
   return
   }
;msgbox, %comspec% /k mencoder %INPUT% -of mpeg -ovc copy -oac copy -ss %BEGINTIME%.00 -endpos %ABCD%.00 -o %DESTFILE%

GuiControl,3:,lastline,CUT %inputname% to %destname% %BEGINTIME%  %ENDTIME%
runwait,%comspec% /c mencoder %INPUT% -of mpeg -ovc copy -oac copy -ss %BEGINTIME%.00 -endpos %ABCD%.59 -o %DESTFILE%,,hide
GuiControl,3:,lastline,CUT finished


ifexist,%DESTFILE%
   {
   GuiControl,3:,lastline,Plays converted %destname%
   ;runwait,%comspec% /c mplayer %DESTFILE% -softvol,,hide
   runwait,%DESTFILE%
   GuiControl,3:,lastline,PLAY finished
   sleep,3000
   }
else
   {
   msgbox, No success to CUT the file %INPUTNAME%
   }

GuiControl,3:,lastline,
return







;----------------------- GOSUBS -----------------------------
NAMECONTROL:
Gui,3:submit,nohide
FAIL=0

if (selectedfile="" AND DRIVEX="")
   {
   msgbox,Nothing selected
   FAIL=1
   return
   }


if selectedfile<>
   {
   INPUT ="%selectedfile%"
   SplitPath,SELECTEDFILE, name1, dir1, ext1, name_no_ext1, drive1
   stringmid,ext1,ext1,1,3
   INPUTNAME=%name_no_ext1%.%ext1%

      if CUTMPG=1
         {
         DESTFILE=%REC%\%name_no_ext1%_DIVIDE.mpg
         DESTNAME=%name_no_ext1%_DIVIDE.mpg
         goto,checkname
         }



   DESTFILE=%REC%\%name_no_ext1%.mpg
   DESTNAME=%name_no_ext1%.mpg

   SplitPath,DESTFILE, name2, dir2, ext2, name_no_ext2, drive2
   if (ext1=ext2)
     {
     msgbox,Extension is SAME`nSelect VOB to convert it MPG
     FAIL=1
     return
     }
  gosub,checkname
  }


 else
   {
   if chapter<>
      CHAPTER1=-chapter %CHAPTER%
     else
      CHAPTER1=
   INPUT   =-dvd-device %DRIVEX%: dvd://%TRACK% %CHAPTER1%
   name7    =DRIVE_%DRIVEX%_%TRACK%_%CHAPTER%.mpg
   DESTFILE  =%REC%\%name7%
   DESTNAME  =%name7%
   gosub,checkname
   }
return



;-----------------------------------------------------------------
CHECKNAME:
ifexist,%DESTFILE%
   {
   SplitPath,DESTFILE, name, dir, ext, name_no_ext, drive
   name=%A_now%_%name%
   DESTFILE=%REC%\%name%
   DESTNAME=%name%
   }
GuiControl,3:,SDEST,%DESTFILE%
return










;------------------------PLAYTIME-CALCULATION --------------------------
PLAYTIMECALCULATION:
Gui,3:submit,nohide
FAIL=0
V1=20050709
DEFAULTTIME=000000
;PLAYTIME   =%BEGINPLAY%

stringreplace,playtime2,beginplay,`:,%nothing%,all
stringmid,playtime2    ,playtime2  ,1,6

d1=%V1%%DEFAULTTIME%
d2=%V1%%PLAYTIME2%

Envsub,d1,d2,s
transform,d1a,ABS,d1
SEC =%d1a%
AA:=(FormatSeconds(SEC))
ABCD=0%AA%
return

;--------------------- END PLAY-TIME-CALCULATION -------------------------------------














;------------------------DATECALCULATION --------------------------
DATECALCULATION:
Gui,3:submit,nohide
FAIL=0
;--- parameter -ss needs the time-difference

;    00:01:30.00      00:02:45.00      >from-until, difference is 75 seconds
;    00:01:30.00      00:01:15.00      <CONVERTED , difference here

V1=20050709
stringreplace,begintime2,begintime,`:,%nothing%,all
stringreplace,endtime2,endtime,`:,%nothing%,all
stringmid,millisec  ,endtime2  ,7,3
stringmid,begintime2,begintime2,1,6
stringmid,endtime2  ,endtime2  ,1,6


d1=%V1%%BEGINTIME2%
d2=%V1%%ENDTIME2%

BD1:=d1
BD2:=d2
if (BD1>=BD2)
   {
   msgbox,BEGINTIME must be smaller then ENDTIME
   FAIL=1
   return
   }

Envsub,d1,d2,s
transform,d1a,ABS,d1
SEC =%d1a%
AA:=(FormatSeconds(SEC))
ABCD=0%AA%%millisec%
msgbox,SECONDS=%SEC%`nBEGINTIME=%BEGINTIME%   ENDTIME=%ENDTIME%`nBEGINTIME=%BEGINTIME%   ENDDIFF=%ABCD%
return

;------------------------------ FORMULA -----------------------------------------------------
FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
    time = 19990101  ; *Midnight* of an arbitrary date.
    time += %NumberOfSeconds%, seconds
    FormatTime, mmss, %time%, mm:ss
    return NumberOfSeconds//3600 ":" mmss  ; This method is used to support more than 24 hours worth of sections.
}
return
;--------------------- END DATECALCULATION -------------------------------------








;-------------------------------------------------------------------
FLV2AVI:
TEST1:
Gui,3:submit,nohide

if (selectedfile="" AND DRIVEX="")
   {
   msgbox,Nothing selected
   return
   }

if (selectedfile<>"" AND DRIVEX<>"")
   {
   msgbox,Don't both select [ Drive and file ]
   return
   }


if selectedfile<>
   {
   INPUT ="%selectedfile%"
   SplitPath,SELECTEDFILE, name, dir, ext, name_no_ext, drive
   stringmid,ext,ext,1,3
   INPUTNAME=%name_no_ext%.%ext%
   }

 else

   {
   if TRACK=
      TRACK=1

   if chapter<>
      CHAPTER1=-chapter %CHAPTER%
     else
      CHAPTER1=
   INPUT    =-dvd-device %DRIVEX%: dvd://%TRACK% %CHAPTER1%
   name7    =DRIVE_%DRIVEX%_%TRACK%_%CHAPTER%.mpg
   DESTFILE =%REC%\%name7%
   gosub,checkname
   }




;------------- PLAY TEST ----------------------------
;run,%INPUT%
;runwait,%comspec% /c mplayer %INPUT%
;run,%MPLC% %INPUT%
;return


; --- convert FLV2AVI  TEST  --------------------------------------
;-----mencoder.exe   = older version 9321 kB convert FLV2AVI
if ext=flv
  {
  ifexist,mencoder.exe
    {
    GuiControl,3:,SDEST,%REC%\output.avi
    GuiControl,3:,lastline,Converts %name_no_ext%.%ext% >> output.avi
    runwait, %comspec% /c mencoder %INPUT% -ofps 15 -vf scale=300:-2 -oac lavc -ovc lavc -lavcopts vcodec=msmpeg4v2:acodec=mp3:abitrate=64 -o %REC%\output.avi,,hide
    GuiControl,3:,lastline,Plays output.avi
    runwait,%REC%\output.avi
    GuiControl,3:,lastline,Play finished
    sleep,3000
    GuiControl,3:,lastline,
    GuiControl,3:,SDEST,
    return
    }
  else
    msgbox,mencoder.exe not exist
  return
  }

else
  {
  msgbox,extension must be FLV to convert xy.flv to output.avi
  return
  }
return

;======================================================================================




;-------------------------------------------------------------------
3guiclose:
Fileexit:
exitapp
;-------------------------------------------------------------------
Back to top
View user's profile Send private message
shajul



Joined: 15 Sep 2006
Posts: 33
Location: India

PostPosted: Wed Sep 03, 2008 5:40 am    Post subject: very nice! Reply with quote

very nice work!
Back to top
View user's profile Send private message Yahoo Messenger
SpiderGames



Joined: 09 Jun 2008
Posts: 464
Location: Canada

PostPosted: Thu Sep 04, 2008 10:40 am    Post subject: Reply with quote

nice
_________________

Xfire: SpiderGames77
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group