Advertisement

SDL: playing videos

Started by April 30, 2012 11:28 AM
4 comments, last by MichaelBarth 12 years, 7 months ago
I've been trying to figure out how to play videos in SDL for a while now, and I cam across libtheora for playing OGV files. I can't figure out how to use it and pipe a result to SDL. If someone could point me into the direction of a cross platform library or a tutorial for libtheora that shows how to open a file, decode it and pipe it to SDL. I've searched and searched for such a tutorial and I couldn't find one. Doing this with SDL_OpenGL would be even better. I know there's SMPEG and FFMPEG, and I've tried them, and I couldn't get them to work because of a lack of a proper tutorial. I don't care what video format I'd have to use, so long as I can convert a video into that format and keep the original quality.

Any help is appreciated.
There's a simular topic here:
http://www.gamedev.net/topic/348340-play-video-files-in-sdl/

the best post in there being this:



I'll refer you to my new post here at this thread, Link66.
Advertisement
Just out of curiosity, will these videos have audio in them that you want to play as well? Do you need to be able to seek in the video, or do you just want to open and play it? It sounds like you have control over the videos, which will help a lot (because two videos that appear the same can have different file contents, and playing one video correctly can be a much larger pain in the butt than the other one, depending on various factors I won't bore you with). These things have a big impact on how robust your player needs to be.

For what it's worth, I haven't ever written anything that used libtheora or libvpx. I've written a few programs that use FFmpeg to decode a video, and I'm in the process of writing a reader that reads both audio and video, so I could help with FFmpeg code if you haven't given up yet on it. I've never used SDL though, but I could tell you how to decode frames in FFmpeg, how they're represented, and how to properly copy the frame buffers to another buffer (which would probably be an SDL buffer, though I don't know SDL). Let me know if this would be useful to you or not.

As a side note, this site has a FFmpeg tutorial that creates an SDL video player. I'll be the first to warn you that the site is a bit old and some of the things they do have been deprecated, but for the most part it could help give a lot of direction.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

There's a simular topic here:
http://www.gamedev.n...o-files-in-sdl/

the best post in there being this:


[quote name='Drew_Benton' timestamp='1128162726' post='3282104']
I'll refer you to my new post here at this thread, Link66.

[/quote]
Actually I made my decision of FFMPEG because I didn't get an answer here for quite some time. And I've seen that, but the links are dead, and the example he gives is in C++.


Just out of curiosity, will these videos have audio in them that you want to play as well? Do you need to be able to seek in the video, or do you just want to open and play it? It sounds like you have control over the videos, which will help a lot (because two videos that appear the same can have different file contents, and playing one video correctly can be a much larger pain in the butt than the other one, depending on various factors I won't bore you with). These things have a big impact on how robust your player needs to be.

For what it's worth, I haven't ever written anything that used libtheora or libvpx. I've written a few programs that use FFmpeg to decode a video, and I'm in the process of writing a reader that reads both audio and video, so I could help with FFmpeg code if you haven't given up yet on it. I've never used SDL though, but I could tell you how to decode frames in FFmpeg, how they're represented, and how to properly copy the frame buffers to another buffer (which would probably be an SDL buffer, though I don't know SDL). Let me know if this would be useful to you or not.

As a side note, this site has a FFmpeg tutorial that creates an SDL video player. I'll be the first to warn you that the site is a bit old and some of the things they do have been deprecated, but for the most part it could help give a lot of direction.


You actually answered my question about playing videos with FFMPEG in my thread where I ended up having to use malloc on a pointer. I decided on FFMPEG once I got it to work, and this thread is from April 30th, and I got no replies until now, so I gave up and searched the net for a few hours and got FFMPEG working.

You actually answered my question about playing videos with FFMPEG in my thread where I ended up having to use malloc on a pointer. I decided on FFMPEG once I got it to work, and this thread is from April 30th, and I got no replies until now, so I gave up and searched the net for a few hours and got FFMPEG working.

Oh wow, I didn't even realize. I just saw falconmick replied today so I figured it was a new thread from today. Teach me to read the dates biggrin.png
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

[quote name='Spirrwell' timestamp='1336503867' post='4938460']
You actually answered my question about playing videos with FFMPEG in my thread where I ended up having to use malloc on a pointer. I decided on FFMPEG once I got it to work, and this thread is from April 30th, and I got no replies until now, so I gave up and searched the net for a few hours and got FFMPEG working.

Oh wow, I didn't even realize. I just saw falconmick replied today so I figured it was a new thread from today. Teach me to read the dates biggrin.png
[/quote]

Nah, it's fine, I just didn't expect to get a reply. I've asked other questions before and have gotten no reply. Thank you all the same.

This topic is closed to new replies.

Advertisement