Воспроизведение видео в SDL 2.0.4 (Theora)
Я использую: UBUNTU 14.04 + SDL 2.0.4 + Code:: Blocks 13.12 - (C++) - связано с libtheora.a (v.1.1.1)
ЦЕЛЬ: чтобы иметь возможность воспроизводить (декодировать) видео Ogg Theora в приложении SDL2.
Я мог бы использовать библиотеку ffmpeg. Но есть проблемы с лицензиями, потому что они используют MPEG... и т.д...
Итак, я выбрал библиотеку Ogg Theora с http://www.theora.org/ так как она "запатентована бесплатно".
(Они имеют простую и очень разрешительную лицензию, не используют "проприетарные" кодеки).
Я искал в Интернете очень простой пример воспроизведения видео SDL2 + Ogg Theora на C++, мне не нужно декодировать аудио, только видео, в моем случае, и отправлять на SDL2 (возможно, на текстуру?...). Но я не могу найти ничего связанного. Я нашел только какой-то "грязный" код, даже если это не сработало.
Кто-нибудь может поделиться фрагментом кода (любое решение / любые советы / другие идеи)?...
Код, который я до сих пор...
(В этом тестировании я использую "theoraplay.h" - https://icculus.org/theoraplay - на данный момент)
// My project linkage:
-lSDL2
-lSDL2_image
-lSDL2_mixer
-logg
-lvorbis
-lvorbisenc
-lvorbisfile
-ltheora
-ltheoraenc
-ltheoradec
// SDL2:
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_mixer.h>
// OGG Library: (The multimedia wrapper)
#include "ogg/ogg.h"
// VORBIS Library: (Audio)
#include "vorbis/codec.h"
#include "vorbis/vorbisenc.h"
#include "vorbis/vorbisfile.h"
// THEORA Library: (Video)
#include "theora/theora.h"
#include "theora/theoraenc.h"
#include "theora/theoradec.h"
// The "framework" for Ogg Theora video play, from: https://icculus.org/theoraplay
// I'm Testing it...
#include "theoraplay.h"
// SDL2 - Objects:
SDL_Surface* surface;
SDL_Texture* texture;
SDL_Rect rectangle;
// THEORAPLAY - Objects:
THEORAPLAY_Decoder* decoder = NULL; // Will return a Link error... Why?...
const THEORAPLAY_VideoFrame* video = NULL; // No issues (Links and runs ok)
const THEORAPLAY_AudioPacket* audio = NULL; // No issues (Links and runs ok)
int main(int args, char* argv[]){
// (SDL2 code to create the window, renderer, events, etc, goes here...)
surface = IMG_Load("images/example.png"); // Load an image.
texture = SDL_CreateTextureFromSurface(renderer, temp); // Pass the image into a texture.
// "ERROR" - LOG says: undefined reference to "THEORAPLAY_startDecodeFile"...
decoder = THEORAPLAY_startDecodeFile("bunny.ogg", 20, THEORAPLAY_VIDFMT_YV12);
// "bunny.ogg" - Ogg video from: https://peach.blender.org/download
// SDL2: Here, will be added the code to pass THEORA frames into a SDL2 streaming texture...
while(!quit){
// Render everything:
SDL_RenderCopy(renderer, texture, NULL, &rectangle);
};
};