This is part of an article series covering VLC’s Objective-C framework, which we provide to allow inclusion of all its features in third party applications as well as VLC for iOS and Apple TV.
Today, we will discuss meta data processing.
In VLCKit, every item you play is a VLCMedia object. For typical use cases, it can be created with an NSURL or an NSString containing a path.
We differentiate between two types of meta data: technical information describing the media such as codec, bitrate, video size and user-visible/-provided information such as artist, publisher name, album title.
Let’s start with the technical information, which can be retrieved from any media object with a single API call:
@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *tracksInformation;
This gives you an array containing as many dictionaries as the media contains tracks, be it video, audio or subpictures (subtitles, teletext). The track type is defined by the VLCMediaTracksInformationType key. All tracks will include information about the respective codec, bitrate and encoding details. Depending on track type, keys for video dimensions, audio channel numbers or text encoding will be set as well as an optional key for language.
Retrieving this property can potentially be very expensive, especially if your media is stored remotely as VLCKit will synchronously parse the source to provide this information. Therefore, we recommend you to cache this data, as it will probably not change during the lifetime of the VLCMedia object.
Note: for codec information, you’ll receive an integer which is a raw FOURCC representation of the codec name. Releases following VLCKit 2.2 will include a convenience method to translate it to an end-user readable string.
On mobile devices, you might run into the question if a given device is powerful enough to decode a given video file. For this purpose, VLCMedia includes the isMediaSizeSuitableForDevice property which will provide a reasonable guess. Note that this property will always be true on OS X.
Now, what about non-technical information about the media contents? To retrieve them, VLCKit needs to parse the source. This can be done both synchronous and asynchronous depending on the needs of your application. We generally recommend you to use the asynchronous way so you don’t block the execution of any threads. VLCMedia includes an optional delegate protocol, which allows you to follow meta data processing by receiving notifications every time further information becomes available as well as once parsing finished.
VLCKit can provide up to 17 different meta data keys with more to come in subsequent releases. While it allows to fetch them one by one, we recommend you to fetch the full dictionary using:
@property (nonatomic, readonly, copy) NSDictionary * metaDictionary;
If you have write access to your media source, you can also set values for the respective keys and save them to disk.
Thanks for reading!
If you have questions, don’t hesitate to use the comment section or to shoot a mail. The next part of this series will be about thumbnail creation.