问候,
我正在尝试找到一个免费的.NET库或命令行可执行文件,它允许我将M4A文件转换为MP3或WMA文件。请帮忙:)。
答案 0 :(得分:4)
发现它!
http://pieter.wigleven.com/it/archives/3
可能还有其他解决方案,但这是我正在寻找的黄金。
P.S。我写了a .NET DLL来处理这个幕后故事。这是非常可怕的代码,但它完成了工作。
答案 1 :(得分:1)
如果您知道正确的工具,这很简单:
ffmpeg -i infile.m4a tmp.wav
lame tmp.wav outfile.mp3
这是一个批量版本(对不起Linux / Mac):
#!/bin/bash
n=0
maxjobs=3
for i in *.m4a ; do
ffmpeg -i "$i" "$TMP/${i%m4a}wav"
(lame "$TMP/${i%m4a}wav" "${i%m4a}mp3" ; rm "$TMP/${i%m4a}wav") &
# limit jobs
if (( $(($((++n)) % $maxjobs)) == 0 )) ; then
wait
fi
done
答案 2 :(得分:0)
有趣。
您提供的链接指向命令行实用程序
如果您真的想以编程方式执行此操作,您可能会对我在Rarewares找到的DLL版本感兴趣。不确定API说明是否附带......: - )
答案 3 :(得分:0)
来自How to convert media file to WMA file
string fileName = @"e:\Down\test.wmv";
DsConvert.ToWma(fileName, fileName + ".wma", DsConvert.WmaProfile.Stereo128);
答案 4 :(得分:0)
对于UWP
public class ConvertToMp3Manager
{
public PrepareTranscodeResult PrepareTranscode = null;
public MediaTranscoder TransCoder = null;
public StorageFile SourceAudio { get; set; }
public StorageFile DestinationAudio { get; set; }
public AudioFormat AudioFormat { get; set; }
public AudioEncodingQuality AudioQuality { get; set; }
private MediaEncodingProfile profile = null;
public ConvertToMp3Manager(StorageFile sourceAudio, StorageFile destinationAudio, AudioFormat AudioType = AudioFormat.MP3, AudioEncodingQuality audioEncodingQuality = AudioEncodingQuality.High)
{
if (sourceAudio == null || destinationAudio == null)
throw new ArgumentNullException("sourceAudio and destinationAudio cannot be null");
switch (AudioType)
{
case AudioFormat.AAC:
case AudioFormat.M4A:
profile = MediaEncodingProfile.CreateM4a(audioEncodingQuality);
break;
case AudioFormat.MP3:
profile = MediaEncodingProfile.CreateMp3(audioEncodingQuality);
break;
case AudioFormat.WMA:
profile = MediaEncodingProfile.CreateWma(audioEncodingQuality);
break;
}
this.SourceAudio = sourceAudio;
this.DestinationAudio = destinationAudio;
this.AudioFormat = AudioType;
this.AudioQuality = audioEncodingQuality;
this.TransCoder = new MediaTranscoder();
}
/// <summary>
/// Return true if audio can be transcoded
/// </summary>
/// <returns></returns>
public async Task<bool> ConvertAudioAsync()
{
PrepareTranscode = await this.TransCoder.PrepareFileTranscodeAsync(this.SourceAudio, this.DestinationAudio, profile);
if (PrepareTranscode.CanTranscode)
{
var transcodeOp = PrepareTranscode.TranscodeAsync();
return true;
}
else
return false;
}
public static async Task<bool> ConvertAudioAsync(StorageFile sourceAudio, StorageFile destinationAudio, AudioFormat AudioType = AudioFormat.MP3, AudioEncodingQuality audioEncodingQuality = AudioEncodingQuality.High)
{
ConvertToMp3Manager convertToMp3Manager = new ConvertToMp3Manager(sourceAudio, destinationAudio, AudioType, audioEncodingQuality);
var success = await convertToMp3Manager.ConvertAudioAsync();
return success;
}
}
public enum AudioFormat
{
MP3,
AAC,
M4A,
WMA
}