Differences in length in TagLib # (C #) and TagLib (C ++)

I am currently moving my C # application to Qt / C ++. I have problems with TagLib tags. It seemed strange to me that TagLib # returns the duration of sound in milliseconds, and TagLib returns its (incorrect) durations in seconds. TagLib simply returns zero for length values, and TagLib # remains true.

Here is my source in C # / TagLib # ...

TagLib.File tagfile = TagLib.File.Create(path);
uint milliseconds = (uint)tagfile.Properties.Duration.TotalMilliseconds;

And here is what should be almost equivalent in C ++ / TagLib. I even made him read for sure. No success.

TagLib::FileName fn(path);
TagLib::FileRef fr(fn, true, TagLib::AudioProperties::Accurate);
uint length = fr.audioProperties()->length();

It works as expected for most of my media files. However, the selected multiple audio files cannot return any sound properties (the rest of the tag information is read perfectly!). The same sound properties are returned without problems in TagLib #.

Any ideas are welcome. Thank.

Anyone have any ideas before the grandeur ends?

+3
source share
3 answers

Hi, there is a patch for taglib that calculates the length in milliseconds, this guy added a method (lengthMilliseconds ()) that returns the length in milliseconds, maybe this may be useful for you: http://web.archiveorange.com/archive / v / sF3Pjr01lSQjsqjrAC7L

+5
source

A lot has changed in the TagLib # method since it was originally ported, so it’s hard to say exactly where the difference will occur. You can test your C ++ program for debugging messages.

, , . , , TagLib . TagLib #, , 16KiB . , , , . , ID3v2 0xFF FF FF FF, . .

166 taglib/mpeg/mpegproperties.cpp. , , 171 191, , , MP3.

+3

, TagLib 1.11 BETA 2 . :

TagLib::FileRef f(path);
int lengthInMillis = f.audioProperties()->lengthInMilliseconds();
+1

Source: https://habr.com/ru/post/1777383/


All Articles