MobileVLCKit and VLCKit, part 1

This article is a general overview and the start of a small series of articles covering the library, published at an irregular rate.

VLCKit is a generic library for any audio or video playback needs on both Apple platforms and also supports streaming and media to file conversations on the Mac. It is open-source software licensed under the LGPLv2.1 or later, available in source code and binary form from the VideoLAN website. You can also integrate MobileVLCKit easily via CocoaPods.

The foundation of this framework was laid in 2007 by Pierre d’Herbemont as part of a Google Summer of Code student project, in fact kind of mentored by me. Since then, it played major roles in developing the Lunettes prototype in 2008/2009, MobileVLC in 2010/2011 as well as take-two of VLC for iOS in 2013 until present.

When do you need VLCKit? Frankly always when you need to play media not supported by QuickTime / AVFoundation or if you require more flexibility. You want to play something else besides H264/AAC files or HLS streams? You need subtitles beyond QuickTime’s basic support for Closed Captions? Your media source is not your mobile device and not a basic HTTP server either, but perhaps a live stream hailing from some weird media server or even a raw DVB signal broadcasted on a local network? Then, VLCKit is for you.

But this is open-source software right? What does this mean for me and the end-user? And wasn’t MobileVLC removed from the App Store in 2011 for some crazy licensing reason?

First of all, open-source means for you, that you get access to the whole stack. There is no blackbox, all the sources are there at your fingertips. No reverse-engineering needed, no private APIs.

Then again, this must not be the case for your software. The LGPLv2.1 allows our software to be included in proprietary apps, as long as you follow the license. As a start, make sure to publish any potential changes you do to our software, make sure that the end-user is aware that VLCKit is embedded within your greater work and that s/he is aware of the gained rights. S/he is granted access to our code as well as to your additions to our work. For further details, please read the license and consult your lawyer with any questions you might have.

Regarding the removal of MobileVLC, the world moved on a bit. libvlc and VLCKit are no longer under the GPLv2 but were relicensed to the LGPLv2.1. While this looks like a play on characters, it is of major importance regarding distribution on the Mac or iOS App Store. As of now, the Terms of Service of either store are still incompatible with the GPLv2 (despite major changes and improvements), while distribution under the LGPLv2.1 is absolutely permitted.

Let’s get going with a technical overview and start with a layer model:

Layer model

Any layer can only communicate with the layer above and the layer below. Therefore, decoders are four abstraction layers away from the client app developer. Why is that a good thing? By having a decent amount of abstraction, it is no longer necessary for you to know which library is taking care of the decoding, rendering or parsing. You are wondering whether you need to decode your certain video in a multi-threaded or single-threaded way, think that decoding might be accelerated through the hardware in the iPhone 5S and above, but pondering what to do with older releases? libvlc will do the correct thing for you.
However, we allow flexibility. You know that you want to use a certain option on libavcodec because it’s cool (and for some reason, we decided against it?)? that’s a one-liner for you.

Okay, so how do you get going? Have a look at the SimplePlayback sample code available for download here. Ignoring the boilerplate code present in any empty iOS app project, this basic app shows you how to play a video in 8 lines of code and to allow the user to play or pause playback:

@interface RandomViewController ()
{
    VLCMediaPlayer *_mediaplayer;
}
@end
@implementation RandomViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    /* setup the media player instance, give it a delegate and
     * something to draw into */
    _mediaplayer = [[VLCMediaPlayer alloc] init];
    /* assign a random UIView or NSView to the player to
     * draw the video */
    _mediaplayer.drawable = self.movieView;
    /* create a media object and give it to the player */
    _mediaplayer.media = [VLCMedia mediaWithURL:
     [NSURL URLWithString:@“http://yourserver.com/folder/file.mkv“]];
}
- (IBAction)playandPause:(id)sender {
    if (_mediaplayer.isPlaying)
        [_mediaplayer pause];
    [_mediaplayer play];
}
@end

Give it a spin!

Then again, chances are that you are on iOS and you want to have a slightly more advanced user experience. Need a seek slider and a time display or would you like to crop the video a bit? Your media includes more than one audio or subtitles track and the user should be able to switch? The code is there for you. We wrote a self contained class and distribute it under the BSD 2-clause license. If you are interested, checkout the Dropin-Player project available here.

That’s it for the first part of this article. The second part will cover more advanced use-cases of VLCKit and will follow shortly.

If you have questions, don’t hesitate to use the comment section or to shoot a mail.

One last word regarding VLC for iOS and taking code from that project. A contrario to VLCKit or the provided sample code, it is protected by different licenses and different obligations. It is dual licensed under the GPLv2 as well as the MPLv2. Most importantly, it is absolutely not permitted to take any bits of code it unless your product is distributed under a compatible license. We have a good DMCA track record and we are monitoring both the Mac and the iOS App Stores constantly.

10 thoughts on “MobileVLCKit and VLCKit, part 1”

  1. Awesome! Thanks for writing this up, eagerly awaiting the next article! I’m using MobileVlcKit in one of the apps I’m developing! It’s awesome! 😉

  2. Any chance that (1) simultaneous viewing/recording of a video stream and (2) transcoding can all be enabled or made to work on iOS? Currently working to see how to accomplish this. Thx for the awesomeness.

  3. I am using MobileVLCKit through cocoaPods.
    It is giving me errors like this at the build time

    Undefined symbols for architecture arm64:
    “std::runtime_error::runtime_error(std::string const&)”, referenced from:
    libebml::CRTError::CRTError(std::string const&, int) in MobileVLCKit(StdIOCallback.o)

      1. My code is looking like this
        _mediaplayer = [[VLCMediaPlayer alloc] init];
        _mediaplayer.delegate = self;
        audioPlayer.delegate = self;
        _mediaplayer.drawable = self.movieView;
        _mediaplayer.media = [VLCMedia mediaWithURL:[NSURL URLWithString:@”rtsp://…….”]];
        [_mediaplayer play];

Comments are closed.