开发者

How to make TagLib# work on a file with the wrong extension?

I'm using TagLib# to retrieve meta data from my MP4 file. So far, so good, everything works fine, until I spotted a file with a "wrong" extension" that made LagLib# puke. I discovered this file was saved with a jpg extension and it made TagLib throw exception Expected SOI m开发者_如何学编程arker at the start of the file. After some googling I discovered that this has to do with reading jpeg files.

If I look at the magic number for the file it returns 00 00 00 20 66 74 79 70, which corresponds with the correct signature for mp4.

I've got the following questions:

  1. How can I read the meta data without renaming the file.
  2. How does TagLib# determine meta data?

Any ideas?

Ps. The code I used was like this:

string file = @"D:\vs2008\Inetpub\wwwroot\Test\data\AA028578_7_2.jpg";
TagLib.File tag = TagLib.File.Create(file);
Console.WriteLine(tag.MimeType);


You can specify the mime type (force it):

string file = @"D:\vs2008\Inetpub\wwwroot\Test\data\AA028578_7_2.jpg";
TagLib.File tag = TagLib.File.Create(file, "video/mp4", TagLib.ReadStyle.Average);
Console.WriteLine(tag.MimeType);

I don't know how it is loaded in TagLibSharp.


TagLib.File.Create(file, "audio/mp3", ReadStyle.None)

worked for me

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