A class that encodes video frames (e.g., images) into a video file.
More...
#include <easy3d/video/video_encoder.h>
|
| VideoEncoder () |
| Constructor.
|
|
| ~VideoEncoder () |
| Destructor.
|
|
bool | start (const std::string &file_name, int framerate, int bitrate) |
|
bool | encode (const unsigned char *data, int width, int height, PixelFormat pixel_format) |
|
bool | end () |
|
|
static bool | is_size_acceptable (int width, int height) |
| Returns whether the image size (width, height) is acceptable.
|
|
A class that encodes video frames (e.g., images) into a video file.
The output format is automatically guessed according to the file extension. Below is an example of usage:
encoder.start(output_file, 30, 100 * 1024 * 1024);
for (std::size_t i = 0; i < image_files.size(); ++i) {
std::vector<unsigned char> data;
int w, h, c;
}
encoder.end();
static bool load(const std::string &file_name, std::vector< unsigned char > &data, int &width, int &height, int &channels, int requested_channels=0, bool flip_vertically=true)
Load image data from a file. The following formats are supported JPG/JPEG, PNG, BMP,...
Definition: image_io.cpp:41
@ PIX_FMT_RGBA_8888
packed BGR 8:8:8, 24bpp, BGRBGR...
Definition: video_encoder.h:69
VideoEncoder()
Constructor.
Definition: video_encoder.cpp:418
◆ PixelFormat
The supported pixel format/storage of the video frames.
Enumerator |
---|
PIX_FMT_BGR_888 | packed RGB 8:8:8, 24bpp, RGBRGB...
|
PIX_FMT_RGBA_8888 | packed BGR 8:8:8, 24bpp, BGRBGR...
|
PIX_FMT_BGRA_8888 | packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
|
◆ encode()
bool encode |
( |
const unsigned char * |
data, |
|
|
int |
width, |
|
|
int |
height, |
|
|
PixelFormat |
pixel_format |
|
) |
| |
Encode one frame to the video stream.
- Parameters
-
data | The input image data. It is a 1D array of 'unsigned char' which points to the pixel data. The pixel data consists of 'height' rows of 'width' pixels, with each pixel has one of the following structures. The correspondences between these structures and pixel/OpenGL formats are: RGB 8:8:8, 24bpp <—> PIX_FMT_RGB_888 <—> GL_RGB BGR 8:8:8, 24bpp <—> PIX_FMT_BGR_888 <—> GL_BGR RGBA 8:8:8:8, 32bpp <—> PIX_FMT_RGBA_8888 <—> GL_RGBA BGRA 8:8:8:8, 32bpp <—> PIX_FMT_BGRA_8888 <—> GL_BGRA |
- Returns
- true on successful.
◆ end()
Finish encoding all the frames.
- Note
- It must be called after encoding all frames.
◆ start()
bool start |
( |
const std::string & |
file_name, |
|
|
int |
framerate, |
|
|
int |
bitrate |
|
) |
| |
- Parameters
-
file_name | The name of the output video file, e.g., "C:/result.mp4". The output format is automatically guessed according to the file extension. |
The documentation for this class was generated from the following files:
- /Users/lnan/Documents/Projects/Easy3D/easy3d/video/video_encoder.h
- /Users/lnan/Documents/Projects/Easy3D/easy3d/video/video_encoder.cpp