Me: I live in Silicon Valley with my wife, child and cat. I have worked at Microsoft since I graduated from College, both in the Macintosh Business Unit on products such as Outlook Express, Entourage, IE, and Virtual PC and in Windows Live on Hotmail, Calendar and People. I am currently a Principal Lead Program Manager on the Windows Live Social Networking team. I basically manage a team of Program Managers responsible for delivering features to support our web and client applications. I've been blogging since 2001 and like to play around with .NET in my spare time working on projects such as dasBlog (the blog that powers this site) and Send to SmugMug (an application for uploading photos to SmugMug). I blog about a number of technology and productivity related topics.
Powered by: newtelligence dasBlog 2.3.9074.18820
Disclaimer The posts on this weblog are provided "AS IS" with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2010, Omar Shahine
E-mail
Since having a kid we have sort of fallen in love with the movie taking capabilities of our point and shoot digital cameras. We take a lot of 30 second – 1 minute videos. Probably over 1,000 in the past 2 years. We then rate and tag them like we do our photos.
I have owned a number of Panasonic and Canon cameras over the years. Recently I switched back to a Canon PowerShot SD880 for a few reasons:
The latter being the most important. Previous video cameras all shoot their video using Motion JPEG. H.264 is the new hotness in video codecs. The only problem is that the Canon shoots the video in a QuickTime MOV container which is not readable by Windows 7 without the QuickTime codecs. Also the bitrate is around 10 MBps which is huge for the quality of video it shoots.
Well, I’ve been using Handbrake, which is a really awesome video encoder for Windows and Mac to encode some video files for our iPod Touch. It turns out Handbrake is a fantastic application for re-encoding these digigam video files. On average I am seeing at least 3x - 6x smaller encoded files with the same quality.
But using Handbrake each time I download videos can be a bit cumbersome. I’ve been messing around with PowerShell lately now that it’s build into Windows 7 and am really loving what I can do with it. I’ve never been a batch scripter and like the more object oriented nature to C# applications to do these kinds of things. PowerShell does the job really well once you get over the small learning curve.
Below is a PowerShell script I wrote that will take all the videos in one folder and encode them into another folder skipping any already encoded files.
All you need to do is configure the first 3 variables:
$sourceFolder = "C:\Users\Public\Videos\_Ingest\" $destinationFolder = "C:\Users\Public\Videos\Encoded\" $handBrakeCli = "C:\Program Files\Handbrake\HandBrakeCLI.exe" $files = dir $sourceFolder *.mov foreach ($file in $files) { $baseName = $file.Name.Trim('.mov') $source = $file.FullName $destination = $destinationFolder + $baseName + ".mp4" if (Test-Path $destination) { Write-Output "skipping $source" } else { $scriptString = "-i '$source' -t 1 -c 1 -o '$destination' -f mp4 -p -e x264 -b 2000 -2 -T -a 1 -E faac -B 160 -R 0 -6 mono -D 1 -x ref=2:bframes=2:me=umh -v" $sp = [diagnostics.process]::start("$handBrakeCli", "$scriptString") $sp.WaitForExit() } }