Question

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 marker 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);
Était-ce utile?

La solution

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.

Autres conseils

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

worked for me

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top