If anyone interested in lossless WMA with more uptodate Expression encoder with foobar2000 on win7 64bit, then I've added comments to Jon Knepp's script (https://kneppscript.wordpress.com/2011/03/25/encoding-wma-files-using-powershell-and-microsoft-expression-encoder/) on setting it up...
You just need Expression encoder and PowerShell 4 installed. Tagging also works.
foobar_WMACompress.ps1
<#
EAC_WMACompress.ps1
Purpose:
Used to convert/compress individual media files using Microsoft Expression Encoder.
Requirements:
- Microsoft Expression Encoder
(http://www.microsoft.com/downloads/en/details.aspx?FamilyID=5c3c5f97-678c-4c99-a7fc-f84f320c626f)
- Expression Encoder requires .NET 4.0 assemblies therefore PowerShell must be
configured to support the .NET 4.0 CLR (http://msdn.microsoft.com/en-us/library/w4atty68.aspx)
The following content will need to be saved as 'powershell.exe.config' in the appropriate
powershell home directory a.k.a. $psHome (e.g. C:\WINDOWS\system32\windowspowershell\v1.0 or
C:\WINDOWS\syswow64\windowspowershell\v1.0 on 64-bit systems):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- [url=http://msdn.microsoft.com/en-us/library/w4atty68.aspx]http://msdn.microsoft.com/en-us/library/w4atty68.aspx[/url] -->
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319" />
<supportedRuntime version="v3.5" />
<supportedRuntime version="v3.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
</configuration>
- The Microsoft Expression Encoder libraries are 32-bit only, therefore this script
will only work under a PowerShell (x86) session when run on a 64-bit system
Created 3/24/2011
By Jon Knepp
New instructions for foobar2000 (on Windows 7 64bit):
- Install Microsoft Expression Encoder (http://www.microsoft.com/expression/eng/)
- Install PowerShell (http://microsoft.com/powershell)
- Replace %USERPROFILE% with direct paths in this script
- Copy script and wmalpreset.xml into %USERPROFILE%\AppData\Roaming\foobar2000\
- Create encoder preset in foobar2000:
Encoder file: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
Extension: wma
Parameters: -executionpolicy remotesigned -noninteractive -noprofile -file "%USERPROFILE%\AppData\Roaming\foobar2000\foobar_WMACompress.ps1" %s %d
Format is: lossless (or hybrid)
Highest BPS mode supported: 24
Encoder name: WMA Lossless
Added 1/11/2015
mehemed
#>
param ( [string]$Source,
[string]$Destination,
[string]$Comment,
[string]$Artist = $($AlbumArtist),
[string]$Title,
[string]$AlbumArtist = $($Artist),
[string]$Album,
[string]$Year,
[int]$Track,
[string]$Genre,
[string]$Preset = $("WMA Lossless 5.1 Audio")
)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Expression.Encoder") | Out-Null
$job = New-Object Microsoft.Expression.Encoder.Job
#$systemPresets = [Microsoft.Expression.Encoder.Preset]::SystemPresets
#$jobPreset = $systemPresets | ? { $_.Name -match $Preset }
$encoderPreset = [Microsoft.Expression.Encoder.Preset]::FromFile("%USERPROFILE%\AppData\Roaming\foobar2000\wmalpreset.xml")
if (Test-Path -Path $Source) { $srcFile = Get-ChildItem $Source }
else { throw "Source file ($Source) could not be found." }
if ($Destination) {
$outFile = Split-Path -Leaf $Destination
$outputDir = Split-Path -Parent $Destination
}
if (!$outputDir) { $outputDir = $PWD.Path }
try {
# Define Encoder MediaItem
$mediaItem = New-Object Microsoft.Expression.Encoder.MediaItem($srcFile)
# Assign tag metadata to the new MediaItem
if ($Destination) { $mediaItem.OutputFileName = $outFile }
if ($Title) { $mediaItem.Metadata["Title"] = $Title }
if ($Artist) { $mediaItem.Metadata["Artist"] = $Artist }
if ($Track) { $mediaItem.Metadata["Track"] = $Track }
if ($AlbumArtist) { $mediaItem.Metadata["Album Artist"] = $AlbumArtist }
if ($Album) { $mediaItem.Metadata["Album"] = $Album }
if ($Year) { $mediaItem.Metadata["Year"] = $Year }
if ($Genre) { $mediaItem.Metadata["Genre"] = $Genre }
if ($Comment) { $mediaItem.Metadata["Comment"] = $Comment }
# Complete job setup
$job.MediaItems.Add($mediaItem)
$job.CreateSubfolder = $false
$job.OutputDirectory = $outputDir
$job.ApplyPreset($encoderPreset)
# Define EventHanlder ScriptBlock for EncoderProgress Event
$onProgress_EventHandler = [ScriptBlock]{
param ( [PSObject]$Sender,
[Microsoft.Expression.Encoder.EncodeProgressEventArgs]$e
)
$activity = "Encoding '{0}' by {1} as {2}" -f $Title, $Artist, $encoderPreset.Name
$status = "Encoding '{0}' {1}% Pass {2} of {3}" -f `
$e.CurrentItem.ActualOutputFileName, `
[int]$e.Progress, `
$e.CurrentPass, `
$e.TotalPasses
Write-Progress -Activity $activity -Status $status -PercentComplete ([int]($e.Progress))
}
# Register onProgress Event Handler with Encoder Job object
$job.add_EncodeProgress($onProgress_EventHandler)
# Start Encoding Job
$job.Encode()
}
catch {
# Generate log file if error occurs
$errLog = "{0}\{1}.log" -f $outputDir, $outFile
"Command Line: {0}" -f $MyInvocation.Line | Out-File $errLog -Append
$_ | Out-File $errLog -Append
throw $_
}
finally {
$job.Dispose()
}
wmalpreset.xml
<?xml version="1.0" encoding="utf-8"?>
<!--Created with Expression Encoder version 4.0.4276.0-->
<Preset
Version="4.0">
<Job />
<MediaFile>
<OutputFormat>
<WindowsMediaOutputFormat>
<AudioProfile>
<WmaAudioProfile
Codec="WmaLossless"
Channels="2"
BitsPerSample="16"
SamplesPerSecond="44100">
<Bitrate>
<VariableQualityBitrate
Quality="100" />
</Bitrate>
</WmaAudioProfile>
</AudioProfile>
</WindowsMediaOutputFormat>
</OutputFormat>
</MediaFile>
</Preset>