Saturday, May 08, 2010

MDL: Script to Convert MPG to AVIs

The MPG videos that I have are not getting along with XBMC.  To get around this I need to convert them all to AVI format.

avidemux has a great command utility and PowerShell has the power to batch the process.

$avidemux = New-Object System.Diagnostics.ProcessStartInfo
$avidemux.FileName = "D:\avimux\avidemux2_cli.exe"
$avidemux.windowStyle ="Hidden"

foreach
($SourceVideoFile in (Get-ChildItem @("D:\videos\") -recurse -include @("*mpg", "*.mpeg") | sort-object name))
{      
    $SourceVideoFile.fullname
    $avidemux.arguments = "--autoindex --load ""{0}"" --save ""{1}"" --output-format AVI --quit" -f $SourceVideoFile.fullname, ($SourceVideoFile.directoryname + "\" + $SourceVideoFile.basename +".avi")
    $avidemuxProcess = [System.Diagnostics.Process]::Start($avidemux)
    $avidemuxProcess.WaitForExit()
}

All done!  The videos all converted in a couple of hours.

Technorati Tags: ,,

No comments:

Post a Comment