This example demonstrates rocAL's video processing capabilities for handling video files and image sequences with various reader types, hardware acceleration options, and sequence manipulation features.
The operation performs video/sequence processing:
where
-
$Video/Sequence$ is the input video file or image sequence -
$\text{Load}$ reads video frames or sequence images based on reader type -
$\text{Decode}$ performs hardware or software decoding -
$\text{Process}$ applies optional augmentations and sequence operations -
$Output_{sequence}$ contains processed frame sequences
- Parse command-line arguments for video/sequence parameters, reader type, and processing options.
- Create rocAL context with specified processing mode and batch configuration.
- Configure video/sequence processing based on reader case:
- Video Reader: Load video files with hardware/software decoding
- Video Resize Reader: Load and resize videos during decoding
- Sequence Reader: Load image sequences from directories
- Single Shard Variants: Process specific data shards
- Set up decoder configuration:
- Choose hardware decoding (ROCDECODE) or software decoding (FFMPEG)
- Configure sequence parameters (length, step, stride)
- Enable metadata, frame numbers, and timestamp options
- Apply optional sequence processing:
- Sequence rearrangement for temporal augmentation
- Dynamic parameter adjustments during processing
- Verify the augmentation graph for correct configuration.
- Process video/sequence data:
- Run processing pipeline for each batch
- Extract frame sequences with specified parameters
- Copy processed data to host memory
- Handle metadata and temporal information:
- Retrieve frame numbers and timestamps if enabled
- Process video labels if metadata reading is enabled
- Save processed frames or create output videos if requested.
- Collect and display detailed timing information.
- Clean up rocAL context and release resources.
-
Multiple Reader Types: rocAL provides various readers for different video and sequence formats, each optimized for specific use cases.
-
Video File Reading:
rocalVideoFileSource(): Loads video files with configurable decoder settings and sequence parameters.rocalVideoFileSourceSingleShard(): Processes video files in single shard mode for parallel processing.rocalVideoFileResize(): Loads and resizes videos during decoding for memory efficiency.rocalVideoFileResizeSingleShard(): Single shard variant with resize capability.
-
Image Sequence Processing:
rocalSequenceReader(): Loads image sequences from directory structures.rocalSequenceReaderSingleShard(): Single shard sequence processing for parallel operations.
-
Hardware Acceleration:
RocalDecodeDevice: Enumeration for hardware vs software decoding (ROCAL_HW_DECODE,ROCAL_SW_DECODE).RocalDecoderType: Specifies decoder implementations (ROCAL_DECODER_VIDEO_ROCDECODE,ROCAL_DECODER_VIDEO_FFMPEG_SW).
-
Video Metadata Handling:
rocalCreateVideoLabelReader(): Creates label readers for video metadata processing.rocalGetImageLabels(): Retrieves label information for video sequences.
-
Sequence Manipulation:
rocalSequenceRearrange(): Rearranges frame sequences for temporal augmentation.- Supports custom frame ordering patterns for varied temporal representations.
-
Temporal Information:
rocalGetSequenceStartFrameNumber(): Retrieves start frame numbers for sequences.rocalGetSequenceFrameTimestamps(): Gets timestamp information for video frames.
-
Sequence Configuration:
- Sequence length controls number of frames per processed sequence.
- Frame step determines sampling interval between frames.
- Frame stride controls temporal resolution of extracted sequences.
-
Multi-format Support:
- Supports various video formats through FFMPEG software decoding.
- Hardware acceleration available through ROCDECODE for supported formats.
- Image sequence support for frame-by-frame processing workflows.
-
Output Options:
- Individual frame saving with sequence-aware naming.
- Video file generation per sequence for complete output preservation.
rocalCreaterocalReleaserocalVerifyrocalRunrocalGetStatusrocalGetErrorMessagerocalCopyToOutputrocalGetTimingInforocalResetLoaders
rocalVideoFileSourcerocalVideoFileSourceSingleShardrocalVideoFileResizerocalVideoFileResizeSingleShard
rocalSequenceReaderrocalSequenceReaderSingleShard
rocalCreateVideoLabelReaderrocalGetImageLabels
rocalSequenceRearrange
rocalGetSequenceStartFrameNumberrocalGetSequenceFrameTimestamps
rocalGetOutputWidthrocalGetOutputHeightrocalGetOutputColorFormatrocalGetAugmentationBranchCountrocalIsEmptyrocalGetRemainingImagesrocalGetImageNameLenrocalGetImageName
rocalCreateIntParameterrocalUpdateIntParameterrocalGetIntValue
RocalContextRocalTensorRocalProcessModeRocalImageColorRocalDecoderTypeRocalDecodeDeviceRocalIntParamRocalTimingInfoROCAL_COLOR_RGB24ROCAL_COLOR_U8ROCAL_DECODER_VIDEO_FFMPEG_SWROCAL_DECODER_VIDEO_ROCDECODEROCAL_DECODER_OPENCVROCAL_HW_DECODEROCAL_SW_DECODEROCAL_USE_USER_GIVEN_SIZE_RESTRICTEDROCAL_PROCESS_GPUROCAL_PROCESS_CPUROCAL_OK