0

As the title says, can I read/write windows explorer compatible file rating data to and from mp4 video files?

It seems that windows explorer adds (a tag?) named "WM/SharedUserRating" with the corresponding data. This tag seems to be part of the ASF file format/tag format.

But I am unable to open an MP4 file as ASF (object guid exception) and the MP4 tag data extracted by taglib doesn't show the rating...?

Michael
  • 1,931
  • 2
  • 8
  • 22
  • Are you talking about the star rating, like up to 5 stars? – Trevor Dec 17 '20 at 20:12
  • Does this answer your question? [C# Reading Video Metadata in Windows (Title,description,year)](https://stackoverflow.com/questions/26695297/c-sharp-reading-video-metadata-in-windows-title-description-year) – NetMage Dec 17 '20 at 21:20
  • For alternative, you can use exiftool.https://exiftool.org/forum/ – MonkeyDLuffy Dec 17 '20 at 21:28
  • Note that ASF and MP4 are not interchangeable file formats. – NetMage Dec 17 '20 at 23:32
  • @Codexer yes, the rating is displayed in windows explorer with up to five stars – Michael Dec 18 '20 at 09:29
  • @NetMage no, that doesnt answer my question. they suggest using taglib, which i am using. They read basic tag data which seems to be part of the mp4 tagging structure like title and description. That rating value seems not to be part of the mp4 "standard"... – Michael Dec 18 '20 at 09:32

1 Answers1

1

If you are on Windows 10, you can use the Windows RT API. Add the Nuget package Microsoft.Windows.SDK.Contracts to your application and then you can access the rating using StorageFile:

using Windows.Storage;
using Windows.Storage.FileProperties;

var f = await StorageFile.GetFileFromPathAsync(@"D:\ProjectsNoBackup\VideoStuff\12-Lead Ecg H.264 480P30.mp4");
var v = await f.Properties.GetVideoPropertiesAsync();

Then v.Rating is a UInt32 value where 0=0, 1=1, 2=25, 3=50, 4=75 and 5=99 (per @Michael).

NetMage
  • 26,163
  • 3
  • 34
  • 55
  • Is this based on the WindowsAPICodePack? I am using the WindowsAPICodePack and its horrible slow for MP4 files... But I'll have a look at it, thanks :) – Michael Dec 18 '20 at 09:35
  • That works :) One correction, the rating is 0=0, 1=1, 2=25, 3=50, 4=75 and 5=99. Can be adjusted easily for images.Adding rating-data to large MP4 is "slow", but I think thats caused by MP4 file structure and the location where the meta data is stored. Leading metadata: slow due to rewriting entire file, leading metadata with padding or existing rating: faster, inserting/overwriting data and trailing metadata: faster, appending data. Haven't verified those... – Michael Dec 18 '20 at 10:15
  • @Michael Sorry about the values - I guess based on 75 :), I'll update my answer. Yeah, I think the MP4/Quicktime Container Format is not exactly designed for fast updating of metadata (though if there was a NOP atom class, you could just write a NOP atom overtop of the existing metadata block and write a new atom at the end). – NetMage Dec 18 '20 at 20:25