Video Manager and Video objects for FFmpeg-based playback and rendering [v26.06.1].
Overview
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.
Key features
-
FFmpeg backend: Uses the bundled static FFmpeg build for demuxing and decoding
-
File playback: Loads videos from external files using the file protocol
-
CDC storage: Saves and loads video resources through raw streamable CDC blocks
-
Audio integration: Routes decoded audio through AudioTrack with Music, SFX, Voice or Custom tags
-
Playback control: Play, pause, resume, stop, seek and repeat playback support
-
SDL rendering: Automatically renders decoded frames with retained target, viewport, alpha, color modulation and blending settings
Supported formats
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 |
CDC storage
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.
Playback methods
Rendering methods
Videos are rendered automatically during the engine render phase once playback starts:
Manager type
This is a standard object manager. Each loaded video has its own decode state, playback position, SDL texture and optional linked AudioTrack stream.
Limitations
-
Network and pipe protocols are disabled
-
Hardware acceleration is disabled
-
swscale is not enabled; supported decoded YUV formats are uploaded directly to SDL textures
-
Only the formats listed above are enabled in the bundled FFmpeg project
-
CDC video blocks must be raw streamable blocks; compressed and encrypted CDC video blocks are not supported
Best practices
-
Use H.264 video with AAC audio in MP4/MOV containers for best compatibility
-
Use hasAudio() before exposing video-specific audio controls
-
Use setTag() to route video audio through the correct engine audio category
-
Access the manager exclusively through Main::videoMgr()
- Note
- The Video Manager is a singleton, automatically created once Main is instantiated. You can get a reference to this manager using Main::videoMgr() method.
The Video Manager is automatically released when Main::terminate() is called. At this time, any resource still loaded will be released, avoiding resource leaks.
Video objects are created through VideoMgr::loadFromFile() or VideoMgr::load(); VideoMgr::create() is intentionally unavailable because an empty Video has no playable source.
|
| 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.
|