错误:使用NReco.VideoConverter

时间:2017-01-25 16:13:14

标签: c# ffmpeg nreco

我正在尝试使用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”(或.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

1 个答案:

答案 0 :(得分:0)

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

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