##

VideoEncoder.hh
Go to the documentation of this file.
/*
* Copyright 2016 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_COMMON_VIDEOENCODER_HH_
#define GAZEBO_COMMON_VIDEOENCODER_HH_
#include <chrono>
#include <string>
#include <memory>
#include <gazebo/util/system.hh>
// Default bitrate (0) indicates that a bitrate should be calculated when
// Start is called.
#define VIDEO_ENCODER_BITRATE_DEFAULT 0
#define VIDEO_ENCODER_WIDTH_DEFAULT 1280
#define VIDEO_ENCODER_HEIGHT_DEFAULT 720
#define VIDEO_ENCODER_FPS_DEFAULT 25
#define VIDEO_ENCODER_FORMAT_DEFAULT "mp4"
namespace gazebo
{
namespace common
{
// Forward declare private data class
class VideoEncoderPrivate;
class GZ_COMMON_VISIBLE VideoEncoder
{
public: VideoEncoder();
public: virtual ~VideoEncoder();
public: bool Start(
const std::string &_format = VIDEO_ENCODER_FORMAT_DEFAULT,
const std::string &_filename = "",
const unsigned int _width = VIDEO_ENCODER_WIDTH_DEFAULT,
const unsigned int _height = VIDEO_ENCODER_HEIGHT_DEFAULT,
const unsigned int _fps = VIDEO_ENCODER_FPS_DEFAULT,
const unsigned int _bitRate = VIDEO_ENCODER_BITRATE_DEFAULT);
public: bool Stop();
public: bool IsEncoding() const;
public: bool AddFrame(const unsigned char *_frame,
const unsigned int _width,
const unsigned int _height);
public: bool AddFrame(const unsigned char *_frame,
const unsigned int _width,
const unsigned int _height,
const std::chrono::steady_clock::time_point &_timestamp);
public: bool SaveToFile(const std::string &_filename);
public: std::string Format() const;
public: unsigned int BitRate() const;
public: void Reset();
private: std::unique_ptr<VideoEncoderPrivate> dataPtr;
};
}
}
#endif
gazebo::common::VideoEncoder::Stop
bool Stop()
Stop the encoder.
gazebo::common::VideoEncoder::VideoEncoder
VideoEncoder()
Constructor.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::common::VideoEncoder::SaveToFile
bool SaveToFile(const std::string &_filename)
Write the video to disk param[in] _filename File in which to save the encoded data.
common
common
Definition: FuelModelDatabase.hh:37
gazebo::common::VideoEncoder::Format
std::string Format() const
Get the encoding format.
system.hh
gazebo::common::VideoEncoder::Reset
void Reset()
Reset to default video properties and clean up allocated memory.
gazebo::common::VideoEncoder::IsEncoding
bool IsEncoding() const
True if the enoder has been started, false otherwise.
gazebo::common::VideoEncoder
The VideoEncoder class supports encoding a series of images to a video format, and then writing the v...
Definition: VideoEncoder.hh:46
gazebo::common::VideoEncoder::~VideoEncoder
virtual ~VideoEncoder()
Destructor.
VIDEO_ENCODER_BITRATE_DEFAULT
#define VIDEO_ENCODER_BITRATE_DEFAULT
Definition: VideoEncoder.hh:27
VIDEO_ENCODER_FPS_DEFAULT
#define VIDEO_ENCODER_FPS_DEFAULT
Definition: VideoEncoder.hh:30
gazebo::common::VideoEncoder::AddFrame
bool AddFrame(const unsigned char *_frame, const unsigned int _width, const unsigned int _height)
Add a single frame to be encoded.
gazebo::common::VideoEncoder::BitRate
unsigned int BitRate() const
Get the bit rate.
VIDEO_ENCODER_FORMAT_DEFAULT
#define VIDEO_ENCODER_FORMAT_DEFAULT
Definition: VideoEncoder.hh:31
VIDEO_ENCODER_WIDTH_DEFAULT
#define VIDEO_ENCODER_WIDTH_DEFAULT
Definition: VideoEncoder.hh:28
VIDEO_ENCODER_HEIGHT_DEFAULT
#define VIDEO_ENCODER_HEIGHT_DEFAULT
Definition: VideoEncoder.hh:29
gazebo::common::VideoEncoder::Start
bool Start(const std::string &_format="mp4", const std::string &_filename="", const unsigned int _width=1280, const unsigned int _height=720, const unsigned int _fps=25, const unsigned int _bitRate=0)
Start the encoder.