<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.videolan.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Yamanu</id>
	<title>VideoLAN Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.videolan.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Yamanu"/>
	<link rel="alternate" type="text/html" href="https://wiki.videolan.org/Special:Contributions/Yamanu/"/>
	<updated>2026-11-04T19:40:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=LibVLC_SampleCode_SDL&amp;diff=22861</id>
		<title>LibVLC SampleCode SDL</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=LibVLC_SampleCode_SDL&amp;diff=22861"/>
		<updated>2012-07-30T06:31:59Z</updated>

		<summary type="html">&lt;p&gt;Yamanu: /* Rendering into a custom surface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Rendering into a custom surface==&lt;br /&gt;
This sample code will render a video into an SDL surface.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;It requires [[LibVLC]] 1.1.1 or later.&#039;&#039;&#039;&lt;br /&gt;
Below is a version with [[#SDL_2.0|SDL 2.0]] and one with [[#Older_API|older LibVLC API]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* libSDL and libVLC sample code&lt;br /&gt;
 * Copyright © 2008 Sam Hocevar &amp;lt;sam@zoy.org&amp;gt;&lt;br /&gt;
 * license: [http://en.wikipedia.org/wiki/WTFPL WTFPL] */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;assert.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SDL/SDL.h&amp;gt;&lt;br /&gt;
#include &amp;lt;SDL/SDL_mutex.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define WIDTH 640&lt;br /&gt;
#define HEIGHT 480&lt;br /&gt;
&lt;br /&gt;
#define VIDEOWIDTH 320&lt;br /&gt;
#define VIDEOHEIGHT 240&lt;br /&gt;
&lt;br /&gt;
struct ctx&lt;br /&gt;
{&lt;br /&gt;
    SDL_Surface *surf;&lt;br /&gt;
    SDL_mutex *mutex;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
static void *lock(void *data, void **p_pixels)&lt;br /&gt;
{&lt;br /&gt;
    struct ctx *ctx = data;&lt;br /&gt;
&lt;br /&gt;
    SDL_LockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    *p_pixels = ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
    return NULL; /* picture identifier, not needed here */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void unlock(void *data, void *id, void *const *p_pixels)&lt;br /&gt;
{&lt;br /&gt;
    struct ctx *ctx = data;&lt;br /&gt;
&lt;br /&gt;
    /* VLC just rendered the video, but we can also render stuff */&lt;br /&gt;
    uint16_t *pixels = *p_pixels;&lt;br /&gt;
    int x, y;&lt;br /&gt;
&lt;br /&gt;
    for(y = 10; y &amp;lt; 40; y++)&lt;br /&gt;
        for(x = 10; x &amp;lt; 40; x++)&lt;br /&gt;
            if(x &amp;lt; 13 || y &amp;lt; 13 || x &amp;gt; 36 || y &amp;gt; 36)&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0xffff;&lt;br /&gt;
            else&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0x0;&lt;br /&gt;
&lt;br /&gt;
    SDL_UnlockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    SDL_UnlockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
&lt;br /&gt;
    assert(id == NULL); /* picture identifier, not needed here */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void display(void *data, void *id)&lt;br /&gt;
{&lt;br /&gt;
    /* VLC wants to display the video */&lt;br /&gt;
    (void) data;&lt;br /&gt;
    assert(id == NULL);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
    libvlc_instance_t *libvlc;&lt;br /&gt;
    libvlc_media_t *m;&lt;br /&gt;
    libvlc_media_player_t *mp;&lt;br /&gt;
    char const *vlc_argv[] =&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;--no-audio&amp;quot;, /* skip any audio track */&lt;br /&gt;
        &amp;quot;--no-xlib&amp;quot;, /* tell VLC to not use Xlib */&lt;br /&gt;
    };&lt;br /&gt;
    int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);&lt;br /&gt;
&lt;br /&gt;
    SDL_Surface *screen, *empty;&lt;br /&gt;
    SDL_Event event;&lt;br /&gt;
    SDL_Rect rect;&lt;br /&gt;
    int done = 0, action = 0, pause = 0, n = 0;&lt;br /&gt;
&lt;br /&gt;
    struct ctx ctx;&lt;br /&gt;
&lt;br /&gt;
    if(argc &amp;lt; 2)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;Usage: %s &amp;lt;filename&amp;gt;\n&amp;quot;, argv[0]);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libSDL&lt;br /&gt;
     */&lt;br /&gt;
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) == -1)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot initialize SDL\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    empty = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                 32, 0, 0, 0, 0);&lt;br /&gt;
    ctx.surf = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                    16, 0x001f, 0x07e0, 0xf800, 0);&lt;br /&gt;
&lt;br /&gt;
    ctx.mutex = SDL_CreateMutex();&lt;br /&gt;
&lt;br /&gt;
    int options = SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF;&lt;br /&gt;
&lt;br /&gt;
    screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
    if(!screen)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot set video mode\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libVLC&lt;br /&gt;
     */&lt;br /&gt;
    libvlc = libvlc_new(vlc_argc, vlc_argv);&lt;br /&gt;
    m = libvlc_media_new_path(libvlc, argv[1]);&lt;br /&gt;
    mp = libvlc_media_player_new_from_media(m);&lt;br /&gt;
    libvlc_media_release(m);&lt;br /&gt;
&lt;br /&gt;
    libvlc_video_set_callbacks(mp, lock, unlock, display, &amp;amp;ctx);&lt;br /&gt;
    libvlc_video_set_format(mp, &amp;quot;RV16&amp;quot;, VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH*2);&lt;br /&gt;
    libvlc_media_player_play(mp);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Main loop&lt;br /&gt;
     */&lt;br /&gt;
    rect.w = 0;&lt;br /&gt;
    rect.h = 0;&lt;br /&gt;
&lt;br /&gt;
    while(!done)&lt;br /&gt;
    { &lt;br /&gt;
        action = 0;&lt;br /&gt;
&lt;br /&gt;
        /* Keys: enter (fullscreen), space (pause), escape (quit) */&lt;br /&gt;
        while( SDL_PollEvent( &amp;amp;event ) ) &lt;br /&gt;
        { &lt;br /&gt;
            switch(event.type)&lt;br /&gt;
            {&lt;br /&gt;
            case SDL_QUIT:&lt;br /&gt;
                done = 1;&lt;br /&gt;
                break;&lt;br /&gt;
            case SDL_KEYDOWN:&lt;br /&gt;
                action = event.key.keysym.sym;&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        switch(action)&lt;br /&gt;
        {&lt;br /&gt;
        case SDLK_ESCAPE:&lt;br /&gt;
            done = 1;&lt;br /&gt;
            break;&lt;br /&gt;
        case SDLK_RETURN:&lt;br /&gt;
            options ^= SDL_FULLSCREEN;&lt;br /&gt;
            screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
            break;&lt;br /&gt;
        case &#039; &#039;:&lt;br /&gt;
            pause = !pause;&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rect.x = (int)((1. + .5 * sin(0.03 * n)) * (WIDTH - VIDEOWIDTH) / 2);&lt;br /&gt;
        rect.y = (int)((1. + .5 * cos(0.03 * n)) * (HEIGHT - VIDEOHEIGHT) / 2);&lt;br /&gt;
&lt;br /&gt;
        if(!pause)&lt;br /&gt;
            n++;&lt;br /&gt;
&lt;br /&gt;
        /* Blitting the surface does not prevent it from being locked and&lt;br /&gt;
         * written to by another thread, so we use this additional mutex. */&lt;br /&gt;
        SDL_LockMutex(ctx.mutex);&lt;br /&gt;
        SDL_BlitSurface(ctx.surf, NULL, screen, &amp;amp;rect);&lt;br /&gt;
        SDL_UnlockMutex(ctx.mutex);&lt;br /&gt;
&lt;br /&gt;
        SDL_Flip(screen);&lt;br /&gt;
        SDL_Delay(10);&lt;br /&gt;
&lt;br /&gt;
        SDL_BlitSurface(empty, NULL, screen, &amp;amp;rect);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Stop stream and clean up libVLC&lt;br /&gt;
     */&lt;br /&gt;
    libvlc_media_player_stop(mp);&lt;br /&gt;
    libvlc_media_player_release(mp);&lt;br /&gt;
    libvlc_release(libvlc);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Close window and clean up libSDL&lt;br /&gt;
     */&lt;br /&gt;
    SDL_DestroyMutex(ctx.mutex);&lt;br /&gt;
    SDL_FreeSurface(ctx.surf);&lt;br /&gt;
    SDL_FreeSurface(empty);&lt;br /&gt;
&lt;br /&gt;
    SDL_Quit();&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===SDL 2.0===&lt;br /&gt;
&lt;br /&gt;
This version works with [[LibVLC]] 1.1.1 or later and SDL 2.0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// libSDL and libVLC sample code.&lt;br /&gt;
// License: [http://en.wikipedia.org/wiki/WTFPL WTFPL]&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;assert.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;SDL/SDL.h&amp;quot;&lt;br /&gt;
#include &amp;quot;SDL/SDL_mutex.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;vlc/vlc.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#define WIDTH 640&lt;br /&gt;
#define HEIGHT 480&lt;br /&gt;
&lt;br /&gt;
#define VIDEOWIDTH 320&lt;br /&gt;
#define VIDEOHEIGHT 240&lt;br /&gt;
&lt;br /&gt;
struct context {&lt;br /&gt;
    SDL_Renderer *renderer;&lt;br /&gt;
    SDL_Texture *texture;&lt;br /&gt;
    SDL_mutex *mutex;&lt;br /&gt;
    int n;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
// VLC prepares to render a video frame.&lt;br /&gt;
static void *lock(void *data, void **p_pixels) {&lt;br /&gt;
&lt;br /&gt;
    struct context *c = (context *)data;&lt;br /&gt;
&lt;br /&gt;
    int pitch;&lt;br /&gt;
    SDL_LockMutex(c-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockTexture(c-&amp;gt;texture, NULL, p_pixels, &amp;amp;pitch);&lt;br /&gt;
&lt;br /&gt;
    return NULL; // Picture identifier, not needed here.&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// VLC just rendered a video frame.&lt;br /&gt;
static void unlock(void *data, void *id, void *const *p_pixels) {&lt;br /&gt;
&lt;br /&gt;
    struct context *c = (context *)data;&lt;br /&gt;
&lt;br /&gt;
    uint16_t *pixels = (uint16_t *)*p_pixels;&lt;br /&gt;
&lt;br /&gt;
    // We can also render stuff.&lt;br /&gt;
    int x, y;&lt;br /&gt;
    for(y = 10; y &amp;lt; 40; y++) {&lt;br /&gt;
        for(x = 10; x &amp;lt; 40; x++) {&lt;br /&gt;
            if(x &amp;lt; 13 || y &amp;lt; 13 || x &amp;gt; 36 || y &amp;gt; 36) {&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0xffff;&lt;br /&gt;
            } else {&lt;br /&gt;
                // RV16 = 5+6+5 pixels per color, BGR.&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0x02ff;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    SDL_UnlockTexture(c-&amp;gt;texture);&lt;br /&gt;
    SDL_UnlockMutex(c-&amp;gt;mutex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// VLC wants to display a video frame.&lt;br /&gt;
static void display(void *data, void *id) {&lt;br /&gt;
&lt;br /&gt;
    struct context *c = (context *)data;&lt;br /&gt;
&lt;br /&gt;
    SDL_Rect rect;&lt;br /&gt;
    rect.w = VIDEOWIDTH;&lt;br /&gt;
    rect.h = VIDEOHEIGHT;&lt;br /&gt;
    rect.x = (int)((1. + .5 * sin(0.03 * c-&amp;gt;n)) * (WIDTH - VIDEOWIDTH) / 2);&lt;br /&gt;
    rect.y = (int)((1. + .5 * cos(0.03 * c-&amp;gt;n)) * (HEIGHT - VIDEOHEIGHT) / 2);&lt;br /&gt;
&lt;br /&gt;
    SDL_SetRenderDrawColor(c-&amp;gt;renderer, 0, 80, 0, 255);&lt;br /&gt;
    SDL_RenderClear(c-&amp;gt;renderer);&lt;br /&gt;
    SDL_RenderCopy(c-&amp;gt;renderer, c-&amp;gt;texture, NULL, &amp;amp;rect);&lt;br /&gt;
    SDL_RenderPresent(c-&amp;gt;renderer);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void quit(int c) {&lt;br /&gt;
    SDL_Quit();&lt;br /&gt;
    exit(c);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[]) {&lt;br /&gt;
&lt;br /&gt;
    libvlc_instance_t *libvlc;&lt;br /&gt;
    libvlc_media_t *m;&lt;br /&gt;
    libvlc_media_player_t *mp;&lt;br /&gt;
    char const *vlc_argv[] = {&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;--no-audio&amp;quot;, // Don&#039;t play audio.&lt;br /&gt;
        &amp;quot;--no-xlib&amp;quot;, // Don&#039;t use Xlib.&lt;br /&gt;
&lt;br /&gt;
        // Apply a video filter.&lt;br /&gt;
        //&amp;quot;--video-filter&amp;quot;, &amp;quot;sepia&amp;quot;,&lt;br /&gt;
        //&amp;quot;--sepia-intensity=200&amp;quot;&lt;br /&gt;
    };&lt;br /&gt;
    int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);&lt;br /&gt;
&lt;br /&gt;
    SDL_Event event;&lt;br /&gt;
    int done = 0, action = 0, pause = 0, n = 0;&lt;br /&gt;
&lt;br /&gt;
    struct context context;&lt;br /&gt;
&lt;br /&gt;
    if(argc &amp;lt; 2) {&lt;br /&gt;
        printf(&amp;quot;Usage: %s &amp;lt;filename&amp;gt;\n&amp;quot;, argv[0]);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Initialise libSDL.&lt;br /&gt;
    if(SDL_Init(SDL_INIT_VIDEO) &amp;lt; 0) {&lt;br /&gt;
        printf(&amp;quot;Could not initialize SDL: %s.\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Create SDL graphics objects.&lt;br /&gt;
    SDL_Window * window = SDL_CreateWindow(&lt;br /&gt;
            &amp;quot;Fartplayer&amp;quot;,&lt;br /&gt;
            SDL_WINDOWPOS_UNDEFINED,&lt;br /&gt;
            SDL_WINDOWPOS_UNDEFINED,&lt;br /&gt;
            WIDTH, HEIGHT,&lt;br /&gt;
            SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE);&lt;br /&gt;
    if (!window) {&lt;br /&gt;
        fprintf(stderr, &amp;quot;Couldn&#039;t create window: %s\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        quit(3);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    context.renderer = SDL_CreateRenderer(window, -1, 0);&lt;br /&gt;
    if (!context.renderer) {&lt;br /&gt;
        fprintf(stderr, &amp;quot;Couldn&#039;t create renderer: %s\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        quit(4);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    context.texture = SDL_CreateTexture(&lt;br /&gt;
            context.renderer,&lt;br /&gt;
            SDL_PIXELFORMAT_BGR565, SDL_TEXTUREACCESS_STREAMING,&lt;br /&gt;
            VIDEOWIDTH, VIDEOHEIGHT);&lt;br /&gt;
    if (!context.texture) {&lt;br /&gt;
        fprintf(stderr, &amp;quot;Couldn&#039;t create texture: %s\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        quit(5);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    context.mutex = SDL_CreateMutex();&lt;br /&gt;
&lt;br /&gt;
    // If you don&#039;t have this variable set you must have plugins directory&lt;br /&gt;
    // with the executable or libvlc_new() will not work!&lt;br /&gt;
    printf(&amp;quot;VLC_PLUGIN_PATH=%s\n&amp;quot;, getenv(&amp;quot;VLC_PLUGIN_PATH&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
    // Initialise libVLC.&lt;br /&gt;
    libvlc = libvlc_new(vlc_argc, vlc_argv);&lt;br /&gt;
    if(NULL == libvlc) {&lt;br /&gt;
        printf(&amp;quot;LibVLC initialization failure.\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    m = libvlc_media_new_path(libvlc, argv[1]);&lt;br /&gt;
    mp = libvlc_media_player_new_from_media(m);&lt;br /&gt;
    libvlc_media_release(m);&lt;br /&gt;
&lt;br /&gt;
    libvlc_video_set_callbacks(mp, lock, unlock, display, &amp;amp;context);&lt;br /&gt;
    libvlc_video_set_format(mp, &amp;quot;RV16&amp;quot;, VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH*2);&lt;br /&gt;
    libvlc_media_player_play(mp);&lt;br /&gt;
&lt;br /&gt;
    // Main loop.&lt;br /&gt;
    while(!done) {&lt;br /&gt;
&lt;br /&gt;
        action = 0;&lt;br /&gt;
&lt;br /&gt;
        // Keys: enter (fullscreen), space (pause), escape (quit).&lt;br /&gt;
        while( SDL_PollEvent( &amp;amp;event )) {&lt;br /&gt;
&lt;br /&gt;
            switch(event.type) {&lt;br /&gt;
                case SDL_QUIT:&lt;br /&gt;
                    done = 1;&lt;br /&gt;
                    break;&lt;br /&gt;
                case SDL_KEYDOWN:&lt;br /&gt;
                    action = event.key.keysym.sym;&lt;br /&gt;
                    break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        switch(action) {&lt;br /&gt;
            case SDLK_ESCAPE:&lt;br /&gt;
            case SDLK_q:&lt;br /&gt;
                done = 1;&lt;br /&gt;
                break;&lt;br /&gt;
            case &#039; &#039;:&lt;br /&gt;
                printf(&amp;quot;Pause toggle.\n&amp;quot;);&lt;br /&gt;
                pause = !pause;&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        if(!pause) { context.n++; }&lt;br /&gt;
&lt;br /&gt;
        SDL_Delay(1000/10);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Stop stream and clean up libVLC.&lt;br /&gt;
    libvlc_media_player_stop(mp);&lt;br /&gt;
    libvlc_media_player_release(mp);&lt;br /&gt;
    libvlc_release(libvlc);&lt;br /&gt;
&lt;br /&gt;
    // Close window and clean up libSDL.&lt;br /&gt;
    SDL_DestroyMutex(context.mutex);&lt;br /&gt;
    SDL_DestroyRenderer(context.renderer);&lt;br /&gt;
&lt;br /&gt;
    quit(0);&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Older API===&lt;br /&gt;
&lt;br /&gt;
This code was used for LibVLC 0.9.x and 1.0.x.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* libSDL and libVLC sample code&lt;br /&gt;
 * Copyright © 2008 Sam Hocevar &amp;lt;sam@zoy.org&amp;gt;&lt;br /&gt;
 * license: [http://en.wikipedia.org/wiki/WTFPL WTFPL] */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SDL.h&amp;gt;&lt;br /&gt;
#include &amp;lt;SDL_mutex.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define WIDTH 640&lt;br /&gt;
#define HEIGHT 480&lt;br /&gt;
&lt;br /&gt;
#define VIDEOWIDTH 320&lt;br /&gt;
#define VIDEOHEIGHT 240&lt;br /&gt;
&lt;br /&gt;
struct ctx&lt;br /&gt;
{&lt;br /&gt;
    SDL_Surface *surf;&lt;br /&gt;
    SDL_mutex *mutex;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
static void catch (libvlc_exception_t *ex)&lt;br /&gt;
{&lt;br /&gt;
    if(libvlc_exception_raised(ex))&lt;br /&gt;
    {&lt;br /&gt;
        fprintf(stderr, &amp;quot;exception: %s\n&amp;quot;, libvlc_exception_get_message(ex));&lt;br /&gt;
        exit(1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    libvlc_exception_clear(ex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#ifdef VLC09X&lt;br /&gt;
static void * lock(struct ctx *ctx)&lt;br /&gt;
{&lt;br /&gt;
    SDL_LockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    return ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
}&lt;br /&gt;
#else&lt;br /&gt;
static void lock(struct ctx *ctx, void **pp_ret)&lt;br /&gt;
{&lt;br /&gt;
    SDL_LockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    *pp_ret = ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
static void unlock(struct ctx *ctx)&lt;br /&gt;
{&lt;br /&gt;
    /* VLC just rendered the video, but we can also render stuff */&lt;br /&gt;
    uint16_t *pixels = (uint16_t *)ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
    int x, y;&lt;br /&gt;
&lt;br /&gt;
    for(y = 10; y &amp;lt; 40; y++)&lt;br /&gt;
        for(x = 10; x &amp;lt; 40; x++)&lt;br /&gt;
            if(x &amp;lt; 13 || y &amp;lt; 13 || x &amp;gt; 36 || y &amp;gt; 36)&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0xffff;&lt;br /&gt;
            else&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0x0;&lt;br /&gt;
&lt;br /&gt;
    SDL_UnlockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    SDL_UnlockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
    char clock[64], cunlock[64], cdata[64];&lt;br /&gt;
    char width[32], height[32], pitch[32];&lt;br /&gt;
    libvlc_exception_t ex;&lt;br /&gt;
    libvlc_instance_t *libvlc;&lt;br /&gt;
    libvlc_media_t *m;&lt;br /&gt;
    libvlc_media_player_t *mp;&lt;br /&gt;
    char const *vlc_argv[] =&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;-q&amp;quot;,&lt;br /&gt;
        //&amp;quot;-vvvvv&amp;quot;,&lt;br /&gt;
        &amp;quot;--plugin-path&amp;quot;, VLC_TREE &amp;quot;/modules&amp;quot;,&lt;br /&gt;
        &amp;quot;--ignore-config&amp;quot;, /* Don&#039;t use VLC&#039;s config files */&lt;br /&gt;
        &amp;quot;--noaudio&amp;quot;,&lt;br /&gt;
        &amp;quot;--vout&amp;quot;, &amp;quot;vmem&amp;quot;,&lt;br /&gt;
        &amp;quot;--vmem-width&amp;quot;, width,&lt;br /&gt;
        &amp;quot;--vmem-height&amp;quot;, height,&lt;br /&gt;
        &amp;quot;--vmem-pitch&amp;quot;, pitch,&lt;br /&gt;
        &amp;quot;--vmem-chroma&amp;quot;, &amp;quot;RV16&amp;quot;,&lt;br /&gt;
        &amp;quot;--vmem-lock&amp;quot;, clock,&lt;br /&gt;
        &amp;quot;--vmem-unlock&amp;quot;, cunlock,&lt;br /&gt;
        &amp;quot;--vmem-data&amp;quot;, cdata,&lt;br /&gt;
    };&lt;br /&gt;
    int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);&lt;br /&gt;
&lt;br /&gt;
    SDL_Surface *screen, *empty;&lt;br /&gt;
    SDL_Event event;&lt;br /&gt;
    SDL_Rect rect;&lt;br /&gt;
    int done = 0, action = 0, pause = 0, n = 0;&lt;br /&gt;
&lt;br /&gt;
    struct ctx ctx;&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libSDL&lt;br /&gt;
     */&lt;br /&gt;
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) == -1)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot initialize SDL\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    empty = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                 32, 0, 0, 0, 0);&lt;br /&gt;
    ctx.surf = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                    16, 0x001f, 0x07e0, 0xf800, 0);&lt;br /&gt;
&lt;br /&gt;
    ctx.mutex = SDL_CreateMutex();&lt;br /&gt;
&lt;br /&gt;
    int options = SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF;&lt;br /&gt;
&lt;br /&gt;
    screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
    if(!screen)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot set video mode\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libVLC&lt;br /&gt;
     */&lt;br /&gt;
    sprintf(clock, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)lock);&lt;br /&gt;
    sprintf(cunlock, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)unlock);&lt;br /&gt;
    sprintf(cdata, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)&amp;amp;ctx);&lt;br /&gt;
    sprintf(width, &amp;quot;%i&amp;quot;, VIDEOWIDTH);&lt;br /&gt;
    sprintf(height, &amp;quot;%i&amp;quot;, VIDEOHEIGHT);&lt;br /&gt;
    sprintf(pitch, &amp;quot;%i&amp;quot;, VIDEOWIDTH * 2);&lt;br /&gt;
&lt;br /&gt;
    if(argc &amp;lt; 2)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;too few arguments (MRL needed)\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
    libvlc_exception_init(&amp;amp;ex);&lt;br /&gt;
    libvlc = libvlc_new(vlc_argc, vlc_argv, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    m = libvlc_media_new(libvlc, argv[1], &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    mp = libvlc_media_player_new_from_media(m, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    libvlc_media_release(m);&lt;br /&gt;
&lt;br /&gt;
    libvlc_media_player_play(mp, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Main loop&lt;br /&gt;
     */&lt;br /&gt;
    rect.w = 0;&lt;br /&gt;
    rect.h = 0;&lt;br /&gt;
&lt;br /&gt;
    while(!done)&lt;br /&gt;
    { &lt;br /&gt;
        action = 0;&lt;br /&gt;
&lt;br /&gt;
        /* Keys: enter (fullscreen), space (pause), escape (quit) */&lt;br /&gt;
        while( SDL_PollEvent( &amp;amp;event ) ) &lt;br /&gt;
        { &lt;br /&gt;
            switch(event.type)&lt;br /&gt;
            {&lt;br /&gt;
            case SDL_QUIT:&lt;br /&gt;
                done = 1;&lt;br /&gt;
                break;&lt;br /&gt;
            case SDL_KEYDOWN:&lt;br /&gt;
                action = event.key.keysym.sym;&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        switch(action)&lt;br /&gt;
        {&lt;br /&gt;
        case SDLK_ESCAPE:&lt;br /&gt;
            done = 1;&lt;br /&gt;
            break;&lt;br /&gt;
        case SDLK_RETURN:&lt;br /&gt;
            options ^= SDL_FULLSCREEN;&lt;br /&gt;
            screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
            break;&lt;br /&gt;
        case &#039; &#039;:&lt;br /&gt;
            pause = !pause;&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rect.x = (int)((1. + .5 * sin(0.03 * n)) * (WIDTH - VIDEOWIDTH) / 2);&lt;br /&gt;
        rect.y = (int)((1. + .5 * cos(0.03 * n)) * (HEIGHT - VIDEOHEIGHT) / 2);&lt;br /&gt;
&lt;br /&gt;
        if(!pause)&lt;br /&gt;
            n++;&lt;br /&gt;
&lt;br /&gt;
        /* Blitting the surface does not prevent it from being locked and&lt;br /&gt;
         * written to by another thread, so we use this additional mutex. */&lt;br /&gt;
        SDL_LockMutex(ctx.mutex);&lt;br /&gt;
        SDL_BlitSurface(ctx.surf, NULL, screen, &amp;amp;rect);&lt;br /&gt;
        SDL_UnlockMutex(ctx.mutex);&lt;br /&gt;
&lt;br /&gt;
        SDL_Flip(screen);&lt;br /&gt;
        SDL_Delay(10);&lt;br /&gt;
&lt;br /&gt;
        SDL_BlitSurface(empty, NULL, screen, &amp;amp;rect);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Stop stream and clean up libVLC&lt;br /&gt;
     */&lt;br /&gt;
    libvlc_media_player_stop(mp, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
&lt;br /&gt;
    libvlc_media_player_release(mp);&lt;br /&gt;
    libvlc_release(libvlc);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Close window and clean up libSDL&lt;br /&gt;
     */&lt;br /&gt;
    SDL_DestroyMutex(ctx.mutex);&lt;br /&gt;
    SDL_FreeSurface(ctx.surf);&lt;br /&gt;
    SDL_FreeSurface(empty);&lt;br /&gt;
&lt;br /&gt;
    SDL_Quit();&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:LibVLC]]&lt;/div&gt;</summary>
		<author><name>Yamanu</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=LibVLC_SampleCode_SDL&amp;diff=22854</id>
		<title>LibVLC SampleCode SDL</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=LibVLC_SampleCode_SDL&amp;diff=22854"/>
		<updated>2012-07-27T12:21:22Z</updated>

		<summary type="html">&lt;p&gt;Yamanu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Rendering into a custom surface==&lt;br /&gt;
This sample code will render a video into an SDL surface.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;It requires [[LibVLC]] 1.1.1 or later.&#039;&#039;&#039;&lt;br /&gt;
Below is a version with [[#SDL_2.0|SDL 2.0]] and one with [[#Older_API|older SDL API]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* libSDL and libVLC sample code&lt;br /&gt;
 * Copyright © 2008 Sam Hocevar &amp;lt;sam@zoy.org&amp;gt;&lt;br /&gt;
 * license: [http://en.wikipedia.org/wiki/WTFPL WTFPL] */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;assert.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SDL/SDL.h&amp;gt;&lt;br /&gt;
#include &amp;lt;SDL/SDL_mutex.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define WIDTH 640&lt;br /&gt;
#define HEIGHT 480&lt;br /&gt;
&lt;br /&gt;
#define VIDEOWIDTH 320&lt;br /&gt;
#define VIDEOHEIGHT 240&lt;br /&gt;
&lt;br /&gt;
struct ctx&lt;br /&gt;
{&lt;br /&gt;
    SDL_Surface *surf;&lt;br /&gt;
    SDL_mutex *mutex;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
static void *lock(void *data, void **p_pixels)&lt;br /&gt;
{&lt;br /&gt;
    struct ctx *ctx = data;&lt;br /&gt;
&lt;br /&gt;
    SDL_LockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    *p_pixels = ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
    return NULL; /* picture identifier, not needed here */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void unlock(void *data, void *id, void *const *p_pixels)&lt;br /&gt;
{&lt;br /&gt;
    struct ctx *ctx = data;&lt;br /&gt;
&lt;br /&gt;
    /* VLC just rendered the video, but we can also render stuff */&lt;br /&gt;
    uint16_t *pixels = *p_pixels;&lt;br /&gt;
    int x, y;&lt;br /&gt;
&lt;br /&gt;
    for(y = 10; y &amp;lt; 40; y++)&lt;br /&gt;
        for(x = 10; x &amp;lt; 40; x++)&lt;br /&gt;
            if(x &amp;lt; 13 || y &amp;lt; 13 || x &amp;gt; 36 || y &amp;gt; 36)&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0xffff;&lt;br /&gt;
            else&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0x0;&lt;br /&gt;
&lt;br /&gt;
    SDL_UnlockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    SDL_UnlockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
&lt;br /&gt;
    assert(id == NULL); /* picture identifier, not needed here */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void display(void *data, void *id)&lt;br /&gt;
{&lt;br /&gt;
    /* VLC wants to display the video */&lt;br /&gt;
    (void) data;&lt;br /&gt;
    assert(id == NULL);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
    libvlc_instance_t *libvlc;&lt;br /&gt;
    libvlc_media_t *m;&lt;br /&gt;
    libvlc_media_player_t *mp;&lt;br /&gt;
    char const *vlc_argv[] =&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;--no-audio&amp;quot;, /* skip any audio track */&lt;br /&gt;
        &amp;quot;--no-xlib&amp;quot;, /* tell VLC to not use Xlib */&lt;br /&gt;
    };&lt;br /&gt;
    int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);&lt;br /&gt;
&lt;br /&gt;
    SDL_Surface *screen, *empty;&lt;br /&gt;
    SDL_Event event;&lt;br /&gt;
    SDL_Rect rect;&lt;br /&gt;
    int done = 0, action = 0, pause = 0, n = 0;&lt;br /&gt;
&lt;br /&gt;
    struct ctx ctx;&lt;br /&gt;
&lt;br /&gt;
    if(argc &amp;lt; 2)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;Usage: %s &amp;lt;filename&amp;gt;\n&amp;quot;, argv[0]);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libSDL&lt;br /&gt;
     */&lt;br /&gt;
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) == -1)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot initialize SDL\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    empty = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                 32, 0, 0, 0, 0);&lt;br /&gt;
    ctx.surf = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                    16, 0x001f, 0x07e0, 0xf800, 0);&lt;br /&gt;
&lt;br /&gt;
    ctx.mutex = SDL_CreateMutex();&lt;br /&gt;
&lt;br /&gt;
    int options = SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF;&lt;br /&gt;
&lt;br /&gt;
    screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
    if(!screen)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot set video mode\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libVLC&lt;br /&gt;
     */&lt;br /&gt;
    libvlc = libvlc_new(vlc_argc, vlc_argv);&lt;br /&gt;
    m = libvlc_media_new_path(libvlc, argv[1]);&lt;br /&gt;
    mp = libvlc_media_player_new_from_media(m);&lt;br /&gt;
    libvlc_media_release(m);&lt;br /&gt;
&lt;br /&gt;
    libvlc_video_set_callbacks(mp, lock, unlock, display, &amp;amp;ctx);&lt;br /&gt;
    libvlc_video_set_format(mp, &amp;quot;RV16&amp;quot;, VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH*2);&lt;br /&gt;
    libvlc_media_player_play(mp);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Main loop&lt;br /&gt;
     */&lt;br /&gt;
    rect.w = 0;&lt;br /&gt;
    rect.h = 0;&lt;br /&gt;
&lt;br /&gt;
    while(!done)&lt;br /&gt;
    { &lt;br /&gt;
        action = 0;&lt;br /&gt;
&lt;br /&gt;
        /* Keys: enter (fullscreen), space (pause), escape (quit) */&lt;br /&gt;
        while( SDL_PollEvent( &amp;amp;event ) ) &lt;br /&gt;
        { &lt;br /&gt;
            switch(event.type)&lt;br /&gt;
            {&lt;br /&gt;
            case SDL_QUIT:&lt;br /&gt;
                done = 1;&lt;br /&gt;
                break;&lt;br /&gt;
            case SDL_KEYDOWN:&lt;br /&gt;
                action = event.key.keysym.sym;&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        switch(action)&lt;br /&gt;
        {&lt;br /&gt;
        case SDLK_ESCAPE:&lt;br /&gt;
            done = 1;&lt;br /&gt;
            break;&lt;br /&gt;
        case SDLK_RETURN:&lt;br /&gt;
            options ^= SDL_FULLSCREEN;&lt;br /&gt;
            screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
            break;&lt;br /&gt;
        case &#039; &#039;:&lt;br /&gt;
            pause = !pause;&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rect.x = (int)((1. + .5 * sin(0.03 * n)) * (WIDTH - VIDEOWIDTH) / 2);&lt;br /&gt;
        rect.y = (int)((1. + .5 * cos(0.03 * n)) * (HEIGHT - VIDEOHEIGHT) / 2);&lt;br /&gt;
&lt;br /&gt;
        if(!pause)&lt;br /&gt;
            n++;&lt;br /&gt;
&lt;br /&gt;
        /* Blitting the surface does not prevent it from being locked and&lt;br /&gt;
         * written to by another thread, so we use this additional mutex. */&lt;br /&gt;
        SDL_LockMutex(ctx.mutex);&lt;br /&gt;
        SDL_BlitSurface(ctx.surf, NULL, screen, &amp;amp;rect);&lt;br /&gt;
        SDL_UnlockMutex(ctx.mutex);&lt;br /&gt;
&lt;br /&gt;
        SDL_Flip(screen);&lt;br /&gt;
        SDL_Delay(10);&lt;br /&gt;
&lt;br /&gt;
        SDL_BlitSurface(empty, NULL, screen, &amp;amp;rect);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Stop stream and clean up libVLC&lt;br /&gt;
     */&lt;br /&gt;
    libvlc_media_player_stop(mp);&lt;br /&gt;
    libvlc_media_player_release(mp);&lt;br /&gt;
    libvlc_release(libvlc);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Close window and clean up libSDL&lt;br /&gt;
     */&lt;br /&gt;
    SDL_DestroyMutex(ctx.mutex);&lt;br /&gt;
    SDL_FreeSurface(ctx.surf);&lt;br /&gt;
    SDL_FreeSurface(empty);&lt;br /&gt;
&lt;br /&gt;
    SDL_Quit();&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===SDL 2.0===&lt;br /&gt;
&lt;br /&gt;
This version works with [[LibVLC]] 1.1.1 or later and SDL 2.0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// libSDL and libVLC sample code.&lt;br /&gt;
// License: [http://en.wikipedia.org/wiki/WTFPL WTFPL]&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;assert.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;SDL/SDL.h&amp;quot;&lt;br /&gt;
#include &amp;quot;SDL/SDL_mutex.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;vlc/vlc.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#define WIDTH 640&lt;br /&gt;
#define HEIGHT 480&lt;br /&gt;
&lt;br /&gt;
#define VIDEOWIDTH 320&lt;br /&gt;
#define VIDEOHEIGHT 240&lt;br /&gt;
&lt;br /&gt;
struct context {&lt;br /&gt;
    SDL_Renderer *renderer;&lt;br /&gt;
    SDL_Texture *texture;&lt;br /&gt;
    SDL_mutex *mutex;&lt;br /&gt;
    int n;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
// VLC prepares to render a video frame.&lt;br /&gt;
static void *lock(void *data, void **p_pixels) {&lt;br /&gt;
&lt;br /&gt;
    struct context *c = (context *)data;&lt;br /&gt;
&lt;br /&gt;
    int pitch;&lt;br /&gt;
    SDL_LockMutex(c-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockTexture(c-&amp;gt;texture, NULL, p_pixels, &amp;amp;pitch);&lt;br /&gt;
&lt;br /&gt;
    return NULL; // Picture identifier, not needed here.&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// VLC just rendered a video frame.&lt;br /&gt;
static void unlock(void *data, void *id, void *const *p_pixels) {&lt;br /&gt;
&lt;br /&gt;
    struct context *c = (context *)data;&lt;br /&gt;
&lt;br /&gt;
    uint16_t *pixels = (uint16_t *)*p_pixels;&lt;br /&gt;
&lt;br /&gt;
    // We can also render stuff.&lt;br /&gt;
    int x, y;&lt;br /&gt;
    for(y = 10; y &amp;lt; 40; y++) {&lt;br /&gt;
        for(x = 10; x &amp;lt; 40; x++) {&lt;br /&gt;
            if(x &amp;lt; 13 || y &amp;lt; 13 || x &amp;gt; 36 || y &amp;gt; 36) {&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0xffff;&lt;br /&gt;
            } else {&lt;br /&gt;
                // RV16 = 5+6+5 pixels per color, BGR.&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0x02ff;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    SDL_UnlockTexture(c-&amp;gt;texture);&lt;br /&gt;
    SDL_UnlockMutex(c-&amp;gt;mutex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// VLC wants to display a video frame.&lt;br /&gt;
static void display(void *data, void *id) {&lt;br /&gt;
&lt;br /&gt;
    struct context *c = (context *)data;&lt;br /&gt;
&lt;br /&gt;
    SDL_Rect rect;&lt;br /&gt;
    rect.w = VIDEOWIDTH;&lt;br /&gt;
    rect.h = VIDEOHEIGHT;&lt;br /&gt;
    rect.x = (int)((1. + .5 * sin(0.03 * c-&amp;gt;n)) * (WIDTH - VIDEOWIDTH) / 2);&lt;br /&gt;
    rect.y = (int)((1. + .5 * cos(0.03 * c-&amp;gt;n)) * (HEIGHT - VIDEOHEIGHT) / 2);&lt;br /&gt;
&lt;br /&gt;
    SDL_SetRenderDrawColor(c-&amp;gt;renderer, 0, 80, 0, 255);&lt;br /&gt;
    SDL_RenderClear(c-&amp;gt;renderer);&lt;br /&gt;
    SDL_RenderCopy(c-&amp;gt;renderer, c-&amp;gt;texture, NULL, &amp;amp;rect);&lt;br /&gt;
    SDL_RenderPresent(c-&amp;gt;renderer);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void quit(int c) {&lt;br /&gt;
    SDL_Quit();&lt;br /&gt;
    exit(c);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[]) {&lt;br /&gt;
&lt;br /&gt;
    libvlc_instance_t *libvlc;&lt;br /&gt;
    libvlc_media_t *m;&lt;br /&gt;
    libvlc_media_player_t *mp;&lt;br /&gt;
    char const *vlc_argv[] = {&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;--no-audio&amp;quot;, // Don&#039;t play audio.&lt;br /&gt;
        &amp;quot;--no-xlib&amp;quot;, // Don&#039;t use Xlib.&lt;br /&gt;
&lt;br /&gt;
        // Apply a video filter.&lt;br /&gt;
        //&amp;quot;--video-filter&amp;quot;, &amp;quot;sepia&amp;quot;,&lt;br /&gt;
        //&amp;quot;--sepia-intensity=200&amp;quot;&lt;br /&gt;
    };&lt;br /&gt;
    int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);&lt;br /&gt;
&lt;br /&gt;
    SDL_Event event;&lt;br /&gt;
    int done = 0, action = 0, pause = 0, n = 0;&lt;br /&gt;
&lt;br /&gt;
    struct context context;&lt;br /&gt;
&lt;br /&gt;
    if(argc &amp;lt; 2) {&lt;br /&gt;
        printf(&amp;quot;Usage: %s &amp;lt;filename&amp;gt;\n&amp;quot;, argv[0]);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Initialise libSDL.&lt;br /&gt;
    if(SDL_Init(SDL_INIT_VIDEO) &amp;lt; 0) {&lt;br /&gt;
        printf(&amp;quot;Could not initialize SDL: %s.\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Create SDL graphics objects.&lt;br /&gt;
    SDL_Window * window = SDL_CreateWindow(&lt;br /&gt;
            &amp;quot;Fartplayer&amp;quot;,&lt;br /&gt;
            SDL_WINDOWPOS_UNDEFINED,&lt;br /&gt;
            SDL_WINDOWPOS_UNDEFINED,&lt;br /&gt;
            WIDTH, HEIGHT,&lt;br /&gt;
            SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE);&lt;br /&gt;
    if (!window) {&lt;br /&gt;
        fprintf(stderr, &amp;quot;Couldn&#039;t create window: %s\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        quit(3);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    context.renderer = SDL_CreateRenderer(window, -1, 0);&lt;br /&gt;
    if (!context.renderer) {&lt;br /&gt;
        fprintf(stderr, &amp;quot;Couldn&#039;t create renderer: %s\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        quit(4);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    context.texture = SDL_CreateTexture(&lt;br /&gt;
            context.renderer,&lt;br /&gt;
            SDL_PIXELFORMAT_BGR565, SDL_TEXTUREACCESS_STREAMING,&lt;br /&gt;
            VIDEOWIDTH, VIDEOHEIGHT);&lt;br /&gt;
    if (!context.texture) {&lt;br /&gt;
        fprintf(stderr, &amp;quot;Couldn&#039;t create texture: %s\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        quit(5);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    context.mutex = SDL_CreateMutex();&lt;br /&gt;
&lt;br /&gt;
    // If you don&#039;t have this variable set you must have plugins directory&lt;br /&gt;
    // with the executable or libvlc_new() will not work!&lt;br /&gt;
    printf(&amp;quot;VLC_PLUGIN_PATH=%s\n&amp;quot;, getenv(&amp;quot;VLC_PLUGIN_PATH&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
    // Initialise libVLC.&lt;br /&gt;
    libvlc = libvlc_new(vlc_argc, vlc_argv);&lt;br /&gt;
    if(NULL == libvlc) {&lt;br /&gt;
        printf(&amp;quot;LibVLC initialization failure.\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    m = libvlc_media_new_path(libvlc, argv[1]);&lt;br /&gt;
    mp = libvlc_media_player_new_from_media(m);&lt;br /&gt;
    libvlc_media_release(m);&lt;br /&gt;
&lt;br /&gt;
    libvlc_video_set_callbacks(mp, lock, unlock, display, &amp;amp;context);&lt;br /&gt;
    libvlc_video_set_format(mp, &amp;quot;RV16&amp;quot;, VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH*2);&lt;br /&gt;
    libvlc_media_player_play(mp);&lt;br /&gt;
&lt;br /&gt;
    // Main loop.&lt;br /&gt;
    while(!done) {&lt;br /&gt;
&lt;br /&gt;
        action = 0;&lt;br /&gt;
&lt;br /&gt;
        // Keys: enter (fullscreen), space (pause), escape (quit).&lt;br /&gt;
        while( SDL_PollEvent( &amp;amp;event )) {&lt;br /&gt;
&lt;br /&gt;
            switch(event.type) {&lt;br /&gt;
                case SDL_QUIT:&lt;br /&gt;
                    done = 1;&lt;br /&gt;
                    break;&lt;br /&gt;
                case SDL_KEYDOWN:&lt;br /&gt;
                    action = event.key.keysym.sym;&lt;br /&gt;
                    break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        switch(action) {&lt;br /&gt;
            case SDLK_ESCAPE:&lt;br /&gt;
            case SDLK_q:&lt;br /&gt;
                done = 1;&lt;br /&gt;
                break;&lt;br /&gt;
            case &#039; &#039;:&lt;br /&gt;
                printf(&amp;quot;Pause toggle.\n&amp;quot;);&lt;br /&gt;
                pause = !pause;&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        if(!pause) { context.n++; }&lt;br /&gt;
&lt;br /&gt;
        SDL_Delay(1000/10);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Stop stream and clean up libVLC.&lt;br /&gt;
    libvlc_media_player_stop(mp);&lt;br /&gt;
    libvlc_media_player_release(mp);&lt;br /&gt;
    libvlc_release(libvlc);&lt;br /&gt;
&lt;br /&gt;
    // Close window and clean up libSDL.&lt;br /&gt;
    SDL_DestroyMutex(context.mutex);&lt;br /&gt;
    SDL_DestroyRenderer(context.renderer);&lt;br /&gt;
&lt;br /&gt;
    quit(0);&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Older API===&lt;br /&gt;
&lt;br /&gt;
This code was used for LibVLC 0.9.x and 1.0.x.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* libSDL and libVLC sample code&lt;br /&gt;
 * Copyright © 2008 Sam Hocevar &amp;lt;sam@zoy.org&amp;gt;&lt;br /&gt;
 * license: [http://en.wikipedia.org/wiki/WTFPL WTFPL] */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SDL.h&amp;gt;&lt;br /&gt;
#include &amp;lt;SDL_mutex.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define WIDTH 640&lt;br /&gt;
#define HEIGHT 480&lt;br /&gt;
&lt;br /&gt;
#define VIDEOWIDTH 320&lt;br /&gt;
#define VIDEOHEIGHT 240&lt;br /&gt;
&lt;br /&gt;
struct ctx&lt;br /&gt;
{&lt;br /&gt;
    SDL_Surface *surf;&lt;br /&gt;
    SDL_mutex *mutex;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
static void catch (libvlc_exception_t *ex)&lt;br /&gt;
{&lt;br /&gt;
    if(libvlc_exception_raised(ex))&lt;br /&gt;
    {&lt;br /&gt;
        fprintf(stderr, &amp;quot;exception: %s\n&amp;quot;, libvlc_exception_get_message(ex));&lt;br /&gt;
        exit(1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    libvlc_exception_clear(ex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#ifdef VLC09X&lt;br /&gt;
static void * lock(struct ctx *ctx)&lt;br /&gt;
{&lt;br /&gt;
    SDL_LockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    return ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
}&lt;br /&gt;
#else&lt;br /&gt;
static void lock(struct ctx *ctx, void **pp_ret)&lt;br /&gt;
{&lt;br /&gt;
    SDL_LockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    *pp_ret = ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
static void unlock(struct ctx *ctx)&lt;br /&gt;
{&lt;br /&gt;
    /* VLC just rendered the video, but we can also render stuff */&lt;br /&gt;
    uint16_t *pixels = (uint16_t *)ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
    int x, y;&lt;br /&gt;
&lt;br /&gt;
    for(y = 10; y &amp;lt; 40; y++)&lt;br /&gt;
        for(x = 10; x &amp;lt; 40; x++)&lt;br /&gt;
            if(x &amp;lt; 13 || y &amp;lt; 13 || x &amp;gt; 36 || y &amp;gt; 36)&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0xffff;&lt;br /&gt;
            else&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0x0;&lt;br /&gt;
&lt;br /&gt;
    SDL_UnlockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    SDL_UnlockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
    char clock[64], cunlock[64], cdata[64];&lt;br /&gt;
    char width[32], height[32], pitch[32];&lt;br /&gt;
    libvlc_exception_t ex;&lt;br /&gt;
    libvlc_instance_t *libvlc;&lt;br /&gt;
    libvlc_media_t *m;&lt;br /&gt;
    libvlc_media_player_t *mp;&lt;br /&gt;
    char const *vlc_argv[] =&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;-q&amp;quot;,&lt;br /&gt;
        //&amp;quot;-vvvvv&amp;quot;,&lt;br /&gt;
        &amp;quot;--plugin-path&amp;quot;, VLC_TREE &amp;quot;/modules&amp;quot;,&lt;br /&gt;
        &amp;quot;--ignore-config&amp;quot;, /* Don&#039;t use VLC&#039;s config files */&lt;br /&gt;
        &amp;quot;--noaudio&amp;quot;,&lt;br /&gt;
        &amp;quot;--vout&amp;quot;, &amp;quot;vmem&amp;quot;,&lt;br /&gt;
        &amp;quot;--vmem-width&amp;quot;, width,&lt;br /&gt;
        &amp;quot;--vmem-height&amp;quot;, height,&lt;br /&gt;
        &amp;quot;--vmem-pitch&amp;quot;, pitch,&lt;br /&gt;
        &amp;quot;--vmem-chroma&amp;quot;, &amp;quot;RV16&amp;quot;,&lt;br /&gt;
        &amp;quot;--vmem-lock&amp;quot;, clock,&lt;br /&gt;
        &amp;quot;--vmem-unlock&amp;quot;, cunlock,&lt;br /&gt;
        &amp;quot;--vmem-data&amp;quot;, cdata,&lt;br /&gt;
    };&lt;br /&gt;
    int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);&lt;br /&gt;
&lt;br /&gt;
    SDL_Surface *screen, *empty;&lt;br /&gt;
    SDL_Event event;&lt;br /&gt;
    SDL_Rect rect;&lt;br /&gt;
    int done = 0, action = 0, pause = 0, n = 0;&lt;br /&gt;
&lt;br /&gt;
    struct ctx ctx;&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libSDL&lt;br /&gt;
     */&lt;br /&gt;
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) == -1)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot initialize SDL\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    empty = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                 32, 0, 0, 0, 0);&lt;br /&gt;
    ctx.surf = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                    16, 0x001f, 0x07e0, 0xf800, 0);&lt;br /&gt;
&lt;br /&gt;
    ctx.mutex = SDL_CreateMutex();&lt;br /&gt;
&lt;br /&gt;
    int options = SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF;&lt;br /&gt;
&lt;br /&gt;
    screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
    if(!screen)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot set video mode\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libVLC&lt;br /&gt;
     */&lt;br /&gt;
    sprintf(clock, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)lock);&lt;br /&gt;
    sprintf(cunlock, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)unlock);&lt;br /&gt;
    sprintf(cdata, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)&amp;amp;ctx);&lt;br /&gt;
    sprintf(width, &amp;quot;%i&amp;quot;, VIDEOWIDTH);&lt;br /&gt;
    sprintf(height, &amp;quot;%i&amp;quot;, VIDEOHEIGHT);&lt;br /&gt;
    sprintf(pitch, &amp;quot;%i&amp;quot;, VIDEOWIDTH * 2);&lt;br /&gt;
&lt;br /&gt;
    if(argc &amp;lt; 2)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;too few arguments (MRL needed)\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
    libvlc_exception_init(&amp;amp;ex);&lt;br /&gt;
    libvlc = libvlc_new(vlc_argc, vlc_argv, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    m = libvlc_media_new(libvlc, argv[1], &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    mp = libvlc_media_player_new_from_media(m, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    libvlc_media_release(m);&lt;br /&gt;
&lt;br /&gt;
    libvlc_media_player_play(mp, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Main loop&lt;br /&gt;
     */&lt;br /&gt;
    rect.w = 0;&lt;br /&gt;
    rect.h = 0;&lt;br /&gt;
&lt;br /&gt;
    while(!done)&lt;br /&gt;
    { &lt;br /&gt;
        action = 0;&lt;br /&gt;
&lt;br /&gt;
        /* Keys: enter (fullscreen), space (pause), escape (quit) */&lt;br /&gt;
        while( SDL_PollEvent( &amp;amp;event ) ) &lt;br /&gt;
        { &lt;br /&gt;
            switch(event.type)&lt;br /&gt;
            {&lt;br /&gt;
            case SDL_QUIT:&lt;br /&gt;
                done = 1;&lt;br /&gt;
                break;&lt;br /&gt;
            case SDL_KEYDOWN:&lt;br /&gt;
                action = event.key.keysym.sym;&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        switch(action)&lt;br /&gt;
        {&lt;br /&gt;
        case SDLK_ESCAPE:&lt;br /&gt;
            done = 1;&lt;br /&gt;
            break;&lt;br /&gt;
        case SDLK_RETURN:&lt;br /&gt;
            options ^= SDL_FULLSCREEN;&lt;br /&gt;
            screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
            break;&lt;br /&gt;
        case &#039; &#039;:&lt;br /&gt;
            pause = !pause;&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rect.x = (int)((1. + .5 * sin(0.03 * n)) * (WIDTH - VIDEOWIDTH) / 2);&lt;br /&gt;
        rect.y = (int)((1. + .5 * cos(0.03 * n)) * (HEIGHT - VIDEOHEIGHT) / 2);&lt;br /&gt;
&lt;br /&gt;
        if(!pause)&lt;br /&gt;
            n++;&lt;br /&gt;
&lt;br /&gt;
        /* Blitting the surface does not prevent it from being locked and&lt;br /&gt;
         * written to by another thread, so we use this additional mutex. */&lt;br /&gt;
        SDL_LockMutex(ctx.mutex);&lt;br /&gt;
        SDL_BlitSurface(ctx.surf, NULL, screen, &amp;amp;rect);&lt;br /&gt;
        SDL_UnlockMutex(ctx.mutex);&lt;br /&gt;
&lt;br /&gt;
        SDL_Flip(screen);&lt;br /&gt;
        SDL_Delay(10);&lt;br /&gt;
&lt;br /&gt;
        SDL_BlitSurface(empty, NULL, screen, &amp;amp;rect);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Stop stream and clean up libVLC&lt;br /&gt;
     */&lt;br /&gt;
    libvlc_media_player_stop(mp, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
&lt;br /&gt;
    libvlc_media_player_release(mp);&lt;br /&gt;
    libvlc_release(libvlc);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Close window and clean up libSDL&lt;br /&gt;
     */&lt;br /&gt;
    SDL_DestroyMutex(ctx.mutex);&lt;br /&gt;
    SDL_FreeSurface(ctx.surf);&lt;br /&gt;
    SDL_FreeSurface(empty);&lt;br /&gt;
&lt;br /&gt;
    SDL_Quit();&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:LibVLC]]&lt;/div&gt;</summary>
		<author><name>Yamanu</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=LibVLC_SampleCode_SDL&amp;diff=22853</id>
		<title>LibVLC SampleCode SDL</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=LibVLC_SampleCode_SDL&amp;diff=22853"/>
		<updated>2012-07-27T12:15:45Z</updated>

		<summary type="html">&lt;p&gt;Yamanu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Rendering into a custom surface==&lt;br /&gt;
This sample code will render a video into an SDL surface.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;It requires [[LibVLC]] 1.1.1 or later.&#039;&#039;&#039;&lt;br /&gt;
Below is a version with [[#SDL_20|SDL 2.0]] and one with [[#Older_API|older SDL API]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* libSDL and libVLC sample code&lt;br /&gt;
 * Copyright © 2008 Sam Hocevar &amp;lt;sam@zoy.org&amp;gt;&lt;br /&gt;
 * license: [http://en.wikipedia.org/wiki/WTFPL WTFPL] */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;assert.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SDL/SDL.h&amp;gt;&lt;br /&gt;
#include &amp;lt;SDL/SDL_mutex.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define WIDTH 640&lt;br /&gt;
#define HEIGHT 480&lt;br /&gt;
&lt;br /&gt;
#define VIDEOWIDTH 320&lt;br /&gt;
#define VIDEOHEIGHT 240&lt;br /&gt;
&lt;br /&gt;
struct ctx&lt;br /&gt;
{&lt;br /&gt;
    SDL_Surface *surf;&lt;br /&gt;
    SDL_mutex *mutex;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
static void *lock(void *data, void **p_pixels)&lt;br /&gt;
{&lt;br /&gt;
    struct ctx *ctx = data;&lt;br /&gt;
&lt;br /&gt;
    SDL_LockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    *p_pixels = ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
    return NULL; /* picture identifier, not needed here */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void unlock(void *data, void *id, void *const *p_pixels)&lt;br /&gt;
{&lt;br /&gt;
    struct ctx *ctx = data;&lt;br /&gt;
&lt;br /&gt;
    /* VLC just rendered the video, but we can also render stuff */&lt;br /&gt;
    uint16_t *pixels = *p_pixels;&lt;br /&gt;
    int x, y;&lt;br /&gt;
&lt;br /&gt;
    for(y = 10; y &amp;lt; 40; y++)&lt;br /&gt;
        for(x = 10; x &amp;lt; 40; x++)&lt;br /&gt;
            if(x &amp;lt; 13 || y &amp;lt; 13 || x &amp;gt; 36 || y &amp;gt; 36)&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0xffff;&lt;br /&gt;
            else&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0x0;&lt;br /&gt;
&lt;br /&gt;
    SDL_UnlockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    SDL_UnlockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
&lt;br /&gt;
    assert(id == NULL); /* picture identifier, not needed here */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void display(void *data, void *id)&lt;br /&gt;
{&lt;br /&gt;
    /* VLC wants to display the video */&lt;br /&gt;
    (void) data;&lt;br /&gt;
    assert(id == NULL);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
    libvlc_instance_t *libvlc;&lt;br /&gt;
    libvlc_media_t *m;&lt;br /&gt;
    libvlc_media_player_t *mp;&lt;br /&gt;
    char const *vlc_argv[] =&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;--no-audio&amp;quot;, /* skip any audio track */&lt;br /&gt;
        &amp;quot;--no-xlib&amp;quot;, /* tell VLC to not use Xlib */&lt;br /&gt;
    };&lt;br /&gt;
    int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);&lt;br /&gt;
&lt;br /&gt;
    SDL_Surface *screen, *empty;&lt;br /&gt;
    SDL_Event event;&lt;br /&gt;
    SDL_Rect rect;&lt;br /&gt;
    int done = 0, action = 0, pause = 0, n = 0;&lt;br /&gt;
&lt;br /&gt;
    struct ctx ctx;&lt;br /&gt;
&lt;br /&gt;
    if(argc &amp;lt; 2)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;Usage: %s &amp;lt;filename&amp;gt;\n&amp;quot;, argv[0]);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libSDL&lt;br /&gt;
     */&lt;br /&gt;
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) == -1)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot initialize SDL\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    empty = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                 32, 0, 0, 0, 0);&lt;br /&gt;
    ctx.surf = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                    16, 0x001f, 0x07e0, 0xf800, 0);&lt;br /&gt;
&lt;br /&gt;
    ctx.mutex = SDL_CreateMutex();&lt;br /&gt;
&lt;br /&gt;
    int options = SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF;&lt;br /&gt;
&lt;br /&gt;
    screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
    if(!screen)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot set video mode\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libVLC&lt;br /&gt;
     */&lt;br /&gt;
    libvlc = libvlc_new(vlc_argc, vlc_argv);&lt;br /&gt;
    m = libvlc_media_new_path(libvlc, argv[1]);&lt;br /&gt;
    mp = libvlc_media_player_new_from_media(m);&lt;br /&gt;
    libvlc_media_release(m);&lt;br /&gt;
&lt;br /&gt;
    libvlc_video_set_callbacks(mp, lock, unlock, display, &amp;amp;ctx);&lt;br /&gt;
    libvlc_video_set_format(mp, &amp;quot;RV16&amp;quot;, VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH*2);&lt;br /&gt;
    libvlc_media_player_play(mp);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Main loop&lt;br /&gt;
     */&lt;br /&gt;
    rect.w = 0;&lt;br /&gt;
    rect.h = 0;&lt;br /&gt;
&lt;br /&gt;
    while(!done)&lt;br /&gt;
    { &lt;br /&gt;
        action = 0;&lt;br /&gt;
&lt;br /&gt;
        /* Keys: enter (fullscreen), space (pause), escape (quit) */&lt;br /&gt;
        while( SDL_PollEvent( &amp;amp;event ) ) &lt;br /&gt;
        { &lt;br /&gt;
            switch(event.type)&lt;br /&gt;
            {&lt;br /&gt;
            case SDL_QUIT:&lt;br /&gt;
                done = 1;&lt;br /&gt;
                break;&lt;br /&gt;
            case SDL_KEYDOWN:&lt;br /&gt;
                action = event.key.keysym.sym;&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        switch(action)&lt;br /&gt;
        {&lt;br /&gt;
        case SDLK_ESCAPE:&lt;br /&gt;
            done = 1;&lt;br /&gt;
            break;&lt;br /&gt;
        case SDLK_RETURN:&lt;br /&gt;
            options ^= SDL_FULLSCREEN;&lt;br /&gt;
            screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
            break;&lt;br /&gt;
        case &#039; &#039;:&lt;br /&gt;
            pause = !pause;&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rect.x = (int)((1. + .5 * sin(0.03 * n)) * (WIDTH - VIDEOWIDTH) / 2);&lt;br /&gt;
        rect.y = (int)((1. + .5 * cos(0.03 * n)) * (HEIGHT - VIDEOHEIGHT) / 2);&lt;br /&gt;
&lt;br /&gt;
        if(!pause)&lt;br /&gt;
            n++;&lt;br /&gt;
&lt;br /&gt;
        /* Blitting the surface does not prevent it from being locked and&lt;br /&gt;
         * written to by another thread, so we use this additional mutex. */&lt;br /&gt;
        SDL_LockMutex(ctx.mutex);&lt;br /&gt;
        SDL_BlitSurface(ctx.surf, NULL, screen, &amp;amp;rect);&lt;br /&gt;
        SDL_UnlockMutex(ctx.mutex);&lt;br /&gt;
&lt;br /&gt;
        SDL_Flip(screen);&lt;br /&gt;
        SDL_Delay(10);&lt;br /&gt;
&lt;br /&gt;
        SDL_BlitSurface(empty, NULL, screen, &amp;amp;rect);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Stop stream and clean up libVLC&lt;br /&gt;
     */&lt;br /&gt;
    libvlc_media_player_stop(mp);&lt;br /&gt;
    libvlc_media_player_release(mp);&lt;br /&gt;
    libvlc_release(libvlc);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Close window and clean up libSDL&lt;br /&gt;
     */&lt;br /&gt;
    SDL_DestroyMutex(ctx.mutex);&lt;br /&gt;
    SDL_FreeSurface(ctx.surf);&lt;br /&gt;
    SDL_FreeSurface(empty);&lt;br /&gt;
&lt;br /&gt;
    SDL_Quit();&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===SDL 2.0===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// libSDL and libVLC sample code.&lt;br /&gt;
// License: [http://en.wikipedia.org/wiki/WTFPL WTFPL]&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;assert.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;SDL/SDL.h&amp;quot;&lt;br /&gt;
#include &amp;quot;SDL/SDL_mutex.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;vlc/vlc.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#define WIDTH 640&lt;br /&gt;
#define HEIGHT 480&lt;br /&gt;
&lt;br /&gt;
#define VIDEOWIDTH 320&lt;br /&gt;
#define VIDEOHEIGHT 240&lt;br /&gt;
&lt;br /&gt;
struct context {&lt;br /&gt;
    SDL_Renderer *renderer;&lt;br /&gt;
    SDL_Texture *texture;&lt;br /&gt;
    SDL_mutex *mutex;&lt;br /&gt;
    int n;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
// VLC prepares to render a video frame.&lt;br /&gt;
static void *lock(void *data, void **p_pixels) {&lt;br /&gt;
&lt;br /&gt;
    struct context *c = (context *)data;&lt;br /&gt;
&lt;br /&gt;
    int pitch;&lt;br /&gt;
    SDL_LockMutex(c-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockTexture(c-&amp;gt;texture, NULL, p_pixels, &amp;amp;pitch);&lt;br /&gt;
&lt;br /&gt;
    return NULL; // Picture identifier, not needed here.&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// VLC just rendered a video frame.&lt;br /&gt;
static void unlock(void *data, void *id, void *const *p_pixels) {&lt;br /&gt;
&lt;br /&gt;
    struct context *c = (context *)data;&lt;br /&gt;
&lt;br /&gt;
    uint16_t *pixels = (uint16_t *)*p_pixels;&lt;br /&gt;
&lt;br /&gt;
    // We can also render stuff.&lt;br /&gt;
    int x, y;&lt;br /&gt;
    for(y = 10; y &amp;lt; 40; y++) {&lt;br /&gt;
        for(x = 10; x &amp;lt; 40; x++) {&lt;br /&gt;
            if(x &amp;lt; 13 || y &amp;lt; 13 || x &amp;gt; 36 || y &amp;gt; 36) {&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0xffff;&lt;br /&gt;
            } else {&lt;br /&gt;
                // RV16 = 5+6+5 pixels per color, BGR.&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0x02ff;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    SDL_UnlockTexture(c-&amp;gt;texture);&lt;br /&gt;
    SDL_UnlockMutex(c-&amp;gt;mutex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// VLC wants to display a video frame.&lt;br /&gt;
static void display(void *data, void *id) {&lt;br /&gt;
&lt;br /&gt;
    struct context *c = (context *)data;&lt;br /&gt;
&lt;br /&gt;
    SDL_Rect rect;&lt;br /&gt;
    rect.w = VIDEOWIDTH;&lt;br /&gt;
    rect.h = VIDEOHEIGHT;&lt;br /&gt;
    rect.x = (int)((1. + .5 * sin(0.03 * c-&amp;gt;n)) * (WIDTH - VIDEOWIDTH) / 2);&lt;br /&gt;
    rect.y = (int)((1. + .5 * cos(0.03 * c-&amp;gt;n)) * (HEIGHT - VIDEOHEIGHT) / 2);&lt;br /&gt;
&lt;br /&gt;
    SDL_SetRenderDrawColor(c-&amp;gt;renderer, 0, 80, 0, 255);&lt;br /&gt;
    SDL_RenderClear(c-&amp;gt;renderer);&lt;br /&gt;
    SDL_RenderCopy(c-&amp;gt;renderer, c-&amp;gt;texture, NULL, &amp;amp;rect);&lt;br /&gt;
    SDL_RenderPresent(c-&amp;gt;renderer);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void quit(int c) {&lt;br /&gt;
    SDL_Quit();&lt;br /&gt;
    exit(c);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[]) {&lt;br /&gt;
&lt;br /&gt;
    libvlc_instance_t *libvlc;&lt;br /&gt;
    libvlc_media_t *m;&lt;br /&gt;
    libvlc_media_player_t *mp;&lt;br /&gt;
    char const *vlc_argv[] = {&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;--no-audio&amp;quot;, // Don&#039;t play audio.&lt;br /&gt;
        &amp;quot;--no-xlib&amp;quot;, // Don&#039;t use Xlib.&lt;br /&gt;
&lt;br /&gt;
        // Apply a video filter.&lt;br /&gt;
        //&amp;quot;--video-filter&amp;quot;, &amp;quot;sepia&amp;quot;,&lt;br /&gt;
        //&amp;quot;--sepia-intensity=200&amp;quot;&lt;br /&gt;
    };&lt;br /&gt;
    int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);&lt;br /&gt;
&lt;br /&gt;
    SDL_Event event;&lt;br /&gt;
    int done = 0, action = 0, pause = 0, n = 0;&lt;br /&gt;
&lt;br /&gt;
    struct context context;&lt;br /&gt;
&lt;br /&gt;
    if(argc &amp;lt; 2) {&lt;br /&gt;
        printf(&amp;quot;Usage: %s &amp;lt;filename&amp;gt;\n&amp;quot;, argv[0]);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Initialise libSDL.&lt;br /&gt;
    if(SDL_Init(SDL_INIT_VIDEO) &amp;lt; 0) {&lt;br /&gt;
        printf(&amp;quot;Could not initialize SDL: %s.\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Create SDL graphics objects.&lt;br /&gt;
    SDL_Window * window = SDL_CreateWindow(&lt;br /&gt;
            &amp;quot;Fartplayer&amp;quot;,&lt;br /&gt;
            SDL_WINDOWPOS_UNDEFINED,&lt;br /&gt;
            SDL_WINDOWPOS_UNDEFINED,&lt;br /&gt;
            WIDTH, HEIGHT,&lt;br /&gt;
            SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE);&lt;br /&gt;
    if (!window) {&lt;br /&gt;
        fprintf(stderr, &amp;quot;Couldn&#039;t create window: %s\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        quit(3);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    context.renderer = SDL_CreateRenderer(window, -1, 0);&lt;br /&gt;
    if (!context.renderer) {&lt;br /&gt;
        fprintf(stderr, &amp;quot;Couldn&#039;t create renderer: %s\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        quit(4);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    context.texture = SDL_CreateTexture(&lt;br /&gt;
            context.renderer,&lt;br /&gt;
            SDL_PIXELFORMAT_BGR565, SDL_TEXTUREACCESS_STREAMING,&lt;br /&gt;
            VIDEOWIDTH, VIDEOHEIGHT);&lt;br /&gt;
    if (!context.texture) {&lt;br /&gt;
        fprintf(stderr, &amp;quot;Couldn&#039;t create texture: %s\n&amp;quot;, SDL_GetError());&lt;br /&gt;
        quit(5);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    context.mutex = SDL_CreateMutex();&lt;br /&gt;
&lt;br /&gt;
    // If you don&#039;t have this variable set you must have plugins directory&lt;br /&gt;
    // with the executable or libvlc_new() will not work!&lt;br /&gt;
    printf(&amp;quot;VLC_PLUGIN_PATH=%s\n&amp;quot;, getenv(&amp;quot;VLC_PLUGIN_PATH&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
    // Initialise libVLC.&lt;br /&gt;
    libvlc = libvlc_new(vlc_argc, vlc_argv);&lt;br /&gt;
    if(NULL == libvlc) {&lt;br /&gt;
        printf(&amp;quot;LibVLC initialization failure.\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    m = libvlc_media_new_path(libvlc, argv[1]);&lt;br /&gt;
    mp = libvlc_media_player_new_from_media(m);&lt;br /&gt;
    libvlc_media_release(m);&lt;br /&gt;
&lt;br /&gt;
    libvlc_video_set_callbacks(mp, lock, unlock, display, &amp;amp;context);&lt;br /&gt;
    libvlc_video_set_format(mp, &amp;quot;RV16&amp;quot;, VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH*2);&lt;br /&gt;
    libvlc_media_player_play(mp);&lt;br /&gt;
&lt;br /&gt;
    // Main loop.&lt;br /&gt;
    while(!done) {&lt;br /&gt;
&lt;br /&gt;
        action = 0;&lt;br /&gt;
&lt;br /&gt;
        // Keys: enter (fullscreen), space (pause), escape (quit).&lt;br /&gt;
        while( SDL_PollEvent( &amp;amp;event )) {&lt;br /&gt;
&lt;br /&gt;
            switch(event.type) {&lt;br /&gt;
                case SDL_QUIT:&lt;br /&gt;
                    done = 1;&lt;br /&gt;
                    break;&lt;br /&gt;
                case SDL_KEYDOWN:&lt;br /&gt;
                    action = event.key.keysym.sym;&lt;br /&gt;
                    break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        switch(action) {&lt;br /&gt;
            case SDLK_ESCAPE:&lt;br /&gt;
            case SDLK_q:&lt;br /&gt;
                done = 1;&lt;br /&gt;
                break;&lt;br /&gt;
            case &#039; &#039;:&lt;br /&gt;
                printf(&amp;quot;Pause toggle.\n&amp;quot;);&lt;br /&gt;
                pause = !pause;&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        if(!pause) { context.n++; }&lt;br /&gt;
&lt;br /&gt;
        SDL_Delay(1000/10);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Stop stream and clean up libVLC.&lt;br /&gt;
    libvlc_media_player_stop(mp);&lt;br /&gt;
    libvlc_media_player_release(mp);&lt;br /&gt;
    libvlc_release(libvlc);&lt;br /&gt;
&lt;br /&gt;
    // Close window and clean up libSDL.&lt;br /&gt;
    SDL_DestroyMutex(context.mutex);&lt;br /&gt;
    SDL_DestroyRenderer(context.renderer);&lt;br /&gt;
&lt;br /&gt;
    quit(0);&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Older API===&lt;br /&gt;
&lt;br /&gt;
This code was used for LibVLC 0.9.x and 1.0.x.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* libSDL and libVLC sample code&lt;br /&gt;
 * Copyright © 2008 Sam Hocevar &amp;lt;sam@zoy.org&amp;gt;&lt;br /&gt;
 * license: [http://en.wikipedia.org/wiki/WTFPL WTFPL] */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SDL.h&amp;gt;&lt;br /&gt;
#include &amp;lt;SDL_mutex.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define WIDTH 640&lt;br /&gt;
#define HEIGHT 480&lt;br /&gt;
&lt;br /&gt;
#define VIDEOWIDTH 320&lt;br /&gt;
#define VIDEOHEIGHT 240&lt;br /&gt;
&lt;br /&gt;
struct ctx&lt;br /&gt;
{&lt;br /&gt;
    SDL_Surface *surf;&lt;br /&gt;
    SDL_mutex *mutex;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
static void catch (libvlc_exception_t *ex)&lt;br /&gt;
{&lt;br /&gt;
    if(libvlc_exception_raised(ex))&lt;br /&gt;
    {&lt;br /&gt;
        fprintf(stderr, &amp;quot;exception: %s\n&amp;quot;, libvlc_exception_get_message(ex));&lt;br /&gt;
        exit(1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    libvlc_exception_clear(ex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#ifdef VLC09X&lt;br /&gt;
static void * lock(struct ctx *ctx)&lt;br /&gt;
{&lt;br /&gt;
    SDL_LockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    return ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
}&lt;br /&gt;
#else&lt;br /&gt;
static void lock(struct ctx *ctx, void **pp_ret)&lt;br /&gt;
{&lt;br /&gt;
    SDL_LockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    *pp_ret = ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
static void unlock(struct ctx *ctx)&lt;br /&gt;
{&lt;br /&gt;
    /* VLC just rendered the video, but we can also render stuff */&lt;br /&gt;
    uint16_t *pixels = (uint16_t *)ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
    int x, y;&lt;br /&gt;
&lt;br /&gt;
    for(y = 10; y &amp;lt; 40; y++)&lt;br /&gt;
        for(x = 10; x &amp;lt; 40; x++)&lt;br /&gt;
            if(x &amp;lt; 13 || y &amp;lt; 13 || x &amp;gt; 36 || y &amp;gt; 36)&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0xffff;&lt;br /&gt;
            else&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0x0;&lt;br /&gt;
&lt;br /&gt;
    SDL_UnlockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    SDL_UnlockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
    char clock[64], cunlock[64], cdata[64];&lt;br /&gt;
    char width[32], height[32], pitch[32];&lt;br /&gt;
    libvlc_exception_t ex;&lt;br /&gt;
    libvlc_instance_t *libvlc;&lt;br /&gt;
    libvlc_media_t *m;&lt;br /&gt;
    libvlc_media_player_t *mp;&lt;br /&gt;
    char const *vlc_argv[] =&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;-q&amp;quot;,&lt;br /&gt;
        //&amp;quot;-vvvvv&amp;quot;,&lt;br /&gt;
        &amp;quot;--plugin-path&amp;quot;, VLC_TREE &amp;quot;/modules&amp;quot;,&lt;br /&gt;
        &amp;quot;--ignore-config&amp;quot;, /* Don&#039;t use VLC&#039;s config files */&lt;br /&gt;
        &amp;quot;--noaudio&amp;quot;,&lt;br /&gt;
        &amp;quot;--vout&amp;quot;, &amp;quot;vmem&amp;quot;,&lt;br /&gt;
        &amp;quot;--vmem-width&amp;quot;, width,&lt;br /&gt;
        &amp;quot;--vmem-height&amp;quot;, height,&lt;br /&gt;
        &amp;quot;--vmem-pitch&amp;quot;, pitch,&lt;br /&gt;
        &amp;quot;--vmem-chroma&amp;quot;, &amp;quot;RV16&amp;quot;,&lt;br /&gt;
        &amp;quot;--vmem-lock&amp;quot;, clock,&lt;br /&gt;
        &amp;quot;--vmem-unlock&amp;quot;, cunlock,&lt;br /&gt;
        &amp;quot;--vmem-data&amp;quot;, cdata,&lt;br /&gt;
    };&lt;br /&gt;
    int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);&lt;br /&gt;
&lt;br /&gt;
    SDL_Surface *screen, *empty;&lt;br /&gt;
    SDL_Event event;&lt;br /&gt;
    SDL_Rect rect;&lt;br /&gt;
    int done = 0, action = 0, pause = 0, n = 0;&lt;br /&gt;
&lt;br /&gt;
    struct ctx ctx;&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libSDL&lt;br /&gt;
     */&lt;br /&gt;
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) == -1)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot initialize SDL\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    empty = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                 32, 0, 0, 0, 0);&lt;br /&gt;
    ctx.surf = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                    16, 0x001f, 0x07e0, 0xf800, 0);&lt;br /&gt;
&lt;br /&gt;
    ctx.mutex = SDL_CreateMutex();&lt;br /&gt;
&lt;br /&gt;
    int options = SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF;&lt;br /&gt;
&lt;br /&gt;
    screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
    if(!screen)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot set video mode\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libVLC&lt;br /&gt;
     */&lt;br /&gt;
    sprintf(clock, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)lock);&lt;br /&gt;
    sprintf(cunlock, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)unlock);&lt;br /&gt;
    sprintf(cdata, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)&amp;amp;ctx);&lt;br /&gt;
    sprintf(width, &amp;quot;%i&amp;quot;, VIDEOWIDTH);&lt;br /&gt;
    sprintf(height, &amp;quot;%i&amp;quot;, VIDEOHEIGHT);&lt;br /&gt;
    sprintf(pitch, &amp;quot;%i&amp;quot;, VIDEOWIDTH * 2);&lt;br /&gt;
&lt;br /&gt;
    if(argc &amp;lt; 2)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;too few arguments (MRL needed)\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
    libvlc_exception_init(&amp;amp;ex);&lt;br /&gt;
    libvlc = libvlc_new(vlc_argc, vlc_argv, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    m = libvlc_media_new(libvlc, argv[1], &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    mp = libvlc_media_player_new_from_media(m, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    libvlc_media_release(m);&lt;br /&gt;
&lt;br /&gt;
    libvlc_media_player_play(mp, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Main loop&lt;br /&gt;
     */&lt;br /&gt;
    rect.w = 0;&lt;br /&gt;
    rect.h = 0;&lt;br /&gt;
&lt;br /&gt;
    while(!done)&lt;br /&gt;
    { &lt;br /&gt;
        action = 0;&lt;br /&gt;
&lt;br /&gt;
        /* Keys: enter (fullscreen), space (pause), escape (quit) */&lt;br /&gt;
        while( SDL_PollEvent( &amp;amp;event ) ) &lt;br /&gt;
        { &lt;br /&gt;
            switch(event.type)&lt;br /&gt;
            {&lt;br /&gt;
            case SDL_QUIT:&lt;br /&gt;
                done = 1;&lt;br /&gt;
                break;&lt;br /&gt;
            case SDL_KEYDOWN:&lt;br /&gt;
                action = event.key.keysym.sym;&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        switch(action)&lt;br /&gt;
        {&lt;br /&gt;
        case SDLK_ESCAPE:&lt;br /&gt;
            done = 1;&lt;br /&gt;
            break;&lt;br /&gt;
        case SDLK_RETURN:&lt;br /&gt;
            options ^= SDL_FULLSCREEN;&lt;br /&gt;
            screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
            break;&lt;br /&gt;
        case &#039; &#039;:&lt;br /&gt;
            pause = !pause;&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rect.x = (int)((1. + .5 * sin(0.03 * n)) * (WIDTH - VIDEOWIDTH) / 2);&lt;br /&gt;
        rect.y = (int)((1. + .5 * cos(0.03 * n)) * (HEIGHT - VIDEOHEIGHT) / 2);&lt;br /&gt;
&lt;br /&gt;
        if(!pause)&lt;br /&gt;
            n++;&lt;br /&gt;
&lt;br /&gt;
        /* Blitting the surface does not prevent it from being locked and&lt;br /&gt;
         * written to by another thread, so we use this additional mutex. */&lt;br /&gt;
        SDL_LockMutex(ctx.mutex);&lt;br /&gt;
        SDL_BlitSurface(ctx.surf, NULL, screen, &amp;amp;rect);&lt;br /&gt;
        SDL_UnlockMutex(ctx.mutex);&lt;br /&gt;
&lt;br /&gt;
        SDL_Flip(screen);&lt;br /&gt;
        SDL_Delay(10);&lt;br /&gt;
&lt;br /&gt;
        SDL_BlitSurface(empty, NULL, screen, &amp;amp;rect);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Stop stream and clean up libVLC&lt;br /&gt;
     */&lt;br /&gt;
    libvlc_media_player_stop(mp, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
&lt;br /&gt;
    libvlc_media_player_release(mp);&lt;br /&gt;
    libvlc_release(libvlc);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Close window and clean up libSDL&lt;br /&gt;
     */&lt;br /&gt;
    SDL_DestroyMutex(ctx.mutex);&lt;br /&gt;
    SDL_FreeSurface(ctx.surf);&lt;br /&gt;
    SDL_FreeSurface(empty);&lt;br /&gt;
&lt;br /&gt;
    SDL_Quit();&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:LibVLC]]&lt;/div&gt;</summary>
		<author><name>Yamanu</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=User:Yamanu&amp;diff=22825</id>
		<title>User:Yamanu</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=User:Yamanu&amp;diff=22825"/>
		<updated>2012-07-13T06:27:25Z</updated>

		<summary type="html">&lt;p&gt;Yamanu: Copyright 0 - 3000 by Yamanu.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Me Yamanu.&lt;/div&gt;</summary>
		<author><name>Yamanu</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Win32Compile&amp;diff=22737</id>
		<title>Win32Compile</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Win32Compile&amp;diff=22737"/>
		<updated>2012-06-22T10:13:18Z</updated>

		<summary type="html">&lt;p&gt;Yamanu: /* Go Back */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to compile {{VLC}} for [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Building Methods&amp;lt;br&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
If you want to build VLC from source, you have several choices: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Method &lt;br /&gt;
! Documentation &lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Cross-compile with Mingw on Linux&#039;&#039;&#039; &lt;br /&gt;
| This page &lt;br /&gt;
| &#039;&#039;&#039;Preferred&#039;&#039;&#039; method (uses cross compilation). On Windows, you should do it in a virtual machine.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Native compilation&#039;&#039;&#039; with &#039;&#039;&#039;[http://www.mingw.org MSYS+MINGW]&#039;&#039;&#039; &lt;br /&gt;
| [[Win32CompileMSYSNew]] &lt;br /&gt;
| &#039;&#039;&#039;Native&#039;&#039;&#039; compilation method. MSYS is a minimal build environment to compile Unixish projects under Microsoft Windows.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Native compilation&#039;&#039;&#039; with &#039;&#039;&#039;cygwin&#039;&#039;&#039; &lt;br /&gt;
| [[Win32CompileCygwinNew]] &lt;br /&gt;
| Build using cygwin as your compile environment. &#039;&#039;&#039;Error&#039;&#039;&#039; prone, and &#039;&#039;&#039;slow&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Obtaining the toolchain  ==&lt;br /&gt;
&lt;br /&gt;
=== Compiler and binary toolchain ===&lt;br /&gt;
&lt;br /&gt;
To compile VLC for Windows (32-bits or 64-bits), the Mingw-w64 toolchain is required:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Debian/Ubuntu&#039;&#039;&#039;: run &amp;lt;code&amp;gt;apt-get install gcc-mingw-w64-i686&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to versions 2.0.x, VLC was compiled with the older mingw32 toolchain, which only supports 32-bits Windows. If you have problems with mingw-w64, you can try mingw32 instead:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Debian/Ubuntu&#039;&#039;&#039;: run &amp;lt;code&amp;gt;apt-get install gcc-mingw32 mingw32-binutils&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Gentoo&#039;&#039;&#039; users can &amp;lt;code&amp;gt;emerge crossdev &amp;amp;amp;&amp;amp;amp; crossdev mingw32&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;ArchLinux&#039;&#039;&#039; users can &amp;lt;code&amp;gt;pacman -S mingw32-gcc&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Fedora&#039;&#039;&#039; users should read [[Win32Compile Under Fedora]]&lt;br /&gt;
* Other &#039;&#039;&#039;Linux&#039;&#039;&#039; systems may attempt http://www.mingw.org/wiki/LinuxCrossMinGW&lt;br /&gt;
* Native-compile with &#039;&#039;&#039;[http://www.mingw.org MSYS+MINGW]&#039;&#039;&#039;, should read the [[Win32CompileMSYSNew|documentation]]&lt;br /&gt;
* Native-compile with &#039;&#039;&#039;[http://www.cygwin.com Cygwin]&#039;&#039;&#039;, should read the [[Win32CompileCygwinNew|documentation]]&lt;br /&gt;
&lt;br /&gt;
=== Development tools ===&lt;br /&gt;
You will also need:&lt;br /&gt;
* lua5.1&lt;br /&gt;
* all autotools: libtool, automake, autoconf, autopoint, make, gettext&lt;br /&gt;
* pkg-config&lt;br /&gt;
* git&lt;br /&gt;
* subversion&lt;br /&gt;
* cmake, cvs if you want to rebuild contribs&lt;br /&gt;
* zip [for creating .zip package], p7zip [for .7z package], nsis [for .exe auto-installer].&lt;br /&gt;
&lt;br /&gt;
=== Host triplet ===&lt;br /&gt;
A number of example commands below include the identifier of the toolchain. This value is &#039;&#039;&#039;essential&#039;&#039;&#039;: it instructs the build system to use the correct toolchain and compile the program for Windows. Without the value, the build system will perform a native compilation for Linux (or whatever your computer runs). With an incorrect value, the build will fail.&lt;br /&gt;
&lt;br /&gt;
This is known as the &#039;&#039;host triplet&#039;&#039;, although it&#039;s more of a pair than a triplet in the case of Mingw. The exact value depends on your installation of the toolchain. Notably on Debian/Ubuntu, these values must be used:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;i686-w64-mingw32&#039;&#039; for Windows 32-bits, using the Mingw-w64 toolchain&lt;br /&gt;
* &#039;&#039;x86_64-w64-mingw32&#039;&#039; for Windows 64-bits, using the Mingw-w64 toolchain&lt;br /&gt;
* &#039;&#039;i586-mingw32msvc&#039;&#039; for Windows 32-bits, using the Mingw32 toolchain&lt;br /&gt;
&lt;br /&gt;
Again, you &#039;&#039;&#039;MUST&#039;&#039;&#039; substitute the value in the following command snippets.&lt;br /&gt;
&lt;br /&gt;
== Get the source code ==&lt;br /&gt;
 $ git clone git://git.videolan.org/vlc.git&lt;br /&gt;
&lt;br /&gt;
== Prepare [[Contrib Status|3rd party libraries]]  ==&lt;br /&gt;
&lt;br /&gt;
Before compiling VLC, you need lots of other libraries. Here is how to get them: &lt;br /&gt;
&lt;br /&gt;
  $ mkdir -p vlc/contrib/win32&lt;br /&gt;
  $ cd vlc/contrib/win32&lt;br /&gt;
  $ ../bootstrap --host=i586-mingw32msvc&lt;br /&gt;
  $ make prebuilt&lt;br /&gt;
&lt;br /&gt;
or, if you want to compile the contribs yourself and are feeling adventurous and have lots of time to burn,&lt;br /&gt;
  # apt-get install subversion yasm cvs cmake&lt;br /&gt;
&lt;br /&gt;
  $ mkdir -p vlc/contrib/win32&lt;br /&gt;
  $ cd vlc/contrib/win32&lt;br /&gt;
  $ ../bootstrap --host=i586-mingw32msvc&lt;br /&gt;
  $ make fetch&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
=== Linux 64-bit ===&lt;br /&gt;
&lt;br /&gt;
If you are on Linux &#039;&#039;&#039;64-bit&#039;&#039;&#039;, you &#039;&#039;&#039;MUST&#039;&#039;&#039; remove some files:&lt;br /&gt;
&lt;br /&gt;
  $ rm -f ../i586-mingw32msvc/bin/moc ../i586-mingw32msvc/bin/uic ../i586-mingw32msvc/bin/rcc&lt;br /&gt;
&lt;br /&gt;
In addition, install the &#039;&#039;qt4-tools&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
=== Fix your contrib path ===&lt;br /&gt;
&lt;br /&gt;
If your Mingw prefix is not &#039;&#039;i586-mingw32msvc&#039;&#039; (you are NOT on Debian or Ubuntu), create a symlink to contribs:&lt;br /&gt;
  $ ln -sf ../i586-mingw32msvc ../i486-mingw32&lt;br /&gt;
&lt;br /&gt;
=== Go Back  ===&lt;br /&gt;
&lt;br /&gt;
Go back to the VLC source directory: &lt;br /&gt;
&lt;br /&gt;
  $ cd ../../&lt;br /&gt;
&lt;br /&gt;
== Configuring the build  ==&lt;br /&gt;
&lt;br /&gt;
=== Bootstrap ===&lt;br /&gt;
First, prepare the tree:&lt;br /&gt;
  $ ./bootstrap&lt;br /&gt;
&lt;br /&gt;
=== Configure ===&lt;br /&gt;
Then you can to configure the build with the &amp;lt;code&amp;gt;./configure&amp;lt;/code&amp;gt; script. &lt;br /&gt;
&lt;br /&gt;
Create a subfolder:&lt;br /&gt;
  $ mkdir win32 &amp;amp;&amp;amp; cd win32&lt;br /&gt;
&lt;br /&gt;
Use the standard configuration: &lt;br /&gt;
 $ ../extras/package/win32/configure.sh --host=i586-mingw32msvc&lt;br /&gt;
&#039;&#039;&#039;NB&#039;&#039;&#039;: use &#039;&#039;&#039;YOUR&#039;&#039;&#039; Xcompiling prefix here, like &#039;&#039;i486-mingw32&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can run configure manually:&lt;br /&gt;
 $ ../configure --host=i586-mingw32msvc&lt;br /&gt;
See &amp;lt;code&amp;gt;&#039;../configure --help&#039;&amp;lt;/code&amp;gt; for more information.&lt;br /&gt;
&lt;br /&gt;
== Building VLC  ==&lt;br /&gt;
&lt;br /&gt;
Once configured, to build VLC, just run:&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
== Packaging VLC ==&lt;br /&gt;
Once the compilation is done, you can build self-contained VLC packages with the following &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; rules: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win-common&amp;lt;/code&amp;gt;&lt;br /&gt;
| Creates a subdirectory named &amp;lt;code&amp;gt;vlc-x.x.x&amp;lt;/code&amp;gt; with all the binaries. You can run VLC directly from this directory.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win-strip&amp;lt;/code&amp;gt; (might be package-win32-strip)&lt;br /&gt;
| Same as above but will create &#039;stripped&#039; binaries (that is, smallest size, unusable with a debugger).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win32-7zip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same as above but will package the directory in a 7z file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win32-zip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same as above but will package the directory in a zip file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win32&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same as above but will also create an auto-installer package. You must have NSIS installed in its default location for this to work.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Well done—you&#039;re ready to use VLC!&#039;&#039;&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
[[Category:Building]]&lt;/div&gt;</summary>
		<author><name>Yamanu</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Win32Compile&amp;diff=22736</id>
		<title>Win32Compile</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Win32Compile&amp;diff=22736"/>
		<updated>2012-06-22T09:38:10Z</updated>

		<summary type="html">&lt;p&gt;Yamanu: /* Prepare 3rd party libraries */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to compile {{VLC}} for [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Building Methods&amp;lt;br&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
If you want to build VLC from source, you have several choices: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Method &lt;br /&gt;
! Documentation &lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Cross-compile with Mingw on Linux&#039;&#039;&#039; &lt;br /&gt;
| This page &lt;br /&gt;
| &#039;&#039;&#039;Preferred&#039;&#039;&#039; method (uses cross compilation). On Windows, you should do it in a virtual machine.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Native compilation&#039;&#039;&#039; with &#039;&#039;&#039;[http://www.mingw.org MSYS+MINGW]&#039;&#039;&#039; &lt;br /&gt;
| [[Win32CompileMSYSNew]] &lt;br /&gt;
| &#039;&#039;&#039;Native&#039;&#039;&#039; compilation method. MSYS is a minimal build environment to compile Unixish projects under Microsoft Windows.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Native compilation&#039;&#039;&#039; with &#039;&#039;&#039;cygwin&#039;&#039;&#039; &lt;br /&gt;
| [[Win32CompileCygwinNew]] &lt;br /&gt;
| Build using cygwin as your compile environment. &#039;&#039;&#039;Error&#039;&#039;&#039; prone, and &#039;&#039;&#039;slow&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Obtaining the toolchain  ==&lt;br /&gt;
&lt;br /&gt;
=== Compiler and binary toolchain ===&lt;br /&gt;
&lt;br /&gt;
To compile VLC for Windows (32-bits or 64-bits), the Mingw-w64 toolchain is required:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Debian/Ubuntu&#039;&#039;&#039;: run &amp;lt;code&amp;gt;apt-get install gcc-mingw-w64-i686&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to versions 2.0.x, VLC was compiled with the older mingw32 toolchain, which only supports 32-bits Windows. If you have problems with mingw-w64, you can try mingw32 instead:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Debian/Ubuntu&#039;&#039;&#039;: run &amp;lt;code&amp;gt;apt-get install gcc-mingw32 mingw32-binutils&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Gentoo&#039;&#039;&#039; users can &amp;lt;code&amp;gt;emerge crossdev &amp;amp;amp;&amp;amp;amp; crossdev mingw32&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;ArchLinux&#039;&#039;&#039; users can &amp;lt;code&amp;gt;pacman -S mingw32-gcc&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Fedora&#039;&#039;&#039; users should read [[Win32Compile Under Fedora]]&lt;br /&gt;
* Other &#039;&#039;&#039;Linux&#039;&#039;&#039; systems may attempt http://www.mingw.org/wiki/LinuxCrossMinGW&lt;br /&gt;
* Native-compile with &#039;&#039;&#039;[http://www.mingw.org MSYS+MINGW]&#039;&#039;&#039;, should read the [[Win32CompileMSYSNew|documentation]]&lt;br /&gt;
* Native-compile with &#039;&#039;&#039;[http://www.cygwin.com Cygwin]&#039;&#039;&#039;, should read the [[Win32CompileCygwinNew|documentation]]&lt;br /&gt;
&lt;br /&gt;
=== Development tools ===&lt;br /&gt;
You will also need:&lt;br /&gt;
* lua5.1&lt;br /&gt;
* all autotools: libtool, automake, autoconf, autopoint, make, gettext&lt;br /&gt;
* pkg-config&lt;br /&gt;
* git&lt;br /&gt;
* subversion&lt;br /&gt;
* cmake, cvs if you want to rebuild contribs&lt;br /&gt;
* zip [for creating .zip package], p7zip [for .7z package], nsis [for .exe auto-installer].&lt;br /&gt;
&lt;br /&gt;
=== Host triplet ===&lt;br /&gt;
A number of example commands below include the identifier of the toolchain. This value is &#039;&#039;&#039;essential&#039;&#039;&#039;: it instructs the build system to use the correct toolchain and compile the program for Windows. Without the value, the build system will perform a native compilation for Linux (or whatever your computer runs). With an incorrect value, the build will fail.&lt;br /&gt;
&lt;br /&gt;
This is known as the &#039;&#039;host triplet&#039;&#039;, although it&#039;s more of a pair than a triplet in the case of Mingw. The exact value depends on your installation of the toolchain. Notably on Debian/Ubuntu, these values must be used:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;i686-w64-mingw32&#039;&#039; for Windows 32-bits, using the Mingw-w64 toolchain&lt;br /&gt;
* &#039;&#039;x86_64-w64-mingw32&#039;&#039; for Windows 64-bits, using the Mingw-w64 toolchain&lt;br /&gt;
* &#039;&#039;i586-mingw32msvc&#039;&#039; for Windows 32-bits, using the Mingw32 toolchain&lt;br /&gt;
&lt;br /&gt;
Again, you &#039;&#039;&#039;MUST&#039;&#039;&#039; substitute the value in the following command snippets.&lt;br /&gt;
&lt;br /&gt;
== Get the source code ==&lt;br /&gt;
 $ git clone git://git.videolan.org/vlc.git&lt;br /&gt;
&lt;br /&gt;
== Prepare [[Contrib Status|3rd party libraries]]  ==&lt;br /&gt;
&lt;br /&gt;
Before compiling VLC, you need lots of other libraries. Here is how to get them: &lt;br /&gt;
&lt;br /&gt;
  $ mkdir -p vlc/contrib/win32&lt;br /&gt;
  $ cd vlc/contrib/win32&lt;br /&gt;
  $ ../bootstrap --host=i586-mingw32msvc&lt;br /&gt;
  $ make prebuilt&lt;br /&gt;
&lt;br /&gt;
or, if you want to compile the contribs yourself and are feeling adventurous and have lots of time to burn,&lt;br /&gt;
  # apt-get install subversion yasm cvs cmake&lt;br /&gt;
&lt;br /&gt;
  $ mkdir -p vlc/contrib/win32&lt;br /&gt;
  $ cd vlc/contrib/win32&lt;br /&gt;
  $ ../bootstrap --host=i586-mingw32msvc&lt;br /&gt;
  $ make fetch&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
=== Linux 64-bit ===&lt;br /&gt;
&lt;br /&gt;
If you are on Linux &#039;&#039;&#039;64-bit&#039;&#039;&#039;, you &#039;&#039;&#039;MUST&#039;&#039;&#039; remove some files:&lt;br /&gt;
&lt;br /&gt;
  $ rm -f ../i586-mingw32msvc/bin/moc ../i586-mingw32msvc/bin/uic ../i586-mingw32msvc/bin/rcc&lt;br /&gt;
&lt;br /&gt;
In addition, install the &#039;&#039;qt4-tools&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
=== Fix your contrib path ===&lt;br /&gt;
&lt;br /&gt;
If your Mingw prefix is not &#039;&#039;i586-mingw32msvc&#039;&#039; (you are NOT on Debian or Ubuntu), create a symlink to contribs:&lt;br /&gt;
  $ ln -sf ../i586-mingw32msvc ../i486-mingw32&lt;br /&gt;
&lt;br /&gt;
=== Go Back  ===&lt;br /&gt;
&lt;br /&gt;
Go back to the VLC source directory: &lt;br /&gt;
&lt;br /&gt;
  $ cd -&lt;br /&gt;
&lt;br /&gt;
== Configuring the build  ==&lt;br /&gt;
&lt;br /&gt;
=== Bootstrap ===&lt;br /&gt;
First, prepare the tree:&lt;br /&gt;
  $ ./bootstrap&lt;br /&gt;
&lt;br /&gt;
=== Configure ===&lt;br /&gt;
Then you can to configure the build with the &amp;lt;code&amp;gt;./configure&amp;lt;/code&amp;gt; script. &lt;br /&gt;
&lt;br /&gt;
Create a subfolder:&lt;br /&gt;
  $ mkdir win32 &amp;amp;&amp;amp; cd win32&lt;br /&gt;
&lt;br /&gt;
Use the standard configuration: &lt;br /&gt;
 $ ../extras/package/win32/configure.sh --host=i586-mingw32msvc&lt;br /&gt;
&#039;&#039;&#039;NB&#039;&#039;&#039;: use &#039;&#039;&#039;YOUR&#039;&#039;&#039; Xcompiling prefix here, like &#039;&#039;i486-mingw32&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can run configure manually:&lt;br /&gt;
 $ ../configure --host=i586-mingw32msvc&lt;br /&gt;
See &amp;lt;code&amp;gt;&#039;../configure --help&#039;&amp;lt;/code&amp;gt; for more information.&lt;br /&gt;
&lt;br /&gt;
== Building VLC  ==&lt;br /&gt;
&lt;br /&gt;
Once configured, to build VLC, just run:&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
== Packaging VLC ==&lt;br /&gt;
Once the compilation is done, you can build self-contained VLC packages with the following &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; rules: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win-common&amp;lt;/code&amp;gt;&lt;br /&gt;
| Creates a subdirectory named &amp;lt;code&amp;gt;vlc-x.x.x&amp;lt;/code&amp;gt; with all the binaries. You can run VLC directly from this directory.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win-strip&amp;lt;/code&amp;gt; (might be package-win32-strip)&lt;br /&gt;
| Same as above but will create &#039;stripped&#039; binaries (that is, smallest size, unusable with a debugger).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win32-7zip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same as above but will package the directory in a 7z file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win32-zip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same as above but will package the directory in a zip file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win32&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same as above but will also create an auto-installer package. You must have NSIS installed in its default location for this to work.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Well done—you&#039;re ready to use VLC!&#039;&#039;&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
[[Category:Building]]&lt;/div&gt;</summary>
		<author><name>Yamanu</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Win32Compile&amp;diff=22735</id>
		<title>Win32Compile</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Win32Compile&amp;diff=22735"/>
		<updated>2012-06-22T09:29:42Z</updated>

		<summary type="html">&lt;p&gt;Yamanu: /* Prepare 3rd party libraries */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to compile {{VLC}} for [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Building Methods&amp;lt;br&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
If you want to build VLC from source, you have several choices: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Method &lt;br /&gt;
! Documentation &lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Cross-compile with Mingw on Linux&#039;&#039;&#039; &lt;br /&gt;
| This page &lt;br /&gt;
| &#039;&#039;&#039;Preferred&#039;&#039;&#039; method (uses cross compilation). On Windows, you should do it in a virtual machine.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Native compilation&#039;&#039;&#039; with &#039;&#039;&#039;[http://www.mingw.org MSYS+MINGW]&#039;&#039;&#039; &lt;br /&gt;
| [[Win32CompileMSYSNew]] &lt;br /&gt;
| &#039;&#039;&#039;Native&#039;&#039;&#039; compilation method. MSYS is a minimal build environment to compile Unixish projects under Microsoft Windows.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Native compilation&#039;&#039;&#039; with &#039;&#039;&#039;cygwin&#039;&#039;&#039; &lt;br /&gt;
| [[Win32CompileCygwinNew]] &lt;br /&gt;
| Build using cygwin as your compile environment. &#039;&#039;&#039;Error&#039;&#039;&#039; prone, and &#039;&#039;&#039;slow&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Obtaining the toolchain  ==&lt;br /&gt;
&lt;br /&gt;
=== Compiler and binary toolchain ===&lt;br /&gt;
&lt;br /&gt;
To compile VLC for Windows (32-bits or 64-bits), the Mingw-w64 toolchain is required:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Debian/Ubuntu&#039;&#039;&#039;: run &amp;lt;code&amp;gt;apt-get install gcc-mingw-w64-i686&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to versions 2.0.x, VLC was compiled with the older mingw32 toolchain, which only supports 32-bits Windows. If you have problems with mingw-w64, you can try mingw32 instead:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Debian/Ubuntu&#039;&#039;&#039;: run &amp;lt;code&amp;gt;apt-get install gcc-mingw32 mingw32-binutils&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Gentoo&#039;&#039;&#039; users can &amp;lt;code&amp;gt;emerge crossdev &amp;amp;amp;&amp;amp;amp; crossdev mingw32&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;ArchLinux&#039;&#039;&#039; users can &amp;lt;code&amp;gt;pacman -S mingw32-gcc&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Fedora&#039;&#039;&#039; users should read [[Win32Compile Under Fedora]]&lt;br /&gt;
* Other &#039;&#039;&#039;Linux&#039;&#039;&#039; systems may attempt http://www.mingw.org/wiki/LinuxCrossMinGW&lt;br /&gt;
* Native-compile with &#039;&#039;&#039;[http://www.mingw.org MSYS+MINGW]&#039;&#039;&#039;, should read the [[Win32CompileMSYSNew|documentation]]&lt;br /&gt;
* Native-compile with &#039;&#039;&#039;[http://www.cygwin.com Cygwin]&#039;&#039;&#039;, should read the [[Win32CompileCygwinNew|documentation]]&lt;br /&gt;
&lt;br /&gt;
=== Development tools ===&lt;br /&gt;
You will also need:&lt;br /&gt;
* lua5.1&lt;br /&gt;
* all autotools: libtool, automake, autoconf, autopoint, make, gettext&lt;br /&gt;
* pkg-config&lt;br /&gt;
* git&lt;br /&gt;
* subversion&lt;br /&gt;
* cmake, cvs if you want to rebuild contribs&lt;br /&gt;
* zip [for creating .zip package], p7zip [for .7z package], nsis [for .exe auto-installer].&lt;br /&gt;
&lt;br /&gt;
=== Host triplet ===&lt;br /&gt;
A number of example commands below include the identifier of the toolchain. This value is &#039;&#039;&#039;essential&#039;&#039;&#039;: it instructs the build system to use the correct toolchain and compile the program for Windows. Without the value, the build system will perform a native compilation for Linux (or whatever your computer runs). With an incorrect value, the build will fail.&lt;br /&gt;
&lt;br /&gt;
This is known as the &#039;&#039;host triplet&#039;&#039;, although it&#039;s more of a pair than a triplet in the case of Mingw. The exact value depends on your installation of the toolchain. Notably on Debian/Ubuntu, these values must be used:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;i686-w64-mingw32&#039;&#039; for Windows 32-bits, using the Mingw-w64 toolchain&lt;br /&gt;
* &#039;&#039;x86_64-w64-mingw32&#039;&#039; for Windows 64-bits, using the Mingw-w64 toolchain&lt;br /&gt;
* &#039;&#039;i586-mingw32msvc&#039;&#039; for Windows 32-bits, using the Mingw32 toolchain&lt;br /&gt;
&lt;br /&gt;
Again, you &#039;&#039;&#039;MUST&#039;&#039;&#039; substitute the value in the following command snippets.&lt;br /&gt;
&lt;br /&gt;
== Get the source code ==&lt;br /&gt;
 $ git clone git://git.videolan.org/vlc.git&lt;br /&gt;
&lt;br /&gt;
== Prepare [[Contrib Status|3rd party libraries]]  ==&lt;br /&gt;
&lt;br /&gt;
Before compiling VLC, you need lots of other libraries. Here is how to get them: &lt;br /&gt;
&lt;br /&gt;
  $ cd vlc&lt;br /&gt;
  $ mkdir -p contrib/win32&lt;br /&gt;
  $ cd contrib/win32&lt;br /&gt;
  $ ../bootstrap --host=i586-mingw32msvc&lt;br /&gt;
  $ make prebuilt&lt;br /&gt;
&lt;br /&gt;
or, if you want to compile the contribs yourself and are feeling adventurous and have lots of time to burn,&lt;br /&gt;
  # apt-get install subversion yasm cvs cmake&lt;br /&gt;
&lt;br /&gt;
  $ mkdir -p contrib/win32&lt;br /&gt;
  $ cd contrib/win32&lt;br /&gt;
  $ ../bootstrap --host=i586-mingw32msvc&lt;br /&gt;
  $ make fetch&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
=== Linux 64-bit ===&lt;br /&gt;
&lt;br /&gt;
If you are on Linux &#039;&#039;&#039;64-bit&#039;&#039;&#039;, you &#039;&#039;&#039;MUST&#039;&#039;&#039; remove some files:&lt;br /&gt;
&lt;br /&gt;
  $ rm -f ../i586-mingw32msvc/bin/moc ../i586-mingw32msvc/bin/uic ../i586-mingw32msvc/bin/rcc&lt;br /&gt;
&lt;br /&gt;
In addition, install the &#039;&#039;qt4-tools&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
=== Fix your contrib path ===&lt;br /&gt;
&lt;br /&gt;
If your Mingw prefix is not &#039;&#039;i586-mingw32msvc&#039;&#039; (you are NOT on Debian or Ubuntu), create a symlink to contribs:&lt;br /&gt;
  $ ln -sf ../i586-mingw32msvc ../i486-mingw32&lt;br /&gt;
&lt;br /&gt;
=== Go Back  ===&lt;br /&gt;
&lt;br /&gt;
Go back to the VLC source directory: &lt;br /&gt;
&lt;br /&gt;
  $ cd -&lt;br /&gt;
&lt;br /&gt;
== Configuring the build  ==&lt;br /&gt;
&lt;br /&gt;
=== Bootstrap ===&lt;br /&gt;
First, prepare the tree:&lt;br /&gt;
  $ ./bootstrap&lt;br /&gt;
&lt;br /&gt;
=== Configure ===&lt;br /&gt;
Then you can to configure the build with the &amp;lt;code&amp;gt;./configure&amp;lt;/code&amp;gt; script. &lt;br /&gt;
&lt;br /&gt;
Create a subfolder:&lt;br /&gt;
  $ mkdir win32 &amp;amp;&amp;amp; cd win32&lt;br /&gt;
&lt;br /&gt;
Use the standard configuration: &lt;br /&gt;
 $ ../extras/package/win32/configure.sh --host=i586-mingw32msvc&lt;br /&gt;
&#039;&#039;&#039;NB&#039;&#039;&#039;: use &#039;&#039;&#039;YOUR&#039;&#039;&#039; Xcompiling prefix here, like &#039;&#039;i486-mingw32&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can run configure manually:&lt;br /&gt;
 $ ../configure --host=i586-mingw32msvc&lt;br /&gt;
See &amp;lt;code&amp;gt;&#039;../configure --help&#039;&amp;lt;/code&amp;gt; for more information.&lt;br /&gt;
&lt;br /&gt;
== Building VLC  ==&lt;br /&gt;
&lt;br /&gt;
Once configured, to build VLC, just run:&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
== Packaging VLC ==&lt;br /&gt;
Once the compilation is done, you can build self-contained VLC packages with the following &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; rules: &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command &lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win-common&amp;lt;/code&amp;gt;&lt;br /&gt;
| Creates a subdirectory named &amp;lt;code&amp;gt;vlc-x.x.x&amp;lt;/code&amp;gt; with all the binaries. You can run VLC directly from this directory.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win-strip&amp;lt;/code&amp;gt; (might be package-win32-strip)&lt;br /&gt;
| Same as above but will create &#039;stripped&#039; binaries (that is, smallest size, unusable with a debugger).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win32-7zip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same as above but will package the directory in a 7z file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win32-zip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same as above but will package the directory in a zip file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;make package-win32&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same as above but will also create an auto-installer package. You must have NSIS installed in its default location for this to work.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Well done—you&#039;re ready to use VLC!&#039;&#039;&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
[[Category:Building]]&lt;/div&gt;</summary>
		<author><name>Yamanu</name></author>
	</entry>
</feed>