This sample program demonstrates how to seek to an arbitrary video frame in a movie file. For an overview of seek playback, refer to
Seek Playback .
Program Flow
The basic steps performed by the sample program are as follows:
- Register the memory allocator function for metadata.
- Set a seek position and begin playback.
1. Register the Memory Allocator Function for Metadata
CriManaPlayerHn criManaPlayer_Create(void *work, CriSint32 work_size)
Create Mana player (no config specified)
void criManaPlayer_SetMetaDataWorkAllocator(CriManaPlayerHn player, CriManaMetaMallocFunc allocfunc, CriManaMetaFreeFunc freefunc, void *obj, CriManaMetaFlag meta_flag)
Register meta data allocator.
@ CRIMANA_META_FLAG_ALL
Definition: cri_mana.h:342
To perform seek playback, you must use the
criManaPlayer_SetMetaDataWorkAllocator function before header analysis to register an allocator for metadata separately from normal allocators. The allocator can be the same as an allocator registered with the ::criMana_UserAllocator function. However, note that during multithreaded operation the allocator for metadata may be called from another thread.
If you do not register an allocator, seek playback cannot be performed.
2. Set a Seek Position and Begin Playback
if (app_obj->mvinf.seekinfo_flag == CRI_TRUE) {
}
void criManaPlayer_Start(CriManaPlayerHn player)
Start playback.
void criManaPlayer_SetSeekPosition(CriManaPlayerHn player, CriSint32 seek_frame_no)
Set seek position.
To perform seek playback, you must set the seek position with the
criManaPlayer_SetSeekPosition function before calling the
criManaPlayer_Start or
criManaPlayer_Prepare functions.
The seek position is usually specified based on the frame number. If an invalid seek position is specified, seeking will be performed from the beginning.
You can use the
criManaPlayer_CalcFrameNoFromTime function to calculate the frame number from a specific time, so you can also seek based on time like in the sample program.
- Additional Notes:
- You can check to see if the seek table information (metadata) required for seeking exists in a movie by looking at the "seekinfo_flag" member variable of the movie information structure. However, the current encoder always embeds a seek table information in the movie data so this check is generally not required.