![]() |
CRM64Pro GDK v0.18.0
A free cross-platform game development kit built on top of SDL 3.0
|
Video Manager and Video objects for FFmpeg-based playback and rendering [v26.06.1].
The Video module provides playback of movie files using the bundled FFmpeg libraries. It decodes video frames, uploads them to SDL textures and renders them through the same rendering path used by the graphics modules. Audio streams are decoded separately and routed through AudioTrack so they participate in the engine audio tag and volume system.
The active FFmpeg project is intentionally small and enables only the formats needed by the current backend:
| Containers | MOV/MP4, AVI and raw H.264 streams |
|---|---|
| Video codecs | H.264 |
| Audio codecs | AAC, MP3 and PCM S16LE |
| Protocols | File protocol only |
Video CDC resources are stored as a small CRM64Pro video metadata header followed by the original media payload. The payload is written through Archive::blockAddStream() and read through Archive::blockOpenStream(), so large videos are saved and played without buffering the full media file in memory. Videos loaded from CDC can also be saved back to CDC archives; the metadata header is rebuilt from the current Video object and the original payload is streamed.
| Video::play() | Starts playback and optionally configures extra repeats |
|---|---|
| Video::pause() | Pauses video and linked audio playback |
| Video::resume() | Resumes playback from a paused state |
| Video::stop() | Stops playback and resets the position to the beginning |
| Video::seek() | Seeks to a specific playback position in milliseconds |
| Video::decodeFrameAt() | Decodes one frame to an ARGB8888 SDL_Surface for import tools and offline processing |
Videos are rendered automatically during the engine render phase once playback starts:
| Video::setTarget() | Selects the screen used for automatic rendering |
|---|---|
| Video::setViewport() | Sets the target viewport, or uses the automatic native-size viewport when omitted |
| Video::setSourceViewport() | Sets the source crop viewport, or uses the full video frame when omitted |
| Video::setRenderEx() | Sets rotation, center point and flip options used by automatic rendering |
This is a standard object manager. Each loaded video has its own decode state, playback position, SDL texture and optional linked AudioTrack stream.
Classes | |
| struct | CRM64Pro::VideoInfo |
| Video metadata and statistics. More... | |
| class | CRM64Pro::Video |
| Video Object class. More... | |
| class | CRM64Pro::VideoMgr |
| Video Manager class. More... | |
Functions | |
| bool | CRM64Pro::Video::info (Sint32 iMode=0) override |
| Request Video object information. | |
| const string & | CRM64Pro::Video::getName () const override |
| Get the name. | |
| Sint32 | CRM64Pro::Video::getID () const override |
| Get the ID. | |
| Sint32 | CRM64Pro::Video::play (Sint32 iRepeats=0) |
| Play the video. | |
| bool | CRM64Pro::Video::pause () |
| Pause the video playback. | |
| bool | CRM64Pro::Video::resume () |
| Resume video from a paused state. | |
| bool | CRM64Pro::Video::stop () |
| Stop video playback and reset to the beginning. | |
| ePlaybackStatus | CRM64Pro::Video::status () const |
| Get the video status. | |
| Sint32 | CRM64Pro::Video::getDuration () const |
| Get total duration. | |
| Sint32 | CRM64Pro::Video::getPlaybackPosition () const |
| Get current playback position. | |
| bool | CRM64Pro::Video::seek (Sint32 iTimeMS) |
| Seek to a playback position. | |
| Uint64 | CRM64Pro::Video::getFrameCount () const |
| Get total frame count. | |
| Uint64 | CRM64Pro::Video::getFrameCurrent () const |
| Get current frame index. | |
| Sint32 | CRM64Pro::Video::getWidth () const |
| Get the native video width. | |
| Sint32 | CRM64Pro::Video::getHeight () const |
| Get the native video height. | |
| bool | CRM64Pro::Video::setBlendMode (SDL_BlendMode bmValue) |
| Set the alpha blending mode. | |
| SDL_BlendMode | CRM64Pro::Video::getBlendMode () const |
| Get the alpha blending mode. | |
| bool | CRM64Pro::Video::setAlphaMod (Sint32 iAlpha) |
| Set the alpha modulation value. | |
| Sint32 | CRM64Pro::Video::getAlphaMod () const |
| Get the alpha modulation value. | |
| bool | CRM64Pro::Video::setColorMod (Uint8 iR, Uint8 iG, Uint8 iB) |
| Set the color modulation value. | |
| Sint32 | CRM64Pro::Video::getColorMod (Uint8 &iR, Uint8 &iG, Uint8 &iB) const |
| Get the color modulation value. | |
| bool | CRM64Pro::Video::setTag (eAudioTrackTag eTag) |
| Set video audio tag category. | |
| eAudioTrackTag | CRM64Pro::Video::getTag () const |
| Get video audio tag category. | |
| bool | CRM64Pro::Video::hasAudio () const |
| Check if the video media contains an audio stream. | |
| bool | CRM64Pro::Video::hasAudioError () const |
| Check if video audio playback was dropped after a runtime audio failure. | |
| bool | CRM64Pro::Video::getInfo (VideoInfo *pVI) const |
| Get video detailed information. | |
| Sint32 | CRM64Pro::Video::decodeFrameAt (Sint32 iTimeMS, SDL_Surface **ppSurface) |
| Decode and copy one video frame at or near a timestamp. | |
| Sint32 | CRM64Pro::Video::save (const string &sCDCFile, const string &sResourceName="") |
| Save the Video into a CDC file. | |
| Sint32 | CRM64Pro::Video::save (Sint32 idCDC, const string &sResourceName="") |
| Save the Video into a CDC file. | |
| Sint32 | CRM64Pro::Video::saveToFile (const string &sFile) const |
| Export the Video to an external file. | |
| bool | CRM64Pro::Video::setTarget (Sint32 idRes=0) |
| Set the video render target. | |
| bool | CRM64Pro::Video::setViewport (const SDL_FRect *pRect=nullptr) |
| Set the target viewport used for automatic video rendering. | |
| bool | CRM64Pro::Video::setSourceViewport (const SDL_FRect *pRect=nullptr) |
| Set the source viewport used for automatic video rendering. | |
| bool | CRM64Pro::Video::setRenderEx (double dAngle=0.0, const SDL_FPoint *pCenter=nullptr, SDL_FlipMode rf=SDL_FLIP_NONE) |
| Set extended render attributes used for automatic video rendering. | |
| bool | CRM64Pro::VideoMgr::info (Sint32 iMode=0) override |
| Request Video Manager information. | |
| Sint32 | CRM64Pro::VideoMgr::close (Sint32 idVideo=0) override |
| Close and destroy a video object. | |
| Sint32 | CRM64Pro::VideoMgr::getCount () const override |
| Get number of loaded objects. | |
| Sint32 | CRM64Pro::VideoMgr::setName (Sint32 idVideo, const string &sName) override |
| Change the object name. | |
| Video * | CRM64Pro::VideoMgr::get (Sint32 idVideo) |
| Get a pointer to the video using its handle. | |
| Sint32 | CRM64Pro::VideoMgr::loadFromFile (const string &sFile, const string &sName="", eAudioTrackTag eTag=ATT_MUSIC) |
| Load a video from an external file. | |
| Sint32 | CRM64Pro::VideoMgr::load (const string &sCDCFile, const string &sName) |
| Load a video stored in a CDC file. | |
| Sint32 | CRM64Pro::VideoMgr::load (Sint32 idCDC, const string &sName) |
| Load a video stored in a CDC file. | |
| Sint32 | CRM64Pro::VideoMgr::remove (Sint32 idCDC, const string &sName) |
| Remove a video stored in a CDC file. | |
| bool | CRM64Pro::VideoMgr::exists (Sint32 idCDC, const string &sName) const |
| Check if a video is stored in a CDC file. | |
|
override |
Request Video object information.
Writes information to the default log.
| iMode | 0 for standard output and 1 for extended output. |
|
override |
Get the name.
|
override |
Get the ID.
| Sint32 CRM64Pro::Video::play | ( | Sint32 | iRepeats = 0 | ) |
Play the video.
| iRepeats | Number of extra repeats after the first play. 0 plays once, -1 repeats forever. |
| bool CRM64Pro::Video::pause | ( | ) |
Pause the video playback.
| bool CRM64Pro::Video::resume | ( | ) |
Resume video from a paused state.
| bool CRM64Pro::Video::stop | ( | ) |
Stop video playback and reset to the beginning.
| ePlaybackStatus CRM64Pro::Video::status | ( | ) | const |
Get the video status.
| Sint32 CRM64Pro::Video::getDuration | ( | ) | const |
Get total duration.
| Sint32 CRM64Pro::Video::getPlaybackPosition | ( | ) | const |
Get current playback position.
| bool CRM64Pro::Video::seek | ( | Sint32 | iTimeMS | ) |
Seek to a playback position.
| iTimeMS | The position in milliseconds to seek to. |
| Uint64 CRM64Pro::Video::getFrameCount | ( | ) | const |
Get total frame count.
| Uint64 CRM64Pro::Video::getFrameCurrent | ( | ) | const |
Get current frame index.
| Sint32 CRM64Pro::Video::getWidth | ( | ) | const |
Get the native video width.
| Sint32 CRM64Pro::Video::getHeight | ( | ) | const |
Get the native video height.
| bool CRM64Pro::Video::setBlendMode | ( | SDL_BlendMode | bmValue | ) |
Set the alpha blending mode.
| bmValue | the SDL_BlendMode to use for rendering. |
| SDL_BlendMode CRM64Pro::Video::getBlendMode | ( | ) | const |
Get the alpha blending mode.
| bool CRM64Pro::Video::setAlphaMod | ( | Sint32 | iAlpha | ) |
Set the alpha modulation value.
| iAlpha | Ranges from 255 (opaque) to 0 (fully transparent). |
| Sint32 CRM64Pro::Video::getAlphaMod | ( | ) | const |
Get the alpha modulation value.
| bool CRM64Pro::Video::setColorMod | ( | Uint8 | iR, |
| Uint8 | iG, | ||
| Uint8 | iB ) |
Set the color modulation value.
| iR | Red (0-255). |
| iG | Green (0-255). |
| iB | Blue (0-255). |
| Sint32 CRM64Pro::Video::getColorMod | ( | Uint8 & | iR, |
| Uint8 & | iG, | ||
| Uint8 & | iB ) const |
Get the color modulation value.
| iR | reference to receive red [0,255]. |
| iG | reference to receive green [0,255]. |
| iB | reference to receive blue [0,255]. |
| bool CRM64Pro::Video::setTag | ( | eAudioTrackTag | eTag | ) |
Set video audio tag category.
Links the video's audio to the ConfigMgr's volume system.
| eTag | The tag category (e.g., ATT_MUSIC or ATT_VOICE). |
| eAudioTrackTag CRM64Pro::Video::getTag | ( | ) | const |
Get video audio tag category.
| bool CRM64Pro::Video::hasAudio | ( | ) | const |
Check if the video media contains an audio stream.
| bool CRM64Pro::Video::hasAudioError | ( | ) | const |
Check if video audio playback was dropped after a runtime audio failure.
| bool CRM64Pro::Video::getInfo | ( | VideoInfo * | pVI | ) | const |
Get video detailed information.
| pVI | Pointer to a VideoInfo struct to be filled. |
| Sint32 CRM64Pro::Video::decodeFrameAt | ( | Sint32 | iTimeMS, |
| SDL_Surface ** | ppSurface ) |
Decode and copy one video frame at or near a timestamp.
| iTimeMS | Target position in milliseconds. |
| ppSurface | Output SDL surface in SDL_PIXELFORMAT_ARGB8888 format. |
| Sint32 CRM64Pro::Video::save | ( | const string & | sCDCFile, |
| const string & | sResourceName = "" ) |
| Sint32 CRM64Pro::Video::save | ( | Sint32 | idCDC, |
| const string & | sResourceName = "" ) |
| Sint32 CRM64Pro::Video::saveToFile | ( | const string & | sFile | ) | const |
Export the Video to an external file.
| sFile | Output file path. |
| bool CRM64Pro::Video::setTarget | ( | Sint32 | idRes = 0 | ) |
Set the video render target.
| idRes | A valid screen handle. Default uses the default screen. |
| bool CRM64Pro::Video::setViewport | ( | const SDL_FRect * | pRect = nullptr | ) |
Set the target viewport used for automatic video rendering.
| pRect | Destination viewport on the render target, or nullptr to use the automatic viewport. |
| bool CRM64Pro::Video::setSourceViewport | ( | const SDL_FRect * | pRect = nullptr | ) |
Set the source viewport used for automatic video rendering.
| pRect | Source viewport in video pixels, or nullptr to use the full video frame. |
| bool CRM64Pro::Video::setRenderEx | ( | double | dAngle = 0.0, |
| const SDL_FPoint * | pCenter = nullptr, | ||
| SDL_FlipMode | rf = SDL_FLIP_NONE ) |
Set extended render attributes used for automatic video rendering.
| dAngle | Angle in degrees for rotation. |
| pCenter | SDL_FPoint pointer indicating rotation center. Default nullptr rotates around the target viewport center. |
| rf | SDL_FlipMode value for flipping actions. |
|
override |
Request Video Manager information.
Writes manager information to the default log.
| iMode | -1 to display only manager information. 0 (default) to display manager and all objects. A specific object ID displays manager information and only that object. |
|
override |
Close and destroy a video object.
| idVideo | 0 for closing all videos or the specific Video id. |
|
override |
Get number of loaded objects.
|
override |
Change the object name.
| idVideo | Video id. |
| sName | The video name. Must be unique. |
| Video * CRM64Pro::VideoMgr::get | ( | Sint32 | idVideo | ) |
| Sint32 CRM64Pro::VideoMgr::loadFromFile | ( | const string & | sFile, |
| const string & | sName = "", | ||
| eAudioTrackTag | eTag = ATT_MUSIC ) |
Load a video from an external file.
| sFile | string containing [directory]+filename+[extension]. |
| sName | Object name. If empty, filename without extension is used. Must be unique and shorter than 64 characters. |
| eTag | Audio category tag (default ATT_MUSIC). |
| Sint32 CRM64Pro::VideoMgr::load | ( | const string & | sCDCFile, |
| const string & | sName ) |
Load a video stored in a CDC file.
| sCDCFile | string containing [directory]+filename+[extension] of the CDC archive. |
| sName | string with the video name. |
| Sint32 CRM64Pro::VideoMgr::load | ( | Sint32 | idCDC, |
| const string & | sName ) |
Load a video stored in a CDC file.
| idCDC | CDC id. |
| sName | string with the video name. |
| Sint32 CRM64Pro::VideoMgr::remove | ( | Sint32 | idCDC, |
| const string & | sName ) |
Remove a video stored in a CDC file.
| idCDC | CDC id. |
| sName | string with the video name. |
| bool CRM64Pro::VideoMgr::exists | ( | Sint32 | idCDC, |
| const string & | sName ) const |
Check if a video is stored in a CDC file.
| idCDC | CDC id. |
| sName | string with the video name. |