Video Playback Library

Is there any library to play videos in SDL?

I could only find very old posts and/or half answers.

Thanks,
Francisco

I don’t know of a library as such, but I would be happy to be corrected. The only common video encoding format that SDL2 can play natively (i.e. without an additional codec) is UYVY, which corresponds to SDL_PIXELFORMAT_UYVY. If it’s acceptable to convert your video into this format you can play it quite easily - the pictures anyway!

Here’s a demo of SDL2 playing a short QuickTime video in this format (it loops).

To play a video in one of the more common heavily-compressed formats such as MPEG2 or h264 you would need a suitable codec to decode the frames into picture and sound chunks that SDL can understand. These will typically be UYVY for the pictures and uncompressed PCM for the sound.

You can use ffmpeg libraries to play videos.
As an example, ffplay (included in ffmpeg project), uses SDL:
https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/fftools/ffplay.c

There is this tutorial (a bit outdated, but shows a bit of ffmpeg api):
https://www.codeproject.com/tips/111468/ffmpeg-tutorial

I’m using pl_mpeg in my project.