Thursday, November 8, 2012

disappear restore safely remove hardware tray icon windows xp

It's been a long time. This isn't so novel or interesting a fix, but I needed it, and it works great.

Problem is sometimes the remove hardware icon disappears on my old Windows XP, HP DV9000 box. I just don't feel comfortable pulling out usb devices or SD devices without first commanding the OS to manually unmount it.

Here's simple cmd or batch file to relaunch the windows xp hardware removal tray icon.

C> rundll32 shell32.dll,Control_RunDLL hotplug.dll

From Tom's Hardware forums.

Thursday, April 5, 2012

chunk splice mp4 video

To non-destructively extract a splice (chunk, subportion) from an .mp4 video file, I use mp4box from the command line. But the syntax is a bit wordy and hard to remember, mp4box takes START_SEC and END_SEC and a command line switch as arguments. So I created a basic wrapper batch script dedicated to splicing mp4 using mp4box that takes minutes and seconds as START_MIN START_SEC END_MIN END_SEC. You can also use total (absolute) sec by (obviously) setting MIN value to 0 and SEC to the total secs.

USAGE EXAMPLE:
mp4chunk_minsec 10 0 10 30 myvid.mp4
@rem mp4chunk_minsec.bat (4/2012)

@rem extracts mp4 chunk by min.sec

@rem mp4box -split-chunk S:E
@rem            extracts a new file from Start to End (in seconds)

@rem fontend wrapper:
@rem mp4chunk_minsec <start_min> <start_sec> <end_min> <end_sec> <file.mp4>

@echo off
set STARTM=%1
set STARTS=%2
set ENDM=%3
set ENDS=%4

if "%5"=="" goto USAGE

SET /a STARTS=%STARTM%*60+%STARTS%
SET /a ENDS=%ENDM%*60+%ENDS%
echo STARTS=%STARTS%
echo ENDS=%ENDS%
mp4box -split-chunk %STARTS%:%ENDS% %5


goto END
:USAGE
echo usage: mp4chunk_minsec ^<start_min^> ^<start_sec^> ^<end_min^> ^<end_sec^> ^<file.mp4^>
echo.

:END

mp4box subs: rejects blank empty srt line (ccextractor generated srt)

I use ripbot264 to transcode from mpg to mp4, saving 75 to 80% space, and embed cc/subtitles. Ripbot264 is gui (I believe it is delphi) frontend which automates a number of powerful freeware audio/video conversion tools. One of these tools is mp4box, which is used for the final mux.

The bug/error/prickliness I hit upon was that mp4box rejects (errors out on) srt subtitle files (extracted using ccextractor [todo link]) which contain multiline subtitles with empty line consisting of all spaces. (I think) such a line might be technically illegal, as empty lines act as record separators, but these empty lines consist of multiple spaces, so they should not be treated as empty lines. But I suspect mp4box trims leading/trailing spaces as preprocess, so it, incorrectly, looks just like the empty line delimiter.

The workaround is the following srtfix.bat which uses sed to detect multi-space empty line and replace the last space with '-'. It handles optional '^M' eol match with ".\?$" regexp. It has an extra bell & whistle, in that it first confirms that the srt is in fact invalid using mp4box own srt converter feature to see if it accepts the srt file.

@rem SRTFIX.bat (4/2012)
@rem fix blank lines in srt by adding - to the end

@rem first test srt

echo %~n1
@rem @goto END

c:\p\mp4box\mp4box -ttxt %1
@echo ERRORLEVEL=%ERRORLEVEL%
if %ERRORLEVEL%==0 goto NOERROR

@rem search blank space line, add '-' to end
sed "/^ *.\?$/s/ \(.\?\)$/-\1/" %1 > %~n1.fix
move %1 %1.orig
move %~n1.fix %1

goto END

:NOERROR
@rem cleanup
@del %~n1.ttxt

:END
some sample output and diff:
C:\Temp\RipBot264temp>dir s*
Volume in drive C is OS
Volume Serial Number is CA5D-3C54

Directory of C:\Temp\RipBot264temp

04/05/2012  12:06 PM           198,108 s.srt
04/04/2012  09:22 PM           198,108 s.srt.orig
04/05/2012  12:22 PM               417 srtfix.bat
           3 File(s)        396,633 bytes
           0 Dir(s)  97,269,633,024 bytes free

