NAudio in Windows Azure /Windows Server 2008 R2

2020-03-31 08:43发布

问题:

I am using NAudio to merge a few mp3 files together for a Windows Azure product. It works fine in the dev environment but once i upload it to Azure, I get the "No Drive Calling acmFormatSuggest" error.

Here's the list of things I have done so far on the Windows Azure Box, trying to fix the issue.

(i) Enabled Windows Audio Service (ii) Installed the Fraunhofer IIS MPEG Layer-3 ACM Codec that is supported by Windows Media Player. (iii) Installed the Lame Mp3 Codec (iv) Installed the K-Lite Codec

The process itself is a worker process and is running under full trust. The code itself reads the mp3 files from the blob, merges it together using a local file and restores it in the blob.

Any ideas or suggestions will be greatly helpful.

回答1:

See my answer to this question. Also, you need to be sure you are running a 32 bit process, as most ACMs are 32 bit.



回答2:

I battled this myself, and these are the steps to follow:

Manually:

  1. Via Server Manager you can add the Windows Feature "Desktop experience"
  2. Reboot the server as requested (you must for it to take effect)
  3. You can now use the regular Mp3 audio codec NAudio uses (you don't need the Dmo one)

Automatically (Azure deployments):

Add these commands to a Startup.cmd startup task in Azure for your role:

echo Begin Install Desktop Experience Feature (for sound codec) >> startup.log
ServerManagerCMD.exe -install Desktop-Experience -restart -resultPath     desktopexperience_results.xml
REM This return code indicates the feature is already installed. Reset the errorlevel to zero using the verify command.
IF %ERRORLEVEL% EQU 1003 (
    echo Windows feature is already installed >> startup.log
    VERIFY > NUL
)
echo End Install Desktop Experience Feature >> startup.log

Note that it is important this script returns a result code (%ERRORLEVEL%) of zero (which the above will do, bar any actual problems).

The ServerManagerCMD will return a non-zero error code when it does not need to install the feature (perhaps because it was already installed from a previous Startup.cmd run), so we explicitly need to check for that code (1003) and silence it using VERIFY > NUL.