0

我正在尝试使用 NReco.VideoConverter 将 .flac 文件转换为 .wav 文件,但我不断收到错误消息,我不知道为什么。这是我用于转换的一段代码:

        //Create the NReco.VideoConverter.FFMpegConverter object
        var ffmpeg = new FFMpegConverter();

        //inputFile will be something like this:
        //type: string, "C:\\some\\folder\\fullTrackName" + ".flac"
        var inputFile = Path.Combine(downloadFolder + fullTrackNameNoExtension + ".flac");

        //outputFile will be something like this:
        //type: string, "C:\\some\\folder\\musicfile" + ".wav"
        var outputFile = Path.Combine(downloadFolder + fullTrackNameNoExtension + ".wav");

        //Convert the file using NReco.VideoConverter.FFMpegConverter
        ffmpeg.ConvertMedia(inputFile, outputFile, null);

inputFile/outputFile 是这样的,这是我在插入断点并检查 in/outputFile 的值时看到的:

string, inputFile/outputFile: "Z:\\Downloads\\Audio - File (Original Mix).flac" (or .wav)

这是我在运行 ffmpeg.ConvertMedia 时收到的错误:

System.ArgumentException: The path is not of a legal form.
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.GetFullPathInternal(String path)
   at System.IO.File.InternalGetLastWriteTimeUtc(String path, Boolean checkHost)
   at NReco.VideoConverter.FFMpegConverter.EnsureFFMpegLibs()
   at NReco.VideoConverter.FFMpegConverter.ConvertMedia(Media input, Media output, ConvertSettings settings)
   at NReco.VideoConverter.FFMpegConverter.ConvertMedia(String inputFile, String inputFormat, String outputFile, String outputFormat, ConvertSettings settings)
   at NReco.VideoConverter.FFMpegConverter.ConvertMedia(String inputFile, String outputFile, String outputFormat)
   at APPLICATION_Name.APPLICATION_Class.ConvertFile(String downloadFolder, String fullTrackName, String fullTrackNameNoExtension, String downloadQuality, String downloadType) in X:\APPLICATION_Name\DownloadTrack.cs:line 244
4

1 回答 1

0

从“FFMpegConverter.EnsureFFMpegLibs”方法抛出异常,该方法在首次使用时提取 ffmpeg 二进制文件(默认为 app bin 文件夹),我可能认为由于某种原因它被错误地确定(或者可能使用了网络路径)。

您可以尝试通过指定 FFMpegConverter.FFMpegToolPath 属性来更改 ffmpeg.exe 的位置(.net 应用程序应该有足够的权限来写入此文件夹)。

于 2017-01-26T14:20:06.917 回答