C:\Temp\RipBot264temp>fc s.srt s.srt.orig
Comparing files s.srt and S.SRT.ORIG
***** s.srt
WHEN I WAS 5.
                           -

***** S.SRT.ORIG
WHEN I WAS 5.


*****

***** s.srt
WHEN I WAS 5.
                           -
I SAW YOYO MA ON "MR. RODGERS
***** S.SRT.ORIG
WHEN I WAS 5.

I SAW YOYO MA ON "MR. RODGERS
*****

***** s.srt
00:33:24,036 --> 00:33:24,534
                           -
I SAW YOYO MA ON "MR. RODGERS
***** S.SRT.ORIG
00:33:24,036 --> 00:33:24,534

I SAW YOYO MA ON "MR. RODGERS
*****

Thursday, March 22, 2012

fbreader workaround / fix defaulting text-align center bug

Problem: FBReader defaults to text-align center when viewing epub files created in calibre. It should be defaulting text-align to left as is would be expected.

We could recompile FBReader. Others have suggested a patch to do so: http://groups.google.com/group/fbreader/browse_thread/thread/6259666627148e63

I don't feel like source code diving and compiling my own FBReader at the moment.

I have a simpler workaround:
  1. extract epub file with unzip
  2. add the following 1 line to stylesheet.css:
    body { text-align: justify }
  3. pack epub file with zip

Friday, October 28, 2011

Change file timestamp

A crude python script to change modify/access file timestamps, after the new NAS would incorrectly change them to current time. Note: only changes modify and access time. File create time cannot be changed by standard python calls. From quick online research, it is suggested lower level, OS dependent, privileged system calls or crudely changing the system clock is required to change creation times.
import sys, os, time

sys.exit()  # hardcode the changed timestamp below

stime1 = "08/24/2010  06:24 PM" # everyday food video
stime2 = "06/29/2010  04:31 PM" # neely video
ts = time.strptime(stime2, "%m/%d/%Y  %I:%M %p")

print ts
print time.mktime(ts)
setTimeVal = time.mktime(ts)

print sys.argv[0]
print len(sys.argv)
if len(sys.argv) < 2:
 print "usage ", sys.argv[0], " <filename>"
 sys.exit(-1)

filename = sys.argv[1]

ts = os.stat(filename)
print ts

os.utime(filename, (setTimeVal,setTimeVal))

Monday, October 3, 2011

autohotkey script to toggle window always on top attribute

This simple autohotkey script makes the windows-space a hotkey to set the active window to be always on top. Often useful when I am multitasking while watching video, so the video won't get covered by other application windows.
;win-space alwaysontop.ahk
#SingleInstance force

#Space:: 
MsgBox, , ,Always on Top toggle,1
WinSet, AlwaysOnTop, Toggle, A

Friday, September 30, 2011

Bad Pool Caller BSOD fix

Broken computer. My di came to me with his 4 year old HP dv9500 Vista laptop computer, which would not load to windows. The only recent change to the computer he knew of were the typical unending software update requests.

I took a look at his computer, and it was BSOD with BAD_POOL_CALLER STOP: C2 after it seems all hardware drivers are loaded. I always have "No GUI Boot" set, to see the diagnostic messages and drivers load during bootup.

Googled around for "Bad Pool", and the top hits suggested hardware failure, probably RAM. A few blamed registry corruption, with other posters denying it could be registry corruption, claiming registry cleaners were a scam at best, and would destroy your registry and computer along with it, at worse.

His computer was able to F8 boot in to Vista recovery mode.

I checked my RAM with the bios diagnostic and with Vista memory diagnostic. A whole lot of nothing. I ran quick HDD check from bios, still nothing. I tried recovering going back through update checkpoints for a couple of days. The most recent ones failed to roll back, with something like "file already created" error. Finally going back a week days succeed. But still same BSOD.

Finally I ran System Restore to go 5 days back. And Viola, the system starts as it should.

I don't know what caused the error. If it was a driver or registry type of problem as this BSOD code is blamed for, it suggests to me the OS was getting corrupted by software. I am just guessing the precise cause: perhaps it was a failed OS update that ended up corrupted; or anti-virus software mayham after an update -- I did notice the computer had 4 anti-virus anti-spyware running and updated. I got rid of Immunet. Kept PC Tools, MSE, Mcafee -- which seems to only scan on demand.