【问题标题】:How to get musicbrainz track information from audio file如何从音频文件中获取 musicbrainz 曲目信息
【发布时间】:2011-01-02 10:35:19
【问题描述】:

谁能告诉我如何使用音频指纹识别从音频文件(mp3、wav、wma、ogg 等)中获取来自MusicBrainz 数据库的曲目信息。我正在使用 MusicBrainz Sharp 库,但任何其他库都可以。

我看到你必须使用 libofa 库,你不能使用 MusicBrainz Sharp 从音频文件中获取 puid,但我不知道如何在 C# 中使用 libofa。

请展示一些示例和代码 sn-ps 来帮助我,因为我在任何地方都找不到它们。

提前致谢!

【问题讨论】:

    标签: c# audio fingerprinting audio-fingerprinting musicbrainz


    【解决方案1】:

    问题是您可能可以使用libofa 来获取音频文件的指纹,但是如果文件没有可用的PUID,您将被卡住并且必须使用genpuid 之类的东西来提交将音频指纹发送到AmpliFIND,然后等待大约一天才能获得PUID

    话虽如此,大约两年前我尝试过类似的事情,但如果我没记错的话,由于我未能编写 IDv3 标签,我对这个项目失去了兴趣。不过,源代码在on Bitbucket.

    我基本上wrapped libofa 使用DllImportwrapped genpuid(即读取输出XML)能够读取指纹并提交指纹文件,如果我没有从libofa 获得指纹。我还写了some code,它使用MusicBrainz Sharp从MusicBrainz读取信息。

    嗯,至少我当时是这么计划的,我想。 :) 我希望这可以帮助您解决您的问题,我很乐意看到这方面的更新。

    编辑:我刚刚注意到我为自己创建了一个bug report,这基本上表明我仍然需要为我的decoder 实现一个实现,这可能就是我在 SO 中创建this question 的原因.所以我想我没有实现genpuid fingerprinter 只是为了能够做指纹/获取guid,因为我没有让libofa fingerprinter 正常工作。

    【讨论】:

    • @Baki:这对您有帮助还是您需要任何进一步的建议?
    • 要写ID3标签(你真的是说ID3v3?还是id3v2?)你可以使用taglib。有一个 nuget,用起来真的很好。
    • TagLib 实际上在 2008 年并不能很好地与 .NET 配合使用(并且 NuGet 不存在;)),但我认为它的工作已经变得更好了。 :)
    【解决方案2】:

    我做了上面建议的包装的 genpuid 方法。

        private string GetPUID(string fileName)
        {
    
            Process p;
            ProcessStartInfo si;
            string outRow;
            string puidReturned;
    
            string gendPuidPath = @"C:\Program Files\genpuid\genpuid.exe";
            string gendPuidKey = "your key here";
            System.Text.RegularExpressions.Regex puidRex = new System.Text.RegularExpressions.Regex( @"puid: (\S+)" ); // sample:  puid: 3c62e009-ec93-1c0f-e078-8829e885df67
            System.Text.RegularExpressions.Match m;
    
            if (File.Exists(gendPuidPath))
            {
                try
                {
                    si = new ProcessStartInfo(gendPuidPath, gendPuidKey + " \"" + fileName + "\"");
                    si.RedirectStandardOutput = true;
                    si.UseShellExecute = false;
    
                    p = new Process();
                    p.StartInfo = si;
                    p.Start();
    
                    puidReturned = "";
                    while ((outRow = p.StandardOutput.ReadLine()) != null)
                    {
                        m = puidRex.Match(outRow);
                        if (m.Success)
                            puidReturned = m.Groups[1].Value;
                        Debug.WriteLine(outRow);
                    }
                    p.WaitForExit();
                    p.Close();
    
                    return puidReturned;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                    throw new Exception("Unexpexted Error obtaining PUID for file: " + fileName, ex);
                }
            }
            else
            {
                Debug.WriteLine("genpuid.exe not found");
                return "";
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-19
      • 2012-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多