majstang Posted March 6, 2011 Share Posted March 6, 2011 (edited) Automatic Commercial Removal script Features: - Removes commercials automatically from recordings and launched right after Recording Service finish the recording. Done via a so-called "after recording task". Works only with Recording Service. - Supports automatic commercial removal on as many simultaneously recorded shows RS allows. - Removes commercials from both SD (MPEG-2) and HD (H.264) recordings. - Drag and drop support. Finished recordings can be dropped on script for removal of commercials. - Automatic Commercial Removal script can be combined with intelligent hibernation. - Hidden mode. All parts of the tools used for commercial removal in script can be hidden entirely if preferred. Required OS: Windows 7 32-bit. This is the only OS I tested the script with so far. It may work with XP and Vista. No support for 64-bit Windows though. Required tools: - Autohotkey_L Unicode 32-bit. Can be downloaded here: http://www.autohotkey.com/download/ - Comskip v.0.80.039 or later. (Comskip is freeware, but only the MPEG-2 version. Getting Comskip H.264 version requires a donation) - VideoReDo TVSuite H.264. Trial can be downloaded, but without registering for the trial key, it's limited to 15 minutes output. Once you register your trial, you're unlimited size for 15 days. (shareware $95.99) Important things to know about more limitations and other conditions before setup: - ALWAYS use .ts output format on your recordings. Script will NOT work with .mpg recordings. - Installing of Autohotkey_L Unicode 32-bit is a must. If having Autohotkey_Basic uninstall it and intstall Autohotkey_L and make sure to choose Unicode. If you have old Autohotkey_Basic scripts on HTPC it is not certain they will work with Autohotkey_L Unicode. For example the old Intelligent Hibernationscript won't work. I will post a new one in here which is adapted to work with both Autohotkey_L Unicode and the Automatic Commercial Removal script. - No support with DVBViewer (if using DVBViewer as a standalone recorder and no support for commercial removal on Live-TV ). - Drag and dropping recordings on script which is still in recording progress will not work. Use this feature for finished recordings only. I don't think there's a limit on how many recordings can be dropped on script at once for commercial removing. Tried 10 at once and all went good. - Script will have processing of H.264 recordings disabled as default. If buying Comskip H.264 enable this feature by activate this function in the PATH CONFIGURATION section. Unfortunately Comskip H.264 is very slow finding commercials in H.264 recordings. So slow I prefer to disable the H.264 feature in script and only remove commercials from MPEG-2 recordings. Fortunately for me my HD channels have no in-show commercials and I can live with the announcements in start and end. Later Comskip versions supports detetction with all four CPU cores simultaneously, which speeds up the process 100%. - I do recommend using my comskip.ini which works very well on both MPEG-2 and H.264 recordings. I will post it in here. Try to see to it that when comskip runs it only creates the .incommercial and .Vprj files. These are the only ones that will be removed after commercials has been removed and script finishes. If having .txt and .logo files still there tweak comskip.ini. Note: If Comskip often fails to detect in-show commercials you might need to tweak the comskip.ini. Visit Comskip forum for more info about this. - Multiple comskip.inis can be used. - No original recordings will be deleted when the commercial free one has been created. The commercial free recordings shall have it's own folder. There is an option for you to delete the original recording and move the commercial free one over to RS recording folder, but it is disabled. Use at own risk! - There is no way to run same recording through the Automatic Commercial Removal script twice. Script will alert you if trying this. Recording must be deleted or moved from the commercial free recording folder before you can run it through the script a second time. - It might be a good idea not using the Hidden Mode right away, at least until you are sure everything works as it should. When it's time to enable Hidden Mode just remove the semicolon in front of the line "Hide_commandline_userinterface" in the "PATHS AND CONFIGURATION" section, which activates it. - Intelligent Hibernation will not work if two recordings with same starttime finishes at the exact same time, due to a shortcoming in RS API. Tried to make RS developer listen to my plea to change this, but he haven't met the plea so far. Intelligent hibernation works fine in all other cases. - Lastly, I recommend this script to be used by people with moderate to advanced Windows knowledge/preferably also some coding knowledge and experienced DVBViewer users only. To newbies it might seem to be hard to setup and understand. I'll do my best to make the instructions on how to as easy as possible. I will not have much support for this script and have no plans on develop it further. Feel free to let me know if you find any bugs however, provided you are using Windows 7 32-bit. Well, that should cover it, now to setup. Basic Setup: - Install Autohotkey_L and choose Unicode during installation. - Install VideoRedo TVSuite H.264 in Program Files folder (located in same partition as OS). - Place Comskip in Program Files folder (Comskip does not have any installer). Copy the original comskip.ini and save it somewhere if you need it later. Copy all lines in my comskip.ini and replace all original lines in comskip.ini located in Comskip folder. - Copy the code in the Commercial Removal script below and paste it into an emty notepad sheet. Choose "save as" and name it CommercialRemover.ahk. Look for a box where the label says "Coding", choose UTF-8 and then press save button. Never choose "Unicode" as encoding. Rightclick the saved .ahk in explorer and choose "Compile script". This compiles the script to an executable (.exe). - Create the output folder where your commercial free recordings will end up. - IMPORTANT NOTE: the CommercialRemover.exe shall always be located in the output folder where your commercial free recordings will end up. So place your CommercialRemover.exe in there. Where ever the script is located it is here your commercial free recordings will end up. DO NOT place it in RS recording folder though! - For drag and drop use, create a shortcut of the CommercialRemover.exe and place it on the Desktop. From the explorer window you can now drag and drop recordings onto the shortcut on desktop. Commercials will then be removed from all recordings dropped on shortcut. Automatic Commercial Removal setup: NOTE: The script can be launched as an "After recording Task" from Recording Service. This makes commercial removal entirely automatic. After Recording service finishes the recording the Automatic Commercial Removal script will be executed. Using this kind of after recording task makes it hard to combine with Recording Service own Post record actions, such as standby, hibernation and shutdown. We do not want the HTPC to close down in the middle of an automatic commercial removal session. I therefor decided to combine automatic commercial removal with my intelligent hibernation script and intercept shutdown script. In this way standby, hibernation and shutdown gets put on hold until automatic commercial removal is done and then closes down HTPC. This is also the only way, I know, to be abled to execute more than one after recording task in Recording Service i.e. automatic commercial removal and hibernation. If you wanna know more about Intelligent hibernation you'll find it here: http://www.DVBViewer.tv/forum/topic/41387-another-intelligent-hibernationscript/ The reciever script: - Copy the code right below and paste it into an emty notepad sheet. Change the path to what path you choose for the InterceptReceiver.exe on the last line in the script. Choose "save as" and name it CommercialRemover.ahk. Look for a box where the label says "Coding", choose UTF-8 and then press save button. Rightclick the saved .ahk in explorer and choose "Compile script". This compiles the script to an executable (.exe). - Now, from the explorer make a shortcut of the .exe and drag it to the autostart folder on the start-menu. Start it manually if you dont wanna restart Windows at this point. Have in mind this script MUST be started before running the CommercialSender script from RS. The autostart takes care of the script is always running after startup. #NoTrayIcon While !DllCall("WaitNamedPipe","Str","\\.\pipe\InterceptShutdown","UInt",0xffffffff) Sleep, 500 Run % """" A_AhkPath """ \\.\pipe\InterceptShutdown" Sleep, 500 Run, InterceptReceiver.exe, D:\ScriptsForWindows7 The CommercialSender script: NOTE: The sender script launches the CommercialRemover.exe. It also specifies the rules of intelligent hibernation and retieves all needed information about RS status. This is the script that must be setup as the "After recording task" in Recording Service. - Locate "The Sender script" down below and copy it and paste it into an empty notepad sheet. Now comes an important bit. You now need to fill in some vital data. Without them script will fail: 1. In PATH, URL AND CONDITIONS CONFIGURATION section fill in which folder you choose to be your output folder where the commecialfree recordings will end up. Only edit the path between the quotes and make sure not to remove any of the quotes. Edited_Video_Folder := "C:\Your CommercialFreeOutPutfolder" 2. In the same section also fill in your username, password IP-number and portnumber to RS. - Choose "save as" and name it CommercialSender.ahk. Look for a box where the label says "Coding", choose UTF-8 and then press save button. Rightclick the saved .ahk in explorer and choose "Compile script". This compiles the script to an executable (.exe). This script can be placed where ever you want. - Rightclick the RS systrayicon and choose Configuration. Go to Tasks and create a new task. Name it CommercialSender and also type in the path for the CommercialSender.exe file (e.g. C:\CommercialSender.exe) in the Filenamebox or click the 3 dot button to the right and navigate to the CommercialSender.exe. Close the Task Editor and the Configuration window. - Open up RS webinterface. Click on Configuration-->Recorder. Under "Default recording actions" and "Default task after recording:" select the process task you created "CommercialSender". "Post record action" should be set to "Nothing". Save your new settings. Remember if you have search presets created before this step, they all have the old default task after recording inherited, so the change you just did wont have any effect on recordingtimers created with these old search presets. Simply bring up your searchpresets in the SearchEPG and manually edit them one by one until all old presets have the "CommercialSender" as the default task after recording. In SearchEPG this box is named "Task" only. Do not confuse this with "post record action", this box must use "Nothing". NOTE: This script can be tested by enabling the IniWrite lines (remove the semicolon in front of a line enables a codeline). Then you can check if script retrieves all needed values to make intelligent hibernation work. Script then creates an .ini file with this information in a folder of your choice. Intelligent hibernation feature can also be disabled if you for some reason don't want it. To do so add semicolons in front of all four: Allow_hibernate_....._..... lines in the PATH, URL AND CONDITIONS CONFIGURATION section. Then your after recording task will only perform automatic commercial removal. If disabling the intelligent hibernation feature you don't need this next script. The Intercept Shutdown script: NOTE: When the automatic commercial removal process is done this is the script that recieves if closedown of HTPC shall be executed according to the hibernation rules you have specified in the CommercialSender script. The default task for the Intercept shutdown script is hibernation. You can alter this by changing BDefault (ButtonDefault) to what closedown method you like to use. After 20 seconds of countdown this default closedown method will be executed per automatic. In the messagebox appearing you can also cancel the closedown within 20 seconds if you choose to. - Locate "The Intercept Shutdown script" down below and copy it and paste it into an empty notepad sheet. Choose "save as" and name it Intercept Shutdown.ahk. Look for a box where the label says "Coding", choose ANSI and then press save button. This script does not need to be saved in UTF-8 encoding, it works very well with ANSI. I do recommend you to choose ANSI here, cuz I haven't tested if everything works if saved as UTF-8 yet. Rightclick the saved .ahk in explorer and choose "Compile script". This compiles the script to an executable (.exe). Place this script where ever you want. - Now, from the explorer make a shortcut of the .exe and drag it to the autostart folder on the start-menu. Start it manually if you dont wanna restart Windows at this point. Have in mind this script MUST be started before running the CommercialSender script from RS. The autostart takes care of the script is always running after startup. Well, that should be it. Enjoy! Commercial Removal script #SingleInstance ignore ;---------------------------------------------------------------------------------------------------------- ;Activate/inactivate codelines by removing/adding the semicolon ";" infront of a line. ;---------------------------------------------------------------------------------------------------------- ;-PATHS AND CONFIGURATION---------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------------------- RS_Recording_folder := "D:\TV\Recording Service" ;Fill in path to RS Recording Folder PropCopy_location := "D:\AVI_VOB_BLU-RAY_AC3-tools\TV-tools\DVBViewer\PropCopy_1_2_2\PropCopy.exe" ;Fill in path to PropCopy Comskip_location := "C:\Program\Comskip\comskip.exe" ;Fill in path to Comskip VideoredoBatchLocation := "C:\Program\VideoReDoTVSuite4\vp.vbs" ;Fill in path to vp.vbs ;Use_H264_commercialdetetction := "H.264" ;H.264 commercial detetction only works with Comskip donators version. Free version MPEG-2 only. ;Hide_commandline_userinterface := "Hide" ;If activated hides commandline windows used by the script. ;---------------------------------------------------------------------------------------------------------- ;-CONDITIONING OF THE HIDE VARIABLE------------------------------------------------------------------------ ;---------------------------------------------------------------------------------------------------------- If Hide_commandline_userinterface Hide_commandline_userinterface := Hide_commandline_userinterface Else Hide_commandline_userinterface := %ErrorLevel% ;---------------------------------------------------------------------------------------------------------- ;-DRAG AND DROP FUNCTIONALITY------------------------------------------------------------------------------ ;---------------------------------------------------------------------------------------------------------- Loop %0% ; For each parameter (or file dropped onto a script): { GivenPath := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index. Loop %GivenPath%, 1 latest_file_drop = %A_LoopFileLongPath% SplitPath, latest_file_drop, OutFileNameDrop, OutDirDrop,, OutNameNoExtDrop latest_file_drop = %OutDirDrop%\%OutFileNameDrop% ;-RETRIEVE MEDIAFILE FORMAT - MPEG-2 OR H.264------------------------------------------------------------ File_properties := GetDetailsOf(latest_file_drop) RegExMatch(File_properties, "MPEG2", MPEG2) RegExMatch(File_properties, "H.264", H264) RegExMatch(File_properties, "TV3", TV3) RegExMatch(File_properties, "Sjuan", Sjuan) ;-CONDITIONING OF THE H.264 VARIABLE--------------------------------------------------------------------- If Use_H264_commercialdetetction = H.264 Use_H264_commercialdetetction := "H.264" Else Use_H264_commercialdetetction := ErrorLevel ;-COMSKIP FILE PROCESSING---------------------------------------------------------------------------------- Loop, %A_ScriptDir%\%OutNameNoExtDrop%.ts, , 0 latest_file_exist := A_LoopFileFullPath If latest_file_exist { MsgBox, 64, INTERRUPTION MESSAGE, %latest_file_exist%`nalready exists in output folder.`nScript will terminate in 15 seconds., 15 ExitApp } Else { If MPEG2 { If TV3 or Sjuan { Loop, %A_programfiles%\TV3.ini, , 1 ; Recurse into subfolders. TV3ini := A_LoopFileShortPath RunWait, %comspec% /c %Comskip_location% -t --videoredo --ini="%TV3ini%" "%latest_file_drop%",, %Hide_commandline_userinterface% } If TV3= { If Sjuan= RunWait, %comspec% /c %Comskip_location% -t --videoredo "%latest_file_drop%",, %Hide_commandline_userinterface% } } Else { If Use_H264_commercialdetetction = H.264 RunWait, %comspec% /c %Comskip_location% -t --videoredo "%latest_file_drop%",, %Hide_commandline_userinterface% } ;-VIDEOREDO FILE PROCESSING-------------------------------------------------------------------------------- Sleep, 3000 If MPEG2 RunWait, %comspec% /c cscript.exe //nologo "%VideoredoBatchLocation%" "%OutDirDrop%\%OutNameNoExtDrop%.VPrj" "%A_ScriptDir%\%OutNameNoExtDrop%.ts" /p:"MPEG2 Transport Stream" /q, , %Hide_commandline_userinterface% If H264 { If Use_H264_commercialdetetction = H.264 RunWait, %comspec% /c cscript.exe //nologo "%VideoredoBatchLocation%" "%OutDirDrop%\%OutNameNoExtDrop%.VPrj" "%A_ScriptDir%\%OutNameNoExtDrop%.ts" /p:"H.264 Transport Stream" /q, , %Hide_commandline_userinterface% } ;-PROPCOPY AND CLEANUP AFTER PROCESSING-------------------------------------------------------------------- RunWait, %PropCopy_location% "%OutDirDrop%\%OutNameNoExtDrop%.ts" "%A_ScriptDir%\%OutNameNoExtDrop%.ts" ;Metadata/Fileinfo copy FileRecycle, %OutDirDrop%\%OutNameNoExtDrop%.VPrj FileRecycle, %OutDirDrop%\%OutNameNoExtDrop%.incommercial ;Filemove, %A_ScriptDir%\%OutFileNameDrop%, %OutDirDrop%\%OutFileNameDrop%, 1 ;Moves edited recording and overwrites original recording. } } ;------------------------------------------------------------------------------------------------------------ ;-RS AFTER RECORDING TASK - COMMERCIAL PROCESSING WHEN RECORDINGS FINISHES----------------------------------- ;------------------------------------------------------------------------------------------------------------ If latest_file_drop = right_Now := a_now timelimit := right_Now EnvAdd, timelimit, -90, seconds FileList = b_index=0 Loop, %RS_Recording_folder%\*.ts { if A_LoopFileTimeModified between %timelimit% and %right_Now% { b_index++ file%b_index% := A_LoopFileFullPath ;FileList = %FileList%%A_LoopFileTimeModified%`t%b_index%`t%A_LoopFileName%`n ;Enable this line to debug with msgbox Please hit } } ;msgbox, 4, , Please hit ^c (while this is displayed) to copy to clipboard `n`n%FileList%`n`n%A_Now%, 10 Loop %b_index% { SplitPath, file%a_index%, OutFileName, OutDir,, OutNameNoExt latest_file = %OutDir%\%OutFileName% ;-RETRIEVE MEDIAFILE FORMAT - MPEG-2 OR H.264-------------------------------------------------------------- File_properties := GetDetailsOf(latest_file) RegExMatch(File_properties, "MPEG2", MPEG2) RegExMatch(File_properties, "H.264", H264) RegExMatch(File_properties, "TV3", TV3) RegExMatch(File_properties, "Sjuan", Sjuan) ;-CONDITIONING OF THE H.264 VARIABLE--------------------------------------------------------------------- If Use_H264_commercialdetetction = H.264 Use_H264_commercialdetetction := "H.264" Else Use_H264_commercialdetetction := ErrorLevel ;-COMSKIP FILE PROCESSING---------------------------------------------------------------------------------- Loop, %A_ScriptDir%\%OutNameNoExt%.ts, , 0 latest_file_exist := A_LoopFileFullPath If latest_file_exist { MsgBox, 64, INTERRUPTION MESSAGE, %latest_file_exist%`nalready exists in output folder.`nScript will terminate in 15 seconds., 15 ExitApp } Else { If MPEG2 { If TV3 or Sjuan { Loop, %A_programfiles%\TV3.ini, , 1 ; Recurse into subfolders. TV3ini := A_LoopFileShortPath RunWait, %comspec% /c %Comskip_location% -t --videoredo --ini="%TV3ini%" "%latest_file%",, %Hide_commandline_userinterface% } If TV3= { If Sjuan= RunWait, %comspec% /c %Comskip_location% -t --videoredo "%latest_file%",, %Hide_commandline_userinterface% } } Else { If Use_H264_commercialdetetction = H.264 RunWait, %comspec% /c %Comskip_location% -t --videoredo "%latest_file%",, %Hide_commandline_userinterface% } ;-VIDEOREDO FILE PROCESSING-------------------------------------------------------------------------------- Sleep, 3000 If MPEG2 RunWait, %comspec% /c cscript.exe //nologo "%VideoredoBatchLocation%" "%OutDir%\%OutNameNoExt%.VPrj" "%A_ScriptDir%\%OutNameNoExt%.ts" /p:"MPEG2 Transport Stream" /q, , %Hide_commandline_userinterface% If H264 { If Use_H264_commercialdetetction = H.264 RunWait, %comspec% /c cscript.exe //nologo "%VideoredoBatchLocation%" "%OutDir%\%OutNameNoExt%.VPrj" "%A_ScriptDir%\%OutNameNoExt%.ts" /p:"H.264 Transport Stream" /q, , %Hide_commandline_userinterface% } ;-PROPCOPY AND CLEANUP AFTER PROCESSING-------------------------------------------------------------------- RunWait, %PropCopy_location% "%RS_recording_folder%\%OutNameNoExt%.ts" "%A_ScriptDir%\%OutNameNoExt%.ts" ;Metadata/Fileinfo copy FileRecycle, %OutDir%\%OutNameNoExt%.VPrj FileRecycle, %OutDir%\%OutNameNoExt%.incommercial ;Filemove, %A_ScriptDir%\%OutFileName%, %OutDir%\%OutFileName%, 1 ;Moves edited recording and overwrites original recording. } } ;---------------------------------------------------------------------------------------------------------- ;-FUNCTIONS------------------------------------------------------------------------------------------------ ;---------------------------------------------------------------------------------------------------------- GetDetailsOf(inFileName) { SplitPath,inFileName,sFileName,sFileDir objFolder := ComObjCreate("Shell.Application").Namespace(sFileDir . "\") objFile := objFolder.Parsename(sFileName) Loop { iAttribute := objFolder.GetDetailsOf(objFolder, A_Index) if not iAttribute break if (iValue := objFolder.GetDetailsOf(objFile, A_Index)) ;only add attribs with values details .= A_Index . " : " . iAttribute . " = " . iValue . "`n" } return details, objFolder := "", objFile := "" } Comskip.ini detect_method=111 verbose=0 max_brightness=60 maxbright=5 test_brightness=40 max_avg_brightness=25 max_commercialbreak=600 min_commercialbreak=25 max_commercial_size=125 min_commercial_size=4 min_show_segment_length=125 max_volume=500 non_uniformity=500 [Detailed Settings] min_silence=8 noise_level=5 brightness_jump=200 fps=25 validate_silence=1 validate_uniform=1 validate_scenechange=1 global_threshold=1.05 disable_heuristics=0 [CPU Load Reduction] play_nice_start=-1 play_nice_end=-1 play_nice_sleep=10 [input Correction] max_repair_size=200 ms_audio_delay=5 volume_slip=20 variable_bitrate=1 [Aspect Ratio] ar_delta=0.08 cut_on_ar_change=1 [Global Removes] padding=0 remove_before=0 remove_after=0 delete_show_after_last_commercial=1 delete_show_before_first_commercial=1 delete_show_before_or_after_current=1 delete_block_after_commercial=0 min_commercial_break_at_start_or_end=5 [uSA Specific] intelligent_brightness=0 black_percentile=0.0073 uniform_percentile=0.005 score_percentile=0.71 [Main Scoring] length_strict_modifier=3 length_nonstrict_modifier=1.5 combined_length_strict_modifier=2 combined_length_nonstrict_modifier=1.25 ar_wrong_modifier=2 excessive_length_modifier=0.01 dark_block_modifier=0.3 min_schange_modifier=0.5 max_schange_modifier=2 logo_present_modifier=0.5 punish_no_logo=1 [Detailed Scoring] punish=0 reward=0 punish_threshold=1.3 punish_modifier=2 reward_modifier=0.5 [Logo Finding] border=10 give_up_logo_search=2000 logo_max_percentage_of_screen=0.1 ticker_tape=0 ignore_side=0 subtitles=0 logo_at_bottom=0 logo_threshold=0.75 logo_filter=5 aggressive_logo_rejection=0 edge_level_threshold=5 edge_radius=2 edge_weight=10 edge_step=1 num_logo_buffers=50 use_existing_logo_file=1 two_pass_logo=1 [Logo Interpretation] connect_blocks_with_logo=1 logo_percentile=0.92 logo_fraction=0.4 shrink_logo=5 before_logo=0 after_logo=0 where_logo=0 min_black_frames_for_break=1 [Closed Captioning] ccCheck=0 cc_commercial_type_modifier=4 cc_wrong_type_modifier=2 cc_correct_type_modifier=0.75 [Live TV] live_tv=1 live_tv_retries=4 dvrms_live_tv_retries=300 standoff=0 dvrmsstandoff=120000 require_div5=0 div5_tolerance=-1 [Output Control] output_default=0 output_plist_cutlist=0 output_zoomplayer_cutlist=0 output_zoomplayer_chapter=0 output_vcf=0 output_vdr=0 output_projectx=0 output_avisynth=0 output_videoredo=0 videoredo_offset=2 output_btv=0 output_edl=0 output_edlp=0 output_bsplayer=0 output_edlx=0 output_cuttermaran=0 output_mpeg2schnitt=0 output_womble=0 output_mls=0 output_mpgtx=0 output_dvrmstb=0 output_dvrcut=0 output_framearray=0 output_debugwindow=0 output_tuning=0 output_training=0 output_aspect=0 output_demux=0 output_timing=0 delete_logo_file=1 cutscene_frame=0 cutscene_dumpfile="" cutscene_threshold=10 cutscenefile1="" cutscenefile2="" cutscenefile3="" cutscenefile4="" cutscenefile5="" cutscenefile6="" cutscenefile7="" cutscenefile8="" windowtitle="Comskip - %s" cuttermaran_options="cut=\"true\" unattended=\"true\" muxResult=\"false\" snapToCutPoints=\"true\" closeApp=\"true\"" mpeg2schnitt_options="mpeg2schnitt.exe /S /E /R25 /Z %2 %1" avisynth_options="LoadPlugin(\"MPEG2Dec3.dll\") \nMPEG2Source(\"%s\")\n" dvrcut_options="dvrcut \"%s.dvr-ms\" \"%s_clean.dvr-ms\" " [sage Workarounds] sage_framenumber_bug=0 sage_minute_bug=0 enable_mencoder_pts=0 Sender script (AKA Intelligent Hibernationscript) #NoTrayIcon ;----------------------------------------------------------------------------------------------------------------- ;Activate codelines by removing the semicolon ";" infront of a line if you wanna use this feature ;If using Clientcount as a variable to cancel hibernation instead of the default TimeVar activate this line in CONDITIONING OF VARIABLES on two locations. ;Using script in default version just fill in user details, IP and port number to Recording Service API in next section. ;----------------------------------------------------------------------------------------------------------------- ;PATH, URL AND CONDITIONS CONFIGURATION ;----------------------------------------------------------------------------------------------------------------- Recording_Service_API_URL := "http://username:password@127.0.0.1:8089" ;Fill in username and password to RS ;RS_recording_folder := "D:\TV\Recording Service" ;Activate if wanting recordings database backup. Fill in path to your RS recording folder. ;EPG_files_location := "D:\TV\Recording Service\EPG Info-Log Files" ;Activate if wanting recordings database backup. OBSERVE! Must be a subfolder to RS recording folder ;PropCopy_location := "D:\AVI_VOB_BLU-RAY_AC3-tools\TV-tools\DVBViewer\PropCopy_1_2_2\PropCopy.exe" ;Activate if wanting recordings database backup. Fill in path to PropCopy ;Recording_database_backup_location_1 := "D:\AVI_VOB_BLU-RAY_AC3-tools\TV-tools\EPG Info-Log Files Backup" ;Activate if wanting recordings database backup on other location. ;Recording_database_backup_location_2 := "E:\EPG Info-Log Files Backup" Edited_Video_Folder := "D:\Edited Recordings" ;Activate if wanting comskip/videoredo commercial removal. Fill in path to CommercialRemover.exe. More info on setup read next section. Allow_hibernate_starttime_weekdays := "01:00:00" ;Configurate starttime from when hibernation should be allowed for weekdays. Change time value to your own preference. Allow_hibernate_stoptime_weekdays := "15:00:00" ;Configurate stoptime up to when hibernation should be allowed for weekdays. Change time value to your own preference. Allow_hibernate_starttime_weekend := "02:00:00" ;Configurate starttime from when hibernation should be allowed for weekends. Change time value to your own preference. Allow_hibernate_stoptime_weekend := "09:00:00" ;Configurate stoptime up to when hibernation should be allowed for weekends. Change time value to your own preference. ;Use_clientcount_status_as_Hibernationblock := "ErrorLevel" /* This last configuration line above disables time as main hibernation blocker and enables hibernation block as long as the local DVBViewer client on RS server is running. Default inactivated. Don't change value...to activate remove semicolon in front of the "Use_clientcount_status_as_Hibernationblock" line. To make it work for local client on server enable: RS Configure/DVBServer tab/"Block Standby/Hibernate if a DVBViewer client is connected on the same computer" option. If not this option is checked, the local client will not be counted when doing the RS API check and this feature will fail. */ ;----------------------------------------------------------------------------------------------------------------- ;COMSKIP/VIDEOREDO COMMERCIAL REMOVAL ;This feature Requires additional software. ;For setup go to: http://www.DVBViewer.tv/forum/topic/44842-automatic-commercial-removal-script/page__view__findpost__p__330318 ;----------------------------------------------------------------------------------------------------------------- ;DELETE OLD RECORDINGS CONFIGURATION ;Activate to use. Fill in number of days to keep files and path to them ;----------------------------------------------------------------------------------------------------------------- ;OldConfigCleanup("2","D:\TV\Inspelat","*.ts") ;Recordings older than 2 days will be deleted from Inspelat folder. ;OldConfigCleanup("2","D:\TV\Seen Recordings","*.ts") ;Recordings older than 2 days will be deleted from Seen Recordings folder. ;OldConfigCleanup("1","D:\TV\Timeshift","*.ts") ;Timeshifted Recordings older than 1 day will be deleted. ;----------------------------------------------------------------------------------------------------------------- ;CODE BODY ;---CURRENT TIME AND DAY RETRIEVAL-------------------------------------------------------------------------------- FormatTime, TimeVar,, HH:mm:ss ;Current local time. FormatTime, DateVar,, WDay ; 1=Sunday, 2=Monday etc. ;---RECORDING SERVICE STATUS RETRIEVAL---------------------------------------------------------------------------- UrlDownloadToVar(Recording_Service_API_URL . "/api/status.html", OutputVar) FoundPos := RegExMatch(OutputVar, "(?<=recordcount>)(.)", SubPat) RS_StatusVar:=SubPat ;status of the recording service ;---TIME TO NEXT RECORDING RETRIEVAL------------------------------------------------------------------------------ UrlDownloadToVar(Recording_Service_API_URL . "/api/timerlist.html[?utf8=]", OutputVar2) x1 := loadXML(OutputVar2) MyList := A_Now A_Tab "<now>" for timer in x1.selectNodes("/Timers/Timer") ;Loop { timer_status := timer.selectSingleNode("@Enabled").text ;Retrieves if timer is enabled or not. Activated=-1 Deactivated=0 date := timer.selectSingleNode("@Date").text ;Date of timer start_time := timer.selectSingleNode("@Start").text ;Start time of timer date_starttime_orig_format = %date%`n%start_time% ;Original date and start time format date_starttime := ReFormatTime( date_starttime_orig_format, "DD MM YYYY HH MI SS", ".`n:" ) ;ReFormat date and start time of timer MyList .= "`n" . date_starttime . "|" . timer_status } Sort, MyList, N NewString := RegexReplace( MyList, "\v*\d{14}\|0" ) ;Removes all deactivated timers set=0 Loop, Parse, NewString, `n { If set=1 { datetime := A_LoopField break } IfInString, A_Loopfield, <now> set=1 } StringSplit, datetime, datetime, %A_Tab% EnvSub, datetime1, A_Now, min If datetime1 = 0 RS_TimeToNextRecordingVar := 31 Else RS_TimeToNextRecordingVar := datetime1 ;time in minutes to next recording ;---RECORDING SERVICE CLIENTCOUNT STATUS RETRIEVAL----------------------------------------------------------------- UrlDownloadToVar(Recording_Service_API_URL . "/api/status.html", OutputVar) FoundPos := RegExMatch(OutputVar, "(?<=clientcount>)(.)", SubPat2) RS_ClientCountStatus:=SubPat2 ;Number of clients connected to the recording service ;---CONDITIONING OF CLIENTCOUNT VARIABLE--------------------------------------------------------------------------- If Use_clientcount_status_as_Hibernationblock = Use_clientcount_status_as_Hibernationblock := ErrorLevel Else Use_clientcount_status_as_Hibernationblock := RS_ClientCountStatus ;---CONDITIONING OF EDITED_VIDEO_FOLDER VARIABLE------------------------------------------------------------------- If Edited_Video_Folder Edited_Video_Folder := Edited_Video_Folder Else Edited_Video_Folder := %ErrorLevel% ;---DEBUG IF THE VARIABLES GETS VALUES----------------------------------------------------------------------------- ;IniWrite, %DateVar%, C:\ScriptsForWindows7\DVBViewer RecService Status.ini, Day_of_Week, Key ;IniWrite, %TimeVar%, C:\ScriptsForWindows7\DVBViewer RecService Status.ini, CurrentTime, Key ;IniWrite, %RS_StatusVar%, C:\ScriptsForWindows7\DVBViewer RecService Status.ini, RS_Status, Key ;IniWrite, %RS_TimeToNextRecordingVar%, C:\ScriptsForWindows7\DVBViewer RecService Status.ini, RS_TimeToNextRecording, Key ;IniWrite, %RS_ClientCountStatus%, C:\ScriptsForWindows7\DVBViewer RecService Status.ini, RS_ClientCountStatus, Key ;---TEST VARIABLES------------------------------------------------------------------------------------------------- ;DateVar = 7 ;TimeVar = 16:00:00 ;RS_StatusVar = 2 ;RS_TimeToNextRecordingVar = 30 ;Use_clientcount_status_as_Hibernationblock = 1 ;---RECORDINGS DATABASE BACKUP AND METADATA COPY------------------------------------------------------------------- right_Now := a_now timelimit := right_Now EnvAdd, timelimit, -60, seconds FileList = b_index=0 Loop, %RS_recording_folder%\*.log { if A_LoopFileTimeModified between %timelimit% and %right_Now% { b_index++ file%b_index% := A_LoopFileFullPath ;FileList = %FileList%%A_LoopFileTimeModified%`t%b_index%`t%A_LoopFileName%`n ;Enable this line to debug with msgbox Please hit } } ;msgbox Please hit ^c (while this is displayed) to copy to clipboard `n`n%FileList% Loop %b_index% { SplitPath, file%a_index%, OutFileName, OutDir,, OutNameNoExt FileCopy, %OutDir%\%OutFileName%, %EPG_files_location%\ ;RS log file will be copied to backupfolder FileMove, %OutDir%\%OutNameNoExt%.txt, %EPG_files_location%\ ;EPG information file will be moved to a subfolder Filemove, %OutDir%\%OutFileName%, %EPG_files_location%\%OutNameNoExt%.ts ;RS Log file will be moved and renamed to .ts extension RunWait, %PropCopy_location% "%RS_recording_folder%\%OutNameNoExt%.ts" "%EPG_files_location%\%OutNameNoExt%.ts" ;Metadata/Fileinfo copy FileCopy, %EPG_files_location%\*.*, %Recording_database_backup_location_1%\, 0 ;Backup of database FileCopy, %EPG_files_location%\*.*, %Recording_database_backup_location_2%\, 0 ;Backup of database } UrlDownloadToVar(Recording_Service_API_URL . "/tasks.html?task=RefreshDB&aktion=tasks", OutputVar) ;Refresh Recording Service Database ;---CONDITIONING OF VARIABLES-------------------------------------------------------------------------------------- If DateVar between 2 and 6 ;Specifies hibernation rules between Monday=2 and Friday=6. Always use LowerBound and UpperBound format, like my example. { If TimeVar not between %Allow_hibernate_starttime_weekdays% and %Allow_hibernate_stoptime_weekdays% ;Between 01:00-15:00 hibernation will be allowed. Gosub, Label1 ;One or more conditions above is NOT met...hibernation will be cancelled but automatic commercial removal will commence. Else { If RS_StatusVar <= 1 ;If Recording Service status is idle hibernation will be allowed. DO NOT alter this value! If Use_clientcount_status_as_Hibernationblock = 0 ;Hibernation will be allowed only if no clients are connected to RS. If RS_TimeToNextRecordingVar >= 30 ;If more than 30 minutes to next recording, HTPC will hibernate. Set to the value you prefer! If Edited_Video_Folder = %ErrorLevel% ;Edited video folder is inactivated { Sleep, 4000 ;Just wait a little before creating pipe #NoEnv ptr := A_PtrSize ? "Ptr" : "UInt" char_size := A_IsUnicode ? 2 : 1 Script= ( SetTitleMatchMode, 2 DetectHiddenWindows, On SendMessage, 0x5555, 0, 0,,InterceptShutdown.exe ; InterceptShutdown.exe is in my case the interceptionscript DetectHiddenWindows, Off ) ; To prevent "collision", pipe_name could be something mostly "unique", like: ; pipe_name := A_TickCount pipe_name := "InterceptShutdown" ; Before reading the file, AutoHotkey calls GetFileAttributes(). This causes ; the pipe to close, so we must create a second pipe for the actual file contents. ; Open them both before starting AutoHotkey, or the second attempt to open the ; "file" will be very likely to fail. The first created instance of the pipe ; seems to reliably be "opened" first. Otherwise, WriteFile would fail. pipe_ga := CreateNamedPipe0(pipe_name, 2) pipe := CreateNamedPipe0(pipe_name, 2) if (pipe=-1 or pipe_ga=-1) { MsgBox CreateNamedPipe failed. ExitApp } ; Wait for AutoHotkey to connect to pipe_ga via GetFileAttributes(). DllCall("ConnectNamedPipe", ptr, pipe_ga, ptr, 0) ; This pipe is not needed, so close it now. (The pipe instance will not be fully ; destroyed until AutoHotkey also closes its handle.) DllCall("CloseHandle", ptr, pipe_ga) ; Wait for AutoHotkey to connect to open the "file". DllCall("ConnectNamedPipe", ptr, pipe, ptr, 0) ; Standard AHK needs a UTF-8 BOM to work via pipe. If we're running on ; Unicode AHK_L, 'Script' contains a UTF-16 string so add that BOM instead: Script := (A_IsUnicode ? chr(0xfeff) : chr(239) chr(187) chr(191)) . Script char_size := (A_IsUnicode ? 2:1) if !DllCall("WriteFile", ptr, pipe, "str", Script, "uint", (StrLen(Script)+1)*char_size, "uint*", 0, ptr, 0) MsgBox WriteFile failed: `%ErrorLevel`%/`%A_LastError`% DllCall("CloseHandle", ptr, pipe) CreateNamedPipe0(Name, OpenMode=3, PipeMode=0, MaxInstances=255) { global ptr return DllCall("CreateNamedPipe","str","\\.\pipe\" Name,"uint",OpenMode ,"uint",PipeMode,"uint",MaxInstances,"uint",0,"uint",0,"uint",0,ptr,0,ptr) } ExitApp } Else if Edited_Video_Folder { Sleep, 4000 ;Just wait a little before creating pipe #NoEnv ptr := A_PtrSize ? "Ptr" : "UInt" char_size := A_IsUnicode ? 2 : 1 Script= ( RunWait, CommercialRemover.exe, %Edited_Video_Folder% SetTitleMatchMode, 2 DetectHiddenWindows, On SendMessage, 0x5555, 0, 0,,InterceptShutdown.exe ; InterceptShutdown.exe is in my case the interceptionscript DetectHiddenWindows, Off ) ; To prevent "collision", pipe_name could be something mostly "unique", like: ; pipe_name := A_TickCount pipe_name := "InterceptShutdown" ; Before reading the file, AutoHotkey calls GetFileAttributes(). This causes ; the pipe to close, so we must create a second pipe for the actual file contents. ; Open them both before starting AutoHotkey, or the second attempt to open the ; "file" will be very likely to fail. The first created instance of the pipe ; seems to reliably be "opened" first. Otherwise, WriteFile would fail. pipe_ga := CreateNamedPipe1(pipe_name, 2) pipe := CreateNamedPipe1(pipe_name, 2) if (pipe=-1 or pipe_ga=-1) { MsgBox CreateNamedPipe failed. ExitApp } ; Wait for AutoHotkey to connect to pipe_ga via GetFileAttributes(). DllCall("ConnectNamedPipe", ptr, pipe_ga, ptr, 0) ; This pipe is not needed, so close it now. (The pipe instance will not be fully ; destroyed until AutoHotkey also closes its handle.) DllCall("CloseHandle", ptr, pipe_ga) ; Wait for AutoHotkey to connect to open the "file". DllCall("ConnectNamedPipe", ptr, pipe, ptr, 0) ; Standard AHK needs a UTF-8 BOM to work via pipe. If we're running on ; Unicode AHK_L, 'Script' contains a UTF-16 string so add that BOM instead: Script := (A_IsUnicode ? chr(0xfeff) : chr(239) chr(187) chr(191)) . Script char_size := (A_IsUnicode ? 2:1) if !DllCall("WriteFile", ptr, pipe, "str", Script, "uint", (StrLen(Script)+1)*char_size, "uint*", 0, ptr, 0) MsgBox WriteFile failed: `%ErrorLevel`%/`%A_LastError`% DllCall("CloseHandle", ptr, pipe) CreateNamedPipe1(Name, OpenMode=3, PipeMode=0, MaxInstances=255) { global ptr return DllCall("CreateNamedPipe","str","\\.\pipe\" Name,"uint",OpenMode ,"uint",PipeMode,"uint",MaxInstances,"uint",0,"uint",0,"uint",0,ptr,0,ptr) } ExitApp } Else if RS_TimeToNextRecordingVar <= 29 GoSub, Label1 ;One or more conditions above is NOT met...hibernation will be cancelled but automatic commercial removal will commence. Else if Use_clientcount_status_as_Hibernationblock >= 1 GoSub, Label1 ;One or more conditions above is NOT met...hibernation will be cancelled but automatic commercial removal will commence. Else if RS_StatusVar >= 2 GoSub, Label1 ;One or more conditions above is NOT met...hibernation will be cancelled but automatic commercial removal will commence. } } ;---CONDITIONING OF VARIABLES WEEKENDS----------------------------------------------------------------------------- If DateVar not between 2 and 6 ;Specifies hibernation rules between Saturday=7 and Sunday=1. Always use LowerBound and UpperBound format, like my example. { If TimeVar not between %Allow_hibernate_starttime_weekend% and %Allow_hibernate_stoptime_weekend% ;Between 02:00-09:00 hibernation will be allowed. Gosub, Label1 ; One or more conditions above is NOT met...hibernation will be cancelled but automatic commercial removal will commence. Else { If RS_StatusVar <= 1 ;If Recording Service status is idle hibernation will be allowed. DO NOT alter this value! If Use_clientcount_status_as_Hibernationblock = 0 ;Hibernation will be allowed only if no clients are connected to RS. If RS_TimeToNextRecordingVar >= 30 ;If more than 30 minutes to next recording, HTPC will hibernate. Set to the value you prefer! If Edited_Video_Folder = %ErrorLevel% ;Edited video folder is inactivated { Sleep, 4000 ;Just wait a little before creating pipe #NoEnv ptr := A_PtrSize ? "Ptr" : "UInt" char_size := A_IsUnicode ? 2 : 1 Script= ( SetTitleMatchMode, 2 DetectHiddenWindows, On SendMessage, 0x5555, 0, 0,,InterceptShutdown.exe ; InterceptShutdown.exe is in my case the interceptionscript DetectHiddenWindows, Off ) ; To prevent "collision", pipe_name could be something mostly "unique", like: ; pipe_name := A_TickCount pipe_name := "InterceptShutdown" ; Before reading the file, AutoHotkey calls GetFileAttributes(). This causes ; the pipe to close, so we must create a second pipe for the actual file contents. ; Open them both before starting AutoHotkey, or the second attempt to open the ; "file" will be very likely to fail. The first created instance of the pipe ; seems to reliably be "opened" first. Otherwise, WriteFile would fail. pipe_ga := CreateNamedPipe2(pipe_name, 2) pipe := CreateNamedPipe2(pipe_name, 2) if (pipe=-1 or pipe_ga=-1) { MsgBox CreateNamedPipe failed. ExitApp } ; Wait for AutoHotkey to connect to pipe_ga via GetFileAttributes(). DllCall("ConnectNamedPipe", ptr, pipe_ga, ptr, 0) ; This pipe is not needed, so close it now. (The pipe instance will not be fully ; destroyed until AutoHotkey also closes its handle.) DllCall("CloseHandle", ptr, pipe_ga) ; Wait for AutoHotkey to connect to open the "file". DllCall("ConnectNamedPipe", ptr, pipe, ptr, 0) ; Standard AHK needs a UTF-8 BOM to work via pipe. If we're running on ; Unicode AHK_L, 'Script' contains a UTF-16 string so add that BOM instead: Script := (A_IsUnicode ? chr(0xfeff) : chr(239) chr(187) chr(191)) . Script char_size := (A_IsUnicode ? 2:1) if !DllCall("WriteFile", ptr, pipe, "str", Script, "uint", (StrLen(Script)+1)*char_size, "uint*", 0, ptr, 0) MsgBox WriteFile failed: `%ErrorLevel`%/`%A_LastError`% DllCall("CloseHandle", ptr, pipe) CreateNamedPipe2(Name, OpenMode=3, PipeMode=0, MaxInstances=255) { global ptr return DllCall("CreateNamedPipe","str","\\.\pipe\" Name,"uint",OpenMode ,"uint",PipeMode,"uint",MaxInstances,"uint",0,"uint",0,"uint",0,ptr,0,ptr) } ExitApp } Else if Edited_Video_Folder { Sleep, 4000 ;Just wait a little before creating pipe #NoEnv ptr := A_PtrSize ? "Ptr" : "UInt" char_size := A_IsUnicode ? 2 : 1 Script= ( RunWait, CommercialRemover.exe, %Edited_Video_Folder% SetTitleMatchMode, 2 DetectHiddenWindows, On SendMessage, 0x5555, 0, 0,,InterceptShutdown.exe ; InterceptShutdown.exe is in my case the interceptionscript DetectHiddenWindows, Off ) ; To prevent "collision", pipe_name could be something mostly "unique", like: ; pipe_name := A_TickCount pipe_name := "InterceptShutdown" ; Before reading the file, AutoHotkey calls GetFileAttributes(). This causes ; the pipe to close, so we must create a second pipe for the actual file contents. ; Open them both before starting AutoHotkey, or the second attempt to open the ; "file" will be very likely to fail. The first created instance of the pipe ; seems to reliably be "opened" first. Otherwise, WriteFile would fail. pipe_ga := CreateNamedPipe3(pipe_name, 2) pipe := CreateNamedPipe3(pipe_name, 2) if (pipe=-1 or pipe_ga=-1) { MsgBox CreateNamedPipe failed. ExitApp } ; Wait for AutoHotkey to connect to pipe_ga via GetFileAttributes(). DllCall("ConnectNamedPipe", ptr, pipe_ga, ptr, 0) ; This pipe is not needed, so close it now. (The pipe instance will not be fully ; destroyed until AutoHotkey also closes its handle.) DllCall("CloseHandle", ptr, pipe_ga) ; Wait for AutoHotkey to connect to open the "file". DllCall("ConnectNamedPipe", ptr, pipe, ptr, 0) ; Standard AHK needs a UTF-8 BOM to work via pipe. If we're running on ; Unicode AHK_L, 'Script' contains a UTF-16 string so add that BOM instead: Script := (A_IsUnicode ? chr(0xfeff) : chr(239) chr(187) chr(191)) . Script char_size := (A_IsUnicode ? 2:1) if !DllCall("WriteFile", ptr, pipe, "str", Script, "uint", (StrLen(Script)+1)*char_size, "uint*", 0, ptr, 0) MsgBox WriteFile failed: `%ErrorLevel`%/`%A_LastError`% DllCall("CloseHandle", ptr, pipe) CreateNamedPipe3(Name, OpenMode=3, PipeMode=0, MaxInstances=255) { global ptr return DllCall("CreateNamedPipe","str","\\.\pipe\" Name,"uint",OpenMode ,"uint",PipeMode,"uint",MaxInstances,"uint",0,"uint",0,"uint",0,ptr,0,ptr) } ExitApp } Else if RS_TimeToNextRecordingVar <= 29 GoSub, Label1 ;One or more conditions above is NOT met...hibernation will be cancelled but automatic commercial removal will commence. Else if Use_clientcount_status_as_Hibernationblock >= 1 GoSub, Label1 ;One or more conditions above is NOT met...hibernation will be cancelled but automatic commercial removal will commence. Else if RS_StatusVar >= 2 GoSub, Label1 ;One or more conditions above is NOT met...hibernation will be cancelled but automatic commercial removal will commence. } } ;---SUBROUTINES---------------------------------------------------------------------------------------------------- Label1: If Edited_Video_Folder ;Edited video folder is activated { Sleep, 4000 ;Just wait a little before creating pipe #NoEnv ptr := A_PtrSize ? "Ptr" : "UInt" char_size := A_IsUnicode ? 2 : 1 Script=Run, CommercialRemover.exe, %Edited_Video_Folder% ; To prevent "collision", pipe_name could be something mostly "unique", like: ; pipe_name := A_TickCount pipe_name := "InterceptShutdown" ; Before reading the file, AutoHotkey calls GetFileAttributes(). This causes ; the pipe to close, so we must create a second pipe for the actual file contents. ; Open them both before starting AutoHotkey, or the second attempt to open the ; "file" will be very likely to fail. The first created instance of the pipe ; seems to reliably be "opened" first. Otherwise, WriteFile would fail. pipe_ga := CreateNamedPipe4(pipe_name, 2) pipe := CreateNamedPipe4(pipe_name, 2) if (pipe=-1 or pipe_ga=-1) { MsgBox CreateNamedPipe failed. ExitApp } ; Wait for AutoHotkey to connect to pipe_ga via GetFileAttributes(). DllCall("ConnectNamedPipe", ptr, pipe_ga, ptr, 0) ; This pipe is not needed, so close it now. (The pipe instance will not be fully ; destroyed until AutoHotkey also closes its handle.) DllCall("CloseHandle", ptr, pipe_ga) ; Wait for AutoHotkey to connect to open the "file". DllCall("ConnectNamedPipe", ptr, pipe, ptr, 0) ; Standard AHK needs a UTF-8 BOM to work via pipe. If we're running on ; Unicode AHK_L, 'Script' contains a UTF-16 string so add that BOM instead: Script := (A_IsUnicode ? chr(0xfeff) : chr(239) chr(187) chr(191)) . Script char_size := (A_IsUnicode ? 2:1) if !DllCall("WriteFile", ptr, pipe, "str", Script, "uint", (StrLen(Script)+1)*char_size, "uint*", 0, ptr, 0) MsgBox WriteFile failed: `%ErrorLevel`%/`%A_LastError`% DllCall("CloseHandle", ptr, pipe) CreateNamedPipe4(Name, OpenMode=3, PipeMode=0, MaxInstances=255) { global ptr return DllCall("CreateNamedPipe","str","\\.\pipe\" Name,"uint",OpenMode ,"uint",PipeMode,"uint",MaxInstances,"uint",0,"uint",0,"uint",0,ptr,0,ptr) } ExitApp } Else If Edited_Video_Folder = %ErrorLevel% ;Edited Video folder does not exist ExitApp ;---------------------------------------------------------------------------------------------------------------- ;FUNCTIONS ;---------------------------------------------------------------------------------------------------------------- UrlDownloadToVar(URL, ByRef Result, UserAgent = "", Proxy = "", ProxyBypass = "") { ; Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0, ; Windows Me, Windows 98, or Windows 95. ; Requires Internet Explorer 3.0 or later. pFix:=a_isunicode ? "W" : "A" hModule := DllCall("LoadLibrary", "Str", "wininet.dll") AccessType := Proxy != "" ? 3 : 1 ;INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration ;INTERNET_OPEN_TYPE_DIRECT 1 // direct to net ;INTERNET_OPEN_TYPE_PROXY 3 // via named proxy ;INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS io := DllCall("wininet\InternetOpen" . pFix , "Str", UserAgent ;lpszAgent , "UInt", AccessType , "Str", Proxy , "Str", ProxyBypass , "UInt", 0) ;dwFlags iou := DllCall("wininet\InternetOpenUrl" . pFix , "UInt", io , "Str", url , "Str", "" ;lpszHeaders , "UInt", 0 ;dwHeadersLength , "UInt", 0x80000000 ;dwFlags: INTERNET_FLAG_RELOAD = 0x80000000 // retrieve the original item , "UInt", 0) ;dwContext If (ErrorLevel != 0 or iou = 0) { DllCall("FreeLibrary", "UInt", hModule) return 0 } VarSetCapacity(buffer, 10240, 0) VarSetCapacity(BytesRead, 4, 0) Loop { ;http://msdn.microsoft.com/library/en-us/wininet/wininet/internetreadfile.asp irf := DllCall("wininet\InternetReadFile", "UInt", iou, "UInt", &buffer, "UInt", 10240, "UInt", &BytesRead) VarSetCapacity(buffer, -1) ;to update the variable's internally-stored length BytesRead_ = 0 ; reset Loop, 4 ; Build the integer by adding up its bytes. (From ExtractInteger-function) BytesRead_ += *(&BytesRead + A_Index-1) << 8*(A_Index-1) ;Bytes read in this very DllCall ; To ensure all data is retrieved, an application must continue to call the ; InternetReadFile function until the function returns TRUE and the lpdwNumberOfBytesRead parameter equals zero. If (irf = 1 and BytesRead_ = 0) break Else ; append the buffer's contents { a_isunicode ? buffer:=StrGet(&buffer, "CP0") Result .= SubStr(buffer, 1, BytesRead_ * (a_isunicode ? 2 : 1)) } /* optional: retrieve only a part of the file BytesReadTotal += BytesRead_ If (BytesReadTotal >= 30000) ; only read the first x bytes break ; (will be a multiple of the buffer size, if the file is not smaller; trim if neccessary) */ } DllCall("wininet\InternetCloseHandle", "UInt", iou) DllCall("wininet\InternetCloseHandle", "UInt", io) DllCall("FreeLibrary", "UInt", hModule) } ;---------------------------------------------------------------------------------------------------------------------- OldConfigCleanup(Daystokeep,Pathtoconfigs,exttodelete) { difdays = %Daystokeep% Source = %Pathtoconfigs%\%exttodelete% Time := A_Now Loop, %Source%, 0, 0 { TimeStamp := Time EnvSub, TimeStamp, %A_LoopFileTimeModified%, Days If ( TimeStamp >= difdays ) { ;MsgBox, file to delete: %A_LoopFileLongPath% ;FileDelete, %A_LoopFileLongPath% ;Files gets deleted instantly and permanent. FileRecycle, %A_LoopFileLongPath% ;Files gets moved to the Recycle Bin } continue } ;ExitApp } ;---------------------------------------------------------------------------------------------------------------------- loadXML(ByRef data) { o := ComObjCreate("MSXML2.DOMDocument.6.0") o.async := false o.preserveWhiteSpace := true o.loadXML(data) return o } ;---------------------------------------------------------------------------------------------------------------------- ReFormatTime( Time, Format, Delimiters ) { StringSplit F,Format, %A_Space% Loop, Parse, Time, %Delimiters% Var := F%A_Index%, %Var% := A_LoopField Return YYYY MM DD HH MI SS } ;---------------------------------------------------------------------------------------------------------------------- Intercept Shutdown script #NoTrayIcon #Persistent ;While !DllCall("WaitNamedPipe","Str","\\.\pipe\InterceptShutdown","UInt",0xffffffff) ;Sleep, 100 ;Run % """" A_AhkPath """ \\.\pipe\InterceptShutdown" SetTimer, RunBeforeShutdown, Off SetTimer, RunBeforeShutdown2, Off Gui,+LastFound hwnd:=WinExist() DllCall("ShutdownBlockReasonCreate","Uint",hwnd,"Str",A_ScriptFullPath "is still running") DllCall("kernel32.dll\SetProcessShutdownParameters", UInt, 0x4FF, UInt, 0) OnMessage(0x11, "WM_QUERYENDSESSION") OnMessage(0x5555, "RunBeforeShutdown2") Return WM_QUERYENDSESSION(wParam, lParam) { static sdtry = 0 ENDSESSION_Logoff = 0x80000000 If (lParam & ENDSESSION_Logoff) ; User is logging off. EventType = Logoff Else ; System is either shutting down or restarting. and EventType = Shutdown If (EventType = "Shutdown" and sdtry = 0) { SetTimer, RunBeforeShutdown, On Return false ; Tell the OS to Abort the Shutdown/Logoff. } Else If (EventType = "Shutdown" and sdtry = 1) Return true } RunBeforeShutdown2(wParam, lParam, msg) { SetTimer, RunBeforeShutdown2, On Return true } RunBeforeShutdown: SetTimer, RunBeforeShutdown, Off SendInput, {ENTER} Sleep, 1000 #SingleInstance, Force SetWorkingDir %A_ScriptDir% FileDelete, demo.htm FileAppend, ( <html> <body style="overflow:hidden"> <body bgcolor="#0033FF" leftmargin="1" topmargin="1"> <div align="Center"><p> <font color="#FFFB02" face="Segoe Print" size="4"><br><b> Your HTPC is about to be Closed Down. <br> You now have a chance to choose closedown method <br> or wait until default method gets choosen for you</b> </p> <font face="Segoe Print" size="5"><b> <script type="text/javascript"> var countDownInterval=20; var countDownTime=countDownInterval+1; function countDown(){ countDownTime--; if (countDownTime <=0){ countDownTime=countDownInterval; clearTimeout(counter); //window.location=""; return } if (document.getElementById) //else if NS6+ document.getElementById("countDownText").innerHTML=countDownTime+" "; else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN document.c_reload.document.c_reload2.document.write('<b id="countDownText">'+countDownTime+' </b> seconds') document.c_reload.document.c_reload2.document.close() } counter=setTimeout("countDown()", 1000); } function startit(){ if (document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN document.write('<b id="countDownText">'+countDownTime+' </b> seconds') countDown() } if (document.getElementById) startit() else window.onload=startit clearTimeout ( countDownTime ); </script> </font></b> </div> </body> </html> ) , demo.htm URL=file:///%A_ScriptDir%\demo.htm Options := "Buttons=Hibernate/Standby/Shutdown/Restart/Cancel, HtmW=580, HtmH=200, BDefault=1, DlgBgColor=0xEE0000, DlgTopmost=1, TimeOut=20, Title=System Closedown in 20 seconds, DlgStyle=NoFrame" Sel := HtmDlg( URL, "", Options ) if (Sel = 1) { ;Run, InterceptShutdown.exe, D:\ScriptsForWindows7 DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0) Return } else if (Sel = 2) { ;Run, InterceptShutdown.exe, D:\ScriptsForWindows7 DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) Return } else if (Sel = 3) { SetWorkingDir, C:\Program\HomeSeer HS2 RunWait, destroy_homeseer_speaker_client.vbs, E:\Extremt Bra Programvara\Scripts\VBS Code project\gopal_code_demo RunWait, Jon00ShutdownHS.exe, C:\Program\HomeSeer HS2 IniRead, HomeSeerPID, HomeSeerPID.ini, IExplorerPID, key WinClose, ahk_pid %HomeSeerPID% Process, Close, DVBViewer.exe Shutdown, 1 ExitApp Return } else if (Sel = 4) { SetWorkingDir, C:\Program\HomeSeer HS2 RunWait, destroy_homeseer_speaker_client.vbs, E:\Extremt Bra Programvara\Scripts\VBS Code project\gopal_code_demo RunWait, Jon00ShutdownHS.exe, C:\Program\HomeSeer HS2 IniRead, HomeSeerPID, HomeSeerPID.ini, IExplorerPID, key WinClose, ahk_pid %HomeSeerPID% Process, Close, DVBViewer.exe Shutdown, 2 ExitApp Return } else if (Sel = 5) { hibernate = 0 ;Run, InterceptShutdown.exe, D:\ScriptsForWindows7 Return } DllCall("ShutdownBlockReasonDestroy","Uint",hwnd) Return ; // end of auto-execute section // RunBeforeShutdown2: SetTimer, RunBeforeShutdown2, Off #SingleInstance, Force SetWorkingDir %A_ScriptDir% FileDelete, demo.htm FileAppend, ( <html> <body style="overflow:hidden"> <body bgcolor="#0033FF" leftmargin="1" topmargin="1"> <div align="Center"><p> <font color="#FFFB02" face="Segoe Print" size="4"><br><b> Your HTPC is about to be Closed Down. <br> You now have a chance to choose closedown method <br> or wait until default method gets choosen for you</b> </p> <font face="Segoe Print" size="5"><b> <script type="text/javascript"> var countDownInterval=20; var countDownTime=countDownInterval+1; function countDown(){ countDownTime--; if (countDownTime <=0){ countDownTime=countDownInterval; clearTimeout(counter); //window.location=""; return } if (document.getElementById) //else if NS6+ document.getElementById("countDownText").innerHTML=countDownTime+" "; else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN document.c_reload.document.c_reload2.document.write('<b id="countDownText">'+countDownTime+' </b> seconds') document.c_reload.document.c_reload2.document.close() } counter=setTimeout("countDown()", 1000); } function startit(){ if (document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN document.write('<b id="countDownText">'+countDownTime+' </b> seconds') countDown() } if (document.getElementById) startit() else window.onload=startit clearTimeout ( countDownTime ); </script> </font></b> </div> </body> </html> ) , demo.htm URL=file:///%A_ScriptDir%\demo.htm Options := "Buttons=Hibernate/Standby/Shutdown/Restart/Cancel, HtmW=580, HtmH=200, BDefault=1, DlgBgColor=0xEE0000, DlgTopmost=1, TimeOut=20, Title=System Closedown in 20 seconds, DlgStyle=NoFrame" Sel := HtmDlg( URL, "", Options ) if (Sel = 1) { ;Run, InterceptShutdown.exe, D:\ScriptsForWindows7 DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0) Return } else if (Sel = 2) { ;Run, InterceptShutdown.exe, D:\ScriptsForWindows7 DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) Return } else if (Sel = 3) { SetWorkingDir, C:\Program\HomeSeer HS2 RunWait, destroy_homeseer_speaker_client.vbs, E:\Extremt Bra Programvara\Scripts\VBS Code project\gopal_code_demo RunWait, Jon00ShutdownHS.exe, C:\Program\HomeSeer HS2 IniRead, HomeSeerPID, HomeSeerPID.ini, IExplorerPID, key WinClose, ahk_pid %HomeSeerPID% Process, Close, DVBViewer.exe Shutdown, 1 ExitApp Return } else if (Sel = 4) { SetWorkingDir, C:\Program\HomeSeer HS2 RunWait, destroy_homeseer_speaker_client.vbs, E:\Extremt Bra Programvara\Scripts\VBS Code project\gopal_code_demo RunWait, Jon00ShutdownHS.exe, C:\Program\HomeSeer HS2 IniRead, HomeSeerPID, HomeSeerPID.ini, IExplorerPID, key WinClose, ahk_pid %HomeSeerPID% Process, Close, DVBViewer.exe Shutdown, 2 ExitApp Return } else if (Sel = 5) { hibernate = 0 ;Run, InterceptShutdown.exe, D:\ScriptsForWindows7 Return } DllCall("ShutdownBlockReasonDestroy","Uint",hwnd) Return ; // end of auto-execute section // ;#Include HtmDlg.ahk ; You may copy/Paste HtmDlg() Instead HtmDlg( _URL="", _Owner=0, _Options="", _ODL="," ) { ; HTML DialogBox v0.57 -- by SKAN ; Topic: www.autohotkey.com/forum/viewtopic.php?t=60215 CD:09-Jul-2010 | LM:05-Aug-2010 ; Credit: WebControl Demo by Sean - www.autohotkey.com/forum/viewtopic.php?p=103987#103987 Static _hInst,_hDLG,_DlgP,_B$,_B$L,_pIWEB,_pV,_DlgT,CliC, HtmF=0,_Brush=0, BDef=1,BEsc=0 If ( A_EventInfo = 0xCBF ) { ; nested Callback Function hWnd := _URL, uMsg := _Owner, wP := _Options, lP := _ODL If ( uMsg=0x112 && wP=0xF060 ) ; WM_SYSCOMMAND & SC_ClOSE Return DllCall( "DestroyWindow", UInt,_hDLG ) | ( BDEf:=BEsc ) If ( uMsg=0x111 && (wP>>16)=0 ) ; WM_COMMAND & BN_CLICKED Return DllCall( "DestroyWindow", UInt,_hDLG ) | ( BDef := (wP=2) ? BEsc : wP-100 ) If ( uMsg=0x007 && HtmF=0 ) ; WM_SETFOCUS Return DllCall( "SetFocus", UInt,DllCall( "GetDlgItem", UInt,_hDLG, UInt,100+BDEF ) ) If ( uMsg=0x201 && CliC ) ; WM_LBUTTONDOWN Return DllCall( "DestroyWindow", UInt,_hDLG ) | ( BDEf := 1 ) If ( uMsg=0x136 && _Brush<>0 ) ; WM_CTLCOLORDLG Return _Brush if ( uMsg=0x002 && hWnd=_hDLG ) ; WM_DESTROY Return _Brush := DllCall( "DeleteObject", UInt,_Brush, UInt ) >> 32 Return False } If ! ( _hInst ) { _hInst := DllCall( "GetModuleHandle", Str,A_IsCompiled ? A_ScriptFullpath : A_AhkPath ) _DT := "61160CD3AFCDD0118A3EGC04FC9E26EZQ1GFFFFUCHC88GAZO9G9G1I4DG53G2H53G68G65G6CG6CG2H" . "44G6CG67ZL5V64K41G74G6CG41G78G57G69G6EK7BG38G38G35G36G46G39G36G31G2DG33G34G3H41G2DG31" . "G31G44G3H2DG41G39G36G42G2DG3H3H43G3H34G46G44G37G3H35G41G32G7DZS14V65KFFFF8ZP14V66KFFF" . "F8ZP14V67KFFFF8ZP14V68KFFFF8ZP14V69KFFFF8ZP14V6AKFFFF8ZP14V6BKFFFF8ZP14V6CKFFFF8ZP14V" . "6DKFFFF8P" Loop 20 ; Decompressing Nulls : www.autohotkey.com/forum/viewtopic.php?p=198560#198560 StringReplace,_DT,_DT,% Chr(70+21-A_Index),% SubStr("000000000000000000000",A_Index),All Loop % _B$L := VarSetCapacity( _B$, ( _DTLEN := StrLen(_DT) // 2 ), 0 ) NumPut( "0x" . SubStr(_DT, 2*A_Index-1,2),_B$,A_Index-1,"Char" ) ; Creating Structure _pIWEB := &_B$, _pV := &_B$+16, _DlgT := &_B$+32 ; Relevant pointers to Structure DllCall( "GetModuleHandle", Str,"atl.dll" ) ? 0 : DllCall( "LoadLibrary", Str,"atl.dll" ) DllCall( "atl\AtlAxWinInit" ), _DlgP := RegisterCallback( A_ThisFunc,0,4,0xCBF ) } VarSetCapacity( _W$,_B$L,0 ), DllCall( "RtlMoveMemory", UInt,&_W$, UInt,&_B$, UInt,_B$L ) _pIWEB := &_W$, _pV := &_W$+16, _DlgT := &_W$+32 ; Relevant pointers to Structure Butt:="OK", BWid:=75, BHei:=23, BSpH:=5, BSpV:=8, BAli:=1, Slee:=-1, HtmC:=0, CliC:=0 HtmD:=0, DlgT:=0, DlgN:=0, DlgX:="", DlgY:="", HtmW:=240, HtmH:=140, Left:=0, TopM:=0 Loop, Parse, _Options, =%_ODL%, %A_Space% ; Override Variables with user 'Options' A_Index & 1 ? ( __ := (SubStr(A_LoopField,1,1)="_") ? "_" : SubStr(A_LoopField,1,4)) : ( %__% := A_LoopField ) Cap := DllCall( "GetSystemMetrics", UInt,4 ) ; SM_CYCAPTION = Window Caption Frm := DllCall( "GetSystemMetrics", UInt,7 ) ; SM_CXFIXEDFRAME = Window Frame NumPut( HtmC<>0 ? 0x200 : 0x0, _W$, 32+68 ), DlgD := DlgD ? 0x8000000 : 0x0 FonS ? NumPut( FonS < 8 ? 8 : ( FonS > 14 ? 14 : FonS ), _W$, 64, "UShort" ) : 0 If ( ( DlgS := SubStr( DlgS,1,1 ) ) <> "" ) _ := ( DlgS = "F" ) ? NumPut( 0x800000C0 | DlgD, _W$, 44 ) | ( Cap := 0 ) : ( DlgS = "N" ) ? NumPut( 0x80000040 | DlgD, _W$, 44 ) | ( Frm := Cap := 0 ) : ( DlgS = "B" ) ? NumPut( 0x80800040 | DlgD, _W$, 44 ) | ( Cap := 0 ) | ( Frm := 1 ) : NumPut( 0x80C800C0 | DlgD, _W$, 44 ) IfNotEqual,DlgB,, SetEnv,_Brush,% DllCall( "CreateSolidBrush", UInt,DlgB ) _hDLG := DllCall( "CreateDialogIndirectParam", UInt,_hInst, UInt,_DlgT, UInt ,_Owner := ( _Owner <> "" ) ? _Owner : DllCall( "GetShellWindow" ), UInt,_DlgP, UInt,0 ) VarSetCapacity( _WU, StrLen(_URL) * ( A_IsUnicode ? 1 : 2 ) + 2, 0 ) A_IsUnicode ? _WU := _URL : DllCall( "MultiByteToWideChar", UInt,0, UInt,0, UInt,&_URL , Int,-1, UInt,&_WU, Int,StrLen(_URL)+1 ) _hHTM := DllCall( "GetDlgItem", UInt,_hDLG, UInt,100 ) DllCall( "atl\AtlAxGetControl", UInt,_hHTM, UIntP,_ppunk ) DllCall( NumGet( NumGet( _ppunk+0 )+4*0 ), UInt,_ppunk, UInt,_pIWEB, UIntP,_ppwb ) DllCall( NumGet( NumGet( _ppunk+0 )+4*2 ), UInt,_ppunk ),_pwb := NumGet( _ppwb+0 ) DllCall( NumGet(_pwb+4*11),UInt,_ppwb, UInt,&_WU, UInt,_pV,UInt,_pV,UInt,_pV,UInt,_pV ) DllCall( NumGet(_pwb+4*2), UInt,_ppwb ) DllCall( "SetWindowPos", UInt,_hHTM,Int,0,Int,Left,Int,TopM,Int,HtmW,Int,HtmH,UInt,0x14 ) IfNotEqual,HtmD,0, Control,Disable,,,ahk_id %_hHTM% DlgW := Frm + Left + HtmW + Frm + Left, ClAW := DlgW - Frm - Frm ; ClientArea Width DlgH := Frm + Cap + TopM + HtmH + BSpV + BHei + BSpV + Frm DlgX := ( DlgX <> "" ) ? DlgX : ( A_ScreenWidth - DlgW ) // 2 DlgY := ( DlgY <> "" ) ? DlgY : ( A_ScreenHeight - DlgH ) // 2 StringReplace, Butt,Butt, /,/, UseErrorLevel bCount := ErrorLevel+1 BY := TopM + HtmH + BSpV BX := ( Bali=1 ? ( ( ClAW - (BSpH*(bCount-1)) - (BWid*bCount) ) / 2 ) : ( Bali=0 ? ( ( BSpH * 2 ) + ( HtmD ? 0 : Left ) ) : ( ClAW - (BSpH*(bCount+1)) - (BWid*bCount) - ( HtmD ? 0 : Left ) ) ) ) Loop, Parse, Butt, / ; SetWindowPos flags = SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER DllCall( "SetWindowPos", UInt,BH:=DllCall( "GetDlgItem", UInt,_hDLG, UInt,100+A_Index ) , UInt,0, Int,BX, Int,BY, Int,BWid, Int,BHei, UInt,0x40|0x10|0x4 ) , DllCall( "SetWindowText", UInt,BH, Str,A_LoopField ), BX := BX + BSpH + BWid , _ := ( BNoT<>"" ) ? DllCall( "uxtheme\SetWindowTheme", UInt,BH, UInt,0, UIntP,0 ) : 0 , _ := ( BSFl<>"" ) ? DllCall( "SetWindowLong", UInt,BH, Int,-16, UInt,0x50018000 ) : 0 BDef := ( BDef < 1 || BDef > bCount ) ? 1 : BDef ; Force Default Button DllCall( "SendMessage", UInt,_hDLG, UInt,0x401, UInt,100+BDef, UInt,0 ) ; DM_SETDEFID DllCall( "SetWindowText", UInt,_hDLG, Str,Titl ? Titl : A_ScriptName ) ; Set Dialog Title DllCall( "SetWindowPos", UInt,_hDLG, Int,DlgT ? -1 : 1, Int,DlgX, Int,DlgY, Int,DlgW, Int , DlgH, UInt,0x10 ) ; DlgTopmost ? HWND_TOPMOST : HWND_TOP While ( nReady <> 4 && DlgW<>"" ) ; wait until webpage-load adapted from Seans's IE.ahk Sleep % 1 + ( DllCall( NumGet(NumGet(1*_ppwb)+224 ), UInt,_ppwb, UIntP,nReady ) >> 32 ) Sleep, %Slee% DllCall( "ShowWindow", UInt,_hDLG, Int,DlgN ? 8 : 5 ) ; DlgNA ? SW_SHOWNA : SW_SHOW IfNotEqual,HtmF,0, ControlFocus,, ahk_ID %_hDLG% WinWaitClose, ahk_id %_hDLG%,, %Time% TimedOut := Errorlevel ? DllCall( "EndDialog", UInt,_hDLG, UInt,0 ) : 0 IfNotEqual,AltR,, IfGreater,BDef,0, StringSplit,B,Butt,/ DllCall( "SetLastError", UInt,TimedOut ? 1 : 0 ) Return AltR ? B%BDef% : BDef } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ >- - - - - - - - - - - - - - - - - - - - - - - O P T I O N S - -< \- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - / Usage: HtmDlg( URL, hwndOwner, Options, OptionsDelimiter ) Parameters : URL - A valid URL supported by Internet Explorer including Res:// and File:// hWndOwner - Handle to the parent window. If invalid handle or 0 ( zero ) is passed, the dialog will have a taskbar button. Passing "" as a parameter will set 'Progman' the owner, thereby supressing the 'Taskbar Button'. Options - A series of 'variable overrides' delimited with character specified in 'Optionsdelimiter'. Please refer 'VARIABLE OVERRIDES' below. OptionsDelimiter - The delimiter used in seperating 'variable overrides' ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; * * * V A R I A B L E O V E R R I D E S * * * ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Important Note: leading 4 characters of a variable will be sufficient. for eg.: Instead of 'AltReturn=1' you may use 'AltR=1' DlgXpos = X coordinate in pixels, relative to screen Dialog is horizontally centered by default DlgYpos = Y coordinate in pixels, relative to screen Dialog is vertically centered by default DlgTopmost = 1 will set the Dialog 'Always-on-Top' 0 is default DlgDisable = 1 will disable the Dialog window No default value Caution: Since there is no way to interact, you may opt to TimeOut the Dialog DlgStyle = Frame or NoFrame or Border. Leading character is sufficient, like: F-N-B Default is Caption Note on Styles used: Frame = WS_POPUP | DS_MODALFRAME NoFrame = WS_POPUP | DS_SETFONT Border = WS_POPUP | DS_SETFONT | WS_BORDER Caption = WS_POPUP | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU WS_DISABLED is additionally set when DlgDisable=1 DlgNoActivate = 1 will Show the Dialog without activating it 0 is default DlgBgColor = ColorRef. eg: 0x0000FF is Red / Invalid ColorRef will result in Black. DlgWait = 1 will delay Dialog from being shown - until HTM is fully loaded Sleep = MilliSeconds ( Will be used just before Dialog is shown ) Default value is -1, 'No sleep' Title = Captionbar Text Default is A_ScriptName AltReturn = 1 will return Button-text 0 is default and Button-instance will be returned TimeOut = Seconds No default value Note: A_LastError will be true when a TimeOut occurs ClickClose = 1 Default value is 0 Note: Mouse L-Click on window's unoccupied clientarea' will close the dialog Tip: Use following to simulate a unobtrusive message ( like TrayTip ) DlgTopmost=1, HtmD=1, DlgNA=1, DlgStyle=Border, BHei=0, BSpV=0, Clic=1 LeftMargin = Spacing in Pixels ( on the left/right sides of WebControl ) Default value is 0 TopMargin = Spacing in Pixels ( above the WebControl ) Default value is 0 FonName ( Not implemented yet ) Default is 'MS Shell Dlg' and equivalent FonSize = Pointsize ( text size of Button-labels - restricted to 8,10,12,14 ) Default value is 8 HtmClientEdge = 1 to set WS_EX_CLIENTEDGE Default value is 0 HtmDisable = 1 to disable Default value is 0 HtmWidth = Width of WebControl in Pixels Default value is 240 HtmHeight = Height of WebControl in pixels Default value is 140 HtmFocus = 1 will activate the dialog and WebControl will have input focus Default value is 0 Note: DlgNoActivate option will lose effect. For best result, use this option along with DlgWait=1 Buttons = Button labels seperated with "/" eg: Buttons=Yes/No/Cancel Default Button is "OK" BDefault = Instance of Default Button. eg: To make 3rd Button default, use BDef=3 Default forced value is 1 BEscape = Instance of Button to return when dialog is closed or {Esc} is pressed Default is 0 BWidth = Button Width in Pixels Default Value is 75 BHeight = Button Height in Pixels Default value is 23 BSpHorizontal = Pixels ( affects the spacing on the sides of a button ) BSpVertical = Pixels ( affects the spacing above/below a button ) BAlign = 0 or 1 or 2 ( for Left, Center, Right alignment of buttons ) Default is 1 BNoTheme = 1 will remove theme from buttons ( XP & greater ) No default value BSFlat = 1 will flatten the button by removing the 3D edge - requires BNoTheme=1 No default value ;< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > */ Edited December 31, 2011 by majstang add spoiler 2 Quote Link to comment
subvertbeats Posted March 26, 2011 Share Posted March 26, 2011 Great stuff maj. Im on x64 so cant test but this is a great step forward! This requirement really should be implemented directly in DVBViewer though. Quote Link to comment
majstang Posted March 26, 2011 Author Share Posted March 26, 2011 Thanks subvertbeats! Well, actually I don't know with certainty if the script does work on 64-bit systems or not, cuz I have no 64-bit system installed...ergo haven't tested it yet. It may work. With a little luck we don't have to wait long before similar functions will be DVBViewer compatible. Hackbart promised to look over the old Comskip-DVBViewer plugin code. Hopefully he will held up this promise sometime soon http://www.DVBViewer.tv/forum/topic/37350-zoom-player-cut-list-to-DVBViewer/page__view__findpost__p__330481 Quote Link to comment
subvertbeats Posted April 26, 2011 Share Posted April 26, 2011 Thanks subvertbeats! Well, actually I don't know with certainty if the script does work on 64-bit systems or not, cuz I have no 64-bit system installed...ergo haven't tested it yet. It may work. With a little luck we don't have to wait long before similar functions will be DVBViewer compatible. Hackbart promised to look over the old Comskip-DVBViewer plugin code. Hopefully he will held up this promise sometime soon http://www.DVBViewer.tv/forum/topic/37350-zoom-player-cut-list-to-DVBViewer/page__view__findpost__p__330481 Thats great news maj! Keeping my fingers crossed Quote Link to comment
majstang Posted August 1, 2011 Author Share Posted August 1, 2011 (edited) Made some improvements on the CommercialRemoval script: - If script gets triggered from the Intelligent hibernationscript after recording task it has no longer any limitation on how many recordings to remove commercials from. For example if having 10 tuners and all finishing their recordings simultaneously all will be processed. If one tuner finish the recording before the others only the finished recording will be processed. - Added property/metadata copy from input to output file with Grigas PropCopy. Use the recordings properties for Windows Explorer to better see the result (choose this option on one of the first splash screens when installing RS) - Improved the error management handling a bit - Added a PATH CONFIGURATION section. Your path information is needed to get the script going. For other options like Comskip H.264, transparency and drag 'n drop batchprocessing follow the instructions in the first post of this thread. Remaining issues - During heavy CPU/RAM load at the same time doing commercial removing, a VideoReDo error message can appear telling you "Server is busy". I'm still not exactly sure on why it shows, but if it does either let it be (script will try to redo this step one time). Tried newer versions of VideoReDo, but they were worse. Best working version is still VideoReDo TVSuite v.4.20.5.600. - Sometimes Comskip confuses audio PID with Teletext PID on the .ts recording and when passed to VideoReDo it tries to recode audio. VideoReDo crashes when this happens and it won't work removing commercials from this .ts ever. The problem occurs if having Teletext or DVB Subtitle activated in Recording Service Output Format Options. It is recommended to disable those, cuz VideoReDo wont keep this kind of subtitles on edited .ts anyway. Edited December 29, 2011 by majstang Quote Link to comment
majstang Posted December 4, 2011 Author Share Posted December 4, 2011 (edited) New CommercialRemoval script Changes: To get rid of the very annoying "Server is busy" message error I found a way to make the VideoReDo commercial editing entirely commandline based. The script no longer starts any visible Videoredo batch manager GUI, everything now takes place in a command prompt, which can be hidden if so preferably. That also fixes the issue with the script being sensitive to mouseclicks and keystrokes. Changes: More and more channels tend to use their logo even on the commercials...making Comskip unabled to detect it. Some other detecting methods can then be used. You will then end up with different comskip.inis for different channels. The script can detect which channel the recording is made on and assign a special comskip.ini for it. In my case for example TV3.ini which works very well detecting all commercials (where the original comskip.ini fails). Setup for this can be done in the "RETRIEVE MEDIAFILE FORMAT - MPEG-2 OR H.264" and "COMSKIP FILE PROCESSING" section. Notes: The latest VideoReDo version 629d, indtroduced support for multiple audiostreams. Default is enabled. The CommercialRemoval script fails with the default, cuz Comskip is not yet adapted to the changes introduced in the new Videoredo version. To disable it: - Start VideoRedo-->Hold down "Shift"-->Click "Tools"-->Click "Options" - In the list that follows scroll down to "70. Support for multiple audiostreams" and change 1 to 0. - Press OK and restart VideoReDo. Support for multiple audiostreams is now disabled Notes: Recent Comskip versions can be configured using all 4 CPU cores at once making commercial detection 100% faster for H.264 material. Remaining issues: Sometimes Comskip confuses audio PID with Teletext PID on the .ts recording and when passed to VideoReDo it tries to recode audio. VideoReDo crashes when this happens and it won't work removing commercials from this .ts ever. The problem occurs if having Teletext or DVB Subtitle activated in Recording Service Output Format Options. It is recommended to disable those, cuz VideoReDo wont keep this kind of subtitles on edited .ts anyway. Edited December 29, 2011 by majstang Quote Link to comment
majstang Posted December 16, 2011 Author Share Posted December 16, 2011 Remaining issues: Sometimes Comskip confuses audio PID with Teletext PID on the .ts recording and when passed to VideoReDo it tries to recode audio. VideoReDo crashes when this happens and it won't work removing commercials from this .ts ever. The problem occurs if having Teletext or DVB Subtitle activated in Recording Service Output Format Options. It is recommended to disable those, cuz VideoReDo wont keep this kind of subtitles on edited .ts anyway. The audio/subtitle PID confusion issue has been fixed. Comskip v.81.022 (donators version) now also supports detecting of the subtitle PID which enables keeping subtitles when Videoredo is done cutting out the commercials. Comskip creates project files, the VPrj. When opening a .ts without a project (Vprj) in Videoredo, it automatically searches and detects video, audio and subtitle PIDs, but once a project file is used (like with this script), Videoredo grabs all the PIDs from the VPrj file and bypasses the ordinary search. Earlier Comskip versions only retrieved Video and Audio PIDs and skipped the subtitle PID, hence the subtitles got lost in the Videoredo editing process. Now that is changed. The only thing needed is the new Comskip version and to activate Teletext and/or DVB Subtitle in Recording Service Output Format Options. No changes has been made on the Automatic Commercial Removal script. Quote Link to comment
majstang Posted December 29, 2011 Author Share Posted December 29, 2011 Changes/fixes: - Looping folders to find the location for Comskip.exe and VideoReDo Vp.vbs script took too much time. So long the commercial removal script after recording task somtimes missed detecting when a recording finished (grace period of 90 seconds). Often happened during heavy HTPC load (many recordings going at once, downloading etc). Replaced the looping with absolute paths, which speeds up the script considerably and it never misses detecting any finished recordings. See the PATH CONFIGURATION section. - Removed some errorhandling and instead added a variable for configuring if having the Comskip H.264 donators version or not. Earlier if not having the Comskip H.264 version the script did exit/stop entirely if detecting a H.264 file, despite MPEG-2 recordings was queued up for commercial removal right after it. If "Use_H264_commercialdetetction" is disabled the script wont halt and exit if a H.264 file is detetcted and process will continue if there's queued up MPEG-2 files after it. Updated the first post of this thread and placed all scripts there. Quote Link to comment
majstang Posted December 31, 2011 Author Share Posted December 31, 2011 Last changes of this script: - Hidden mode now gets activated/inactivated in the "PATHS AND CONFIGURATION" section only. Happy new year! Regards majstang Quote Link to comment
utku Posted March 22, 2012 Share Posted March 22, 2012 DVBViewer Recording Properties now can be installed on 64 bit system. Does that mean this script can work ? Quote Link to comment
majstang Posted March 22, 2012 Author Share Posted March 22, 2012 DVBViewer Recording Properties now can be installed on 64 bit system. Does that mean this script can work ? Hi utku! In theory yes! I will get back to you on that when finding some time to test it out the coming next days regards majstang Quote Link to comment
majstang Posted March 22, 2012 Author Share Posted March 22, 2012 DVBViewer Recording Properties now can be installed on 64 bit system. Does that mean this script can work ? Yes, the Automatic Commercial Removal script now works beautiful on 64-bit Windows with the new DVBViewer Recording Properties v.2.0. Many thanks for that Lars No problem to get it to work at all. I just installed the DVBViewer Recording Properties v.2.0 and changed the "VideoredoBatchLocation" path to the vp.vbs (VideoRedo batch script) in the PATHS AND CONFIGURATION section in the Automatic Commercial Removal script. Usually when installing VideoRedo on a 64-bit system it gets located to the "C:\Program Files (x86)\VideoReDoTVSuite4\vp.vbs" folder. Recommend to launch the commercial removal script through the Intelligent Hibernationscript, which delays the standby/hibernation until the commercial removal task is done. http://www.DVBViewer.tv/forum/topic/41387-another-intelligent-hibernationscript/ Regards majstang Quote Link to comment
utku Posted March 23, 2012 Share Posted March 23, 2012 thats great news finally, i been waiting so long for this. I am trying to get code working, but i have a problem. PropCopy_location := "D:\AVI_VOB_BLU-RAY_AC3-tools\TV-tools\DVBViewer\PropCopy_1_2_2\PropCopy.exe" ;Fill in path to PropCopy i choose dvbRecProp_Beta_setup.exe but it doesnt work, then i tried DVBVPropertyHandler.dll it doesnt work neither. Quote Link to comment
majstang Posted March 23, 2012 Author Share Posted March 23, 2012 (edited) thats great news finally, i been waiting so long for this. I am trying to get code working, but i have a problem. PropCopy_location := "D:\AVI_VOB_BLU-RAY_AC3-tools\TV-tools\DVBViewer\PropCopy_1_2_2\PropCopy.exe" ;Fill in path to PropCopy i choose dvbRecProp_Beta_setup.exe but it doesnt work, then i tried DVBVPropertyHandler.dll it doesnt work neither. Yes, these fileinfo/propety/metadata tools can be confusing at first not knowing what they really are doing and good for. DVBViewer Recording Properties v.2.0 (dvbRecProp_Beta_setup.exe) and the PropCopy are two separate tools. - RS uses the DVBViewer Recording Properties tool to enable the Vista/Windows 7 explorer to show the detailed fileinfo for DVBViewer recordings. This tool should only be installed on your system and applying paths to this tool isn't needed in the script. - Unfortunately when editing the original recording with VideoRedo this detailed fileinfo (often stored somewhere in the beginning of the original recording) simply gets wiped out in the edited copy/output. The PropCopy tool is then used to copy the fileinfo from the original recording over to the commercial-free recording. PropCopy is a tool which can be downloaded from: www.DVBViewer.tv/members/ Using the script without this tool requires some minor code changes on several places and I therefor think the easiest way to make it work for you would be to download it and apply the path to it in the PATHS AND CONFIGURATION section in the script. Regards majstang Edited March 23, 2012 by majstang Quote Link to comment
utku Posted March 23, 2012 Share Posted March 23, 2012 hi again, sorry for taking your time, also thank you for all the answers. RS_Recording_folder := "C:\Users\utku\Desktop\kayitlar" ;Fill in path to RS Recording Folder PropCopy_location := "C:\Users\utku\Desktop\basla\PropCopy.exe" ;Fill in path to PropCopy Comskip_location := "C:\Users\utku\Desktop\yeni son kom\comskip.exe" ;Fill in path to Comskip VideoredoBatchLocation := "C:\Program Files (x86)\VideoReDoTVSuite4\vp.vbs" ;Fill in path to vp.vbs Use_H264_commercialdetetction := "H.264" ;H.264 commercial detetction only works with Comskip donators version. Free version MPEG-2 only. here is my paths and configuration section. Im sure all the paths are correct. Also i deleted ; from Use_H264_commercialdetetction to use H264 detection. When i drag and drop a ts file to CommercialRemover.exe Shortcut, program starts in taskbar and then after certian time(5 to 10 seconds) there is one command line window opened and closed in one second, then CommercialRemover.exe taskbar icon dissapers. How can i debug this code ? i have visual studio 2010 installed on pc. i also have i7-2600k like you, which overclocked to 4.6ghz and using comskip 81_034_donators also thread_count=8, i am seeing 170fps to 220 fps on h264 and computer doesnt exceeds %20-30 percent. what do you fps see on h264? Thanks a lot, again. Utku Quote Link to comment
majstang Posted March 24, 2012 Author Share Posted March 24, 2012 (edited) When i drag and drop a ts file to CommercialRemover.exe Shortcut, program starts in taskbar and then after certian time(5 to 10 seconds) there is one command line window opened and closed in one second, then CommercialRemover.exe taskbar icon dissapers. Seems it's the comskip step failing for you. You will have to check if all variables has correct values in the script, which are then fed to comskip. First of all make sure setting up RS Webinterface-->Configuration-->Recorder-->Output Format-->Video/Audio TS (*.ts). Trying to make comskip detect commercials on mpg files won't work because of the -t parameter (which stands for ts files) when the script calls comskip. RunWait, %comspec% /c %Comskip_location% -t --videoredo "%latest_file_drop%",, %Hide_commandline_userinterface% Also make sure your comskip.ini is present in the comskip folder. A little tip when testing and trying to make the script work. It's easier to dragndrop the files onto the ahk script itself instead of the exe shortcut. Then you wont have to compile it each and every time when doing changes in the ahk. How can i debug this code ? i have visual studio 2010 installed on pc. Debugging Autohotkey scripts doesn't require any tool else other than a texteditor, preferably Notepad++. You then add messageboxes for the variables to check their input values. For example like this: #SingleInstance ignore ;---------------------------------------------------------------------------------------------------------- ;Activate/inactivate codelines by removing/adding the semicolon ";" infront of a line. ;---------------------------------------------------------------------------------------------------------- ;-PATHS AND CONFIGURATION---------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------------------- RS_Recording_folder := "C:\Users\utku\Desktop\kayitlar" ;Fill in path to RS Recording Folder PropCopy_location := "C:\Users\utku\Desktop\basla\PropCopy.exe" ;Fill in path to PropCopy Comskip_location := "C:\Users\utku\Desktop\yeni son kom\comskip.exe" ;Fill in path to Comskip VideoredoBatchLocation := "C:\Program Files (x86)\VideoReDoTVSuite4\vp.vbs" ;Fill in path to vp.vbs Use_H264_commercialdetetction := "H.264" ;H.264 commercial detetction only works with Comskip donators version. Free version MPEG-2 only. ;Hide_commandline_userinterface := "Hide" ;If activated hides commandline windows used by the script. ;---------------------------------------------------------------------------------------------------------- ;-CONDITIONING OF THE HIDE VARIABLE------------------------------------------------------------------------ ;---------------------------------------------------------------------------------------------------------- If Hide_commandline_userinterface Hide_commandline_userinterface := Hide_commandline_userinterface Else Hide_commandline_userinterface := %ErrorLevel% ;---------------------------------------------------------------------------------------------------------- ;-DRAG AND DROP FUNCTIONALITY------------------------------------------------------------------------------ ;---------------------------------------------------------------------------------------------------------- Loop %0% ; For each parameter (or file dropped onto a script): { GivenPath := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index. Loop %GivenPath%, 1 latest_file_drop = %A_LoopFileLongPath% SplitPath, latest_file_drop, OutFileNameDrop, OutDirDrop,, OutNameNoExtDrop latest_file_drop = %OutDirDrop%\%OutFileNameDrop% msgbox % latest_file_drop ; File dropped on script ;-RETRIEVE MEDIAFILE FORMAT - MPEG-2 OR H.264------------------------------------------------------------ File_properties := GetDetailsOf(latest_file_drop) RegExMatch(File_properties, "MPEG2", MPEG2) RegExMatch(File_properties, "H.264", H264) RegExMatch(File_properties, "TV3", TV3) RegExMatch(File_properties, "Sjuan", Sjuan) msgbox, %MPEG2%`n`n%H264% ; Checks if dropped file is MPEG2 or H.264 ;-CONDITIONING OF THE H.264 VARIABLE--------------------------------------------------------------------- If Use_H264_commercialdetetction = H.264 Use_H264_commercialdetetction := "H.264" Else Use_H264_commercialdetetction := ErrorLevel ;-COMSKIP FILE PROCESSING-------------------------------------------------------------------------------- Loop, %A_ScriptDir%\%OutNameNoExtDrop%.ts, , 0 latest_file_exist := A_LoopFileFullPath If latest_file_exist { MsgBox, 64, INTERRUPTION MESSAGE, %latest_file_exist%`nalready exists in output folder.`nScript will terminate in 15 seconds., 15 ExitApp } Else { If MPEG2 { If TV3 or Sjuan { Loop, %A_programfiles%\TV3.ini, , 1 ; Recurse into subfolders. TV3ini := A_LoopFileShortPath RunWait, %comspec% /c %Comskip_location% -t --videoredo --ini="%TV3ini%" "%latest_file_drop%",, %Hide_commandline_userinterface% } If TV3= { If Sjuan= RunWait, %comspec% /c %Comskip_location% -t --videoredo "%latest_file_drop%",, %Hide_commandline_userinterface% } } Else { If Use_H264_commercialdetetction = H.264 RunWait, %comspec% /c %Comskip_location% -t --videoredo "%latest_file_drop%",, %Hide_commandline_userinterface% } ;-VIDEOREDO FILE PROCESSING-------------------------------------------------------------------------------- Sleep, 3000 If MPEG2 RunWait, %comspec% /c cscript.exe //nologo "%VideoredoBatchLocation%" "%OutDirDrop%\%OutNameNoExtDrop%.VPrj" "%A_ScriptDir%\%OutNameNoExtDrop%.ts" /p:"MPEG2 Transport Stream" /q, , %Hide_commandline_userinterface% If H264 { If Use_H264_commercialdetetction = H.264 RunWait, %comspec% /c cscript.exe //nologo "%VideoredoBatchLocation%" "%OutDirDrop%\%OutNameNoExtDrop%.VPrj" "%A_ScriptDir%\%OutNameNoExtDrop%.ts" /p:"H.264 Transport Stream" /q, , %Hide_commandline_userinterface% } ;-PROPCOPY AND CLEANUP AFTER PROCESSING-------------------------------------------------------------------- RunWait, %PropCopy_location% "%OutDirDrop%\%OutNameNoExtDrop%.ts" "%A_ScriptDir%\%OutNameNoExtDrop%.ts" ;Metadata/Fileinfo copy FileRecycle, %OutDirDrop%\%OutNameNoExtDrop%.VPrj FileRecycle, %OutDirDrop%\%OutNameNoExtDrop%.incommercial ;Filemove, %A_ScriptDir%\%OutFileNameDrop%, %OutDirDrop%\%OutFileNameDrop%, 1 ;Moves edited recording and overwrites original recording. } } ;------------------------------------------------------------------------------------------------------------ ;-RS AFTER RECORDING TASK - COMMERCIAL PROCESSING WHEN RECORDINGS FINISHES----------------------------------- ;------------------------------------------------------------------------------------------------------------ If latest_file_drop = right_Now := a_now timelimit := right_Now EnvAdd, timelimit, -90, seconds FileList = b_index=0 Loop, %RS_Recording_folder%\*.ts { if A_LoopFileTimeModified between %timelimit% and %right_Now% { b_index++ file%b_index% := A_LoopFileFullPath ;FileList = %FileList%%A_LoopFileTimeModified%`t%b_index%`t%A_LoopFileName%`n ;Enable this line to debug with msgbox Please hit } } ;msgbox, 4, , Please hit ^c (while this is displayed) to copy to clipboard `n`n%FileList%`n`n%A_Now%, 10 Loop %b_index% { SplitPath, file%a_index%, OutFileName, OutDir,, OutNameNoExt latest_file = %OutDir%\%OutFileName% ;-RETRIEVE MEDIAFILE FORMAT - MPEG-2 OR H.264-------------------------------------------------------------- File_properties := GetDetailsOf(latest_file) RegExMatch(File_properties, "MPEG2", MPEG2) RegExMatch(File_properties, "H.264", H264) RegExMatch(File_properties, "TV3", TV3) RegExMatch(File_properties, "Sjuan", Sjuan) ;-CONDITIONING OF THE H.264 VARIABLE--------------------------------------------------------------------- If Use_H264_commercialdetetction = H.264 Use_H264_commercialdetetction := "H.264" Else Use_H264_commercialdetetction := ErrorLevel ;-COMSKIP FILE PROCESSING---------------------------------------------------------------------------------- Loop, %A_ScriptDir%\%OutNameNoExt%.ts, , 0 latest_file_exist := A_LoopFileFullPath If latest_file_exist { MsgBox, 64, INTERRUPTION MESSAGE, %latest_file_exist%`nalready exists in output folder.`nScript will terminate in 15 seconds., 15 ExitApp } Else { If MPEG2 { If TV3 or Sjuan { Loop, %A_programfiles%\TV3.ini, , 1 ; Recurse into subfolders. TV3ini := A_LoopFileShortPath RunWait, %comspec% /c %Comskip_location% -t --videoredo --ini="%TV3ini%" "%latest_file%",, %Hide_commandline_userinterface% } If TV3= { If Sjuan= RunWait, %comspec% /c %Comskip_location% -t --videoredo "%latest_file%",, %Hide_commandline_userinterface% } } Else { If Use_H264_commercialdetetction = H.264 RunWait, %comspec% /c %Comskip_location% -t --videoredo "%latest_file%",, %Hide_commandline_userinterface% } ;-VIDEOREDO FILE PROCESSING-------------------------------------------------------------------------------- Sleep, 3000 If MPEG2 RunWait, %comspec% /c cscript.exe //nologo "%VideoredoBatchLocation%" "%OutDir%\%OutNameNoExt%.VPrj" "%A_ScriptDir%\%OutNameNoExt%.ts" /p:"MPEG2 Transport Stream" /q, , %Hide_commandline_userinterface% If H264 { If Use_H264_commercialdetetction = H.264 RunWait, %comspec% /c cscript.exe //nologo "%VideoredoBatchLocation%" "%OutDir%\%OutNameNoExt%.VPrj" "%A_ScriptDir%\%OutNameNoExt%.ts" /p:"H.264 Transport Stream" /q, , %Hide_commandline_userinterface% } ;-PROPCOPY AND CLEANUP AFTER PROCESSING-------------------------------------------------------------------- RunWait, %PropCopy_location% "%RS_recording_folder%\%OutNameNoExt%.ts" "%A_ScriptDir%\%OutNameNoExt%.ts" ;Metadata/Fileinfo copy FileRecycle, %OutDir%\%OutNameNoExt%.VPrj FileRecycle, %OutDir%\%OutNameNoExt%.incommercial ;Filemove, %A_ScriptDir%\%OutFileName%, %OutDir%\%OutFileName%, 1 ;Moves edited recording and overwrites original recording. } } ;---------------------------------------------------------------------------------------------------------- ;-FUNCTIONS------------------------------------------------------------------------------------------------ ;---------------------------------------------------------------------------------------------------------- GetDetailsOf(inFileName) { SplitPath,inFileName,sFileName,sFileDir objFolder := ComObjCreate("Shell.Application").Namespace(sFileDir . "\") objFile := objFolder.Parsename(sFileName) Loop { iAttribute := objFolder.GetDetailsOf(objFolder, A_Index) if not iAttribute break if (iValue := objFolder.GetDetailsOf(objFile, A_Index)) ;only add attribs with values details .= A_Index . " : " . iAttribute . " = " . iValue . "`n" } return details, objFolder := "", objFile := "" } First msgbox checks the file dropped onto the script. The second checks if the dropped files are a MPEG2 or H.264. If the latter msgbox are empty there is something wrong with the DVBViewer Recording Properties values, which will make the comskip step failing and script exits without any error message. Let me know what you see here. i also have i7-2600k like you, which overclocked to 4.6ghz and using comskip 81_034_donators also thread_count=8, i am seeing 170fps to 220 fps on h264 and computer doesnt exceeds %20-30 percent. what do you fps see on h264? I have the h264 function inactivated, cuz my HD channels has no commercials. Have no HD recordings saved at the moment, but will record some and check later.EDIT: My comskip fps rate on h264 is about 1100 fps with thread_count=8. No overclocking. Edited March 24, 2012 by majstang Quote Link to comment
utku Posted March 26, 2012 Share Posted March 26, 2012 Man you are genius )) Yes you were right, comskip step was failing. After i moved the CommercialRemover.ahk to Comskip folder it ran succesfully but than Videoredo step was failing and Second msgbox saved me. As you can see on printscreen "RETRIEVE MEDIAFILE FORMAT" section does not get the format and second message box is empty. Than i remove the if statments for MPEG2 and H264 now the code works. ))) -VIDEOREDO FILE PROCESSING-------------------------------------------------------------------------------- Sleep, 3000 RunWait, %comspec% /c cscript.exe //nologo "%VideoredoBatchLocation%" "%OutDir%\%OutNameNoExt%.VPrj" "%A_ScriptDir%\%OutNameNoExt%.ts" /p:"H.264 Transport Stream" /q, , %Hide_commandline_userinterface% I did now understand why DVBViewer Recording Properties does not work. Isnt Recorded Tv section available means that my Recording Properties work ? Also thank you for all your tips, it helped a lot, i have at least working code. I am using Notepad++ now. Last, Are you sure that you see 1100 fps on h264 material ? because i see 1100 fps only on MPEG2, also comskip has a bug that it cant use all the i7's power, example on mine, it does not exceeds %30 percentage. Are tested on 32 bit or 64 bit? Thanks again. Utku. Quote Link to comment
majstang Posted March 26, 2012 Author Share Posted March 26, 2012 (edited) Yes you were right, comskip step was failing. After i moved the CommercialRemover.ahk to Comskip folder it ran succesfully but than Videoredo step was failing and Second msgbox saved me. As you can see on printscreen "RETRIEVE MEDIAFILE FORMAT" section does not get the format and second message box is empty. I did now understand why DVBViewer Recording Properties does not work. Isnt Recorded Tv section available means that my Recording Properties work ?Hi Utku! Actually your Recording Properties details looks fine to me. The script searches for the "Video compression" value and as marked in the second properties picture of yours, the value are valid. Now the reason for the script fails finding the videocompression value could be permissions/security related. In other words it could be problematic to locate executable files and other files the script has to access in the C:/users directory. I have stumbled on this very thing before when scripts are being denied access (or partly denied) to files in the users folders. Even the Windows partition and more particular the program files folder can be problematic for scripts to access and it can therefor be a good idea to move the RS recording folder, comskip and the script to some other partition or folder. Than i remove the if statments for MPEG2 and H264 now the code works. ))) Well, if not using the If statements videoredo wont work alright when it tries to edit a H.264 which is in fact a MPEG2 and vice versa. Could be problematic. Last, Are you sure that you see 1100 fps on h264 material ? because i see 1100 fps only on MPEG2, also comskip has a bug that it cant use all the i7's power, example on mine, it does not exceeds %30 percentage. Are tested on 32 bit or 64 bit? Yes, the 1100 fps for H.264 was tested on my 64-bit system with 8GB RAM and for MPEG2 it was 2300 fps. Haven't checked the CPU load though. Best regards majstang Edited July 2, 2012 by majstang Quote Link to comment
majstang Posted March 26, 2012 Author Share Posted March 26, 2012 Last, Are you sure that you see 1100 fps on h264 material ? because i see 1100 fps only on MPEG2, also comskip has a bug that it cant use all the i7's power, example on mine, it does not exceeds %30 percentage. Are tested on 32 bit or 64 bit? Hi Utku! Just tested comskip on a H.264 with both 32- and 64-bit and it's the same 1100 fps, but for me i have a CPU load of 80-85%. All 8 threads are used (two per core). I remember reading somewhere in the comskip forum people had problems getting it to work. Didn't take much notice of it though cuz it worked the first try for me. regards majstang Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.