Helper for decoding video frames.
More...
#include <video.hpp>
Helper for decoding video frames.
- Note
- This is only available if compiled with FFmpeg, see Dependencies.
Definition at line 197 of file video.hpp.
◆ VideoFrameDecoder()
| fpsdk::common::video::VideoFrameDecoder::VideoFrameDecoder |
( |
const VideoDecoderParams & | params | ) |
|
|
explicit |
◆ DecodeFrame() [1/2]
| virtual std::optional< ImageData > fpsdk::common::video::VideoFrameDecoder::DecodeFrame |
( |
const uint8_t * | data, |
|
|
const std::size_t | size ) |
|
pure virtual |
Decode one frame.
- This works for data that is available frame by frame. That is, it does not work for regular video streams where the data is chunked arbitrarily. Ideally, start by supplying an I frame incl. all the necessary NAL units (NALUs) to decode a first frame. After that, the following P frames should decode fine.
- For example, for HEVC (H.265) a full set of data for a I frame should contain:
- NALU type 32 (VPS, Video Parameter Set)
- NALU type 33 (SPS, Sequence Parameter Set)
- NALU type 34 (PPS, Picture Parameter Set)
- NALU type 19 (IDR, Instantaneous Decoding Refresh, and RADL, Random Access Decodable Leading) (possibly other types 16-23 (IRAP, Intra Random Access Point) NALUs might work)
- The video encoder should be configured accordingly (to repeat the VPS/SPS/PPS for each I-frame, and possibly to produce all/only I frames.
- Separate instances of this should be used to process different video streams
- Parameters
-
| [in] | data | Data for one (not more, not less) video frame |
| [in] | size | Size of data |
- Returns
- the decoded, converted and scaled image, nullptr otherwise (not enough data, bad data, ...)
◆ DecodeFrame() [2/2]
| std::optional< ImageData > fpsdk::common::video::VideoFrameDecoder::DecodeFrame |
( |
const std::vector< uint8_t > & | data | ) |
|
Decode video data.
- Parameters
-
| [in] | data | Data for one (recommended) or more video frame(s) |
- Returns
- the decoded, converted and scaled image, nullptr otherwise (not enough data, bad data, ...)
◆ IsOkay()
| virtual bool fpsdk::common::video::VideoFrameDecoder::IsOkay |
( |
| ) |
const |
|
pure virtual |
Check if decoder is in error state.
This is useful to check when DecodeFrame() didn't return a frame. If the decoder is in error state, it cannot be used anymore and must be discarded.
- Returns
- true if the decoder is okay, false if it is in error state
◆ params_
The documentation for this class was generated from the following file: