# Include video using SDL

**URL:** <https://discourse.libsdl.org/t/include-video-using-sdl/24640>\
**Category:** Game Development\
**Created:** [July 1, 2018, 4:48am UTC](https://discourse.libsdl.org/t/include-video-using-sdl/24640 "2018-07-01T04:48:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LastBlow](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/l/cdc98d/32.png) [@LastBlow](https://discourse.libsdl.org/u/LastBlow)\
**Post date:** [July 1, 2018, 4:48am UTC](https://discourse.libsdl.org/t/include-video-using-sdl/24640/1 "2018-07-01T04:48:21Z")

</div>

Hi, second post here!

Been reading png files in SDL and using them as textures…

Now, would like to include in my game 2 short videos made in Blender, in dvi and mp4 formats.  
Is it possible to do so using SDL and how, please?

Thank you! ;-)))

---

<div class="post-metadata">

**Author:** ![Blerg](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/b/c77e96/32.png) [@Blerg](https://discourse.libsdl.org/u/Blerg)\
**Post date:** [July 1, 2018, 8:09pm UTC](https://discourse.libsdl.org/t/include-video-using-sdl/24640/2 "2018-07-01T20:09:13Z")

</div>

It’s a bit more complex than decoding a PNG and displaying it on the screen. You basically have to decode each frame using a decoder library, and then display each frame of the video to the screen in a timely manner that is similar to what the video is supposed to be playing at. This is a very complex operation that will take a bit of work for you to create.

There are a couple of samples that might help, (you’ll need to swap out the Theora decoding out for the format you want to use): [TheoraPlay](https://icculus.org/theoraplay/)

Other than that, Google is your friend: [sdl2 video player](https://www.google.com/search?ei=CWI4W-mYDMaQsAWCr7nQBg&q=sdl2+video+player&oq=sdl2+video+player&gs_l=psy-ab.3..0.26503.28256.0.28508.4.4.0.0.0.0.201.533.1j2j1.4.0....0...1.1.64.psy-ab..0.4.530...0i67k1j0i7i30k1.0.WIBrOqtAtw0)

---

<div class="post-metadata">

**Author:** ![LastBlow](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/l/cdc98d/32.png) [@LastBlow](https://discourse.libsdl.org/u/LastBlow)\
**Post date:** [July 10, 2018, 6:22pm UTC](https://discourse.libsdl.org/t/include-video-using-sdl/24640/3 "2018-07-10T18:22:03Z")

</div>

Thank you very much for your support!

video.cpp here attached plays a mp4 video whose codecs appear below.

Based on [http://dranger.com/ffmpeg](http://dranger.com/ffmpeg), running Windows x64, Visual Studio 2015, SDL2, ffmpeg 4.0 and C++.

Hope it helps!

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘crawl.mp4’:  
Metadata:  
major\_brand : isom  
minor\_version : 512  
compatible\_brands: isomiso2avc1mp41  
creation\_time : 1970-01-01T00:00:00.000000Z  
Duration: 00:00:29.00, start: 0.000000, bitrate: 689 kb/s  
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1344x680, 612 kb/s, 10 fps, 10 tbr, 10 tbn, 20 tbc (default)  
Metadata:  
creation\_time : 1970-01-01T00:00:00.000000Z  
handler\_name : VideoHandler  
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 75 kb/s (default)  
Metadata:  
creation\_time : 1970-01-01T00:00:00.000000Z  
handler\_name : SoundHandler  
screen final size: 1344x680

[video.cpp](https://discourse.libsdl.org/uploads/default/original/2X/a/ae0ac8437b679ca56d858e1038274d3624fad721.cpp) (19.8 KB)
