4 #include <libavcodec/avcodec.h> 
    5 #include <libavformat/avformat.h> 
    6 #include <libavutil/avutil.h> 
   28         LOG_INFO(
"Setup video encoder with:\n" << profile)
 
   42     if(!isValid && !profile.empty())
 
   44         const std::string msg(
"Invalid video profile to setup encoder.");
 
   46         throw std::runtime_error(msg);
 
   56     for(ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it)
 
   70         catch(std::exception& e)
 
   79         LOG_INFO(
"SetUp video encoder to compute statistics during process")
 
   80         encoderFlags |= CODEC_FLAG_PSNR;
 
   86     for(ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it)
 
  100         catch(std::exception& e)
 
  102             LOG_WARN(
"VideoEncoder - can't set option " << (*it).first << 
" to " << (*it).second << 
": " << e.what())
 
  112     if((avCodecContext.coded_frame) && (avCodecContext.coded_frame->pts != (
int)AV_NOPTS_VALUE))
 
  114         packet.pts = avCodecContext.coded_frame->pts;
 
  117     if(avCodecContext.coded_frame && avCodecContext.coded_frame->key_frame)
 
  119         packet.flags |= AV_PKT_FLAG_KEY;
 
  133     encodedData.data = NULL;
 
  136 #if LIBAVCODEC_VERSION_MAJOR > 53 
  138     const int ret = avcodec_encode_video2(&avCodecContext, &encodedData, decodedData, &gotPacket);
 
  141         throw std::runtime_error(
"Encode video frame error: avcodec encode video frame - " +
 
  144     return gotPacket == 1;
 
  146     const int ret = avcodec_encode_video(&avCodecContext, encodedData.data, encodedData.size, decodedData);
 
  149         throw std::runtime_error(
"Encode video frame error: avcodec encode video frame - " +
 
Description to create a video frame. 
 
void setString(const std::string &value)
 
const std::string avProfileFrameRate
 
bool encodeFrame(const Frame &sourceFrame, CodedData &codedFrame)
Encode a new frame, and get coded frame. 
 
void setupEncoder(const ProfileLoader::Profile &profile=ProfileLoader::Profile())
Setup the encoder. 
 
const std::string avProfileProcessStat
Do statistics during the process. 
 
void setImageParameters(const VideoFrameDesc &videoFrameDesc)
 
void setInt(const int value)
 
void setupVideoEncoder(const VideoFrameDesc &frameDesc, const ProfileLoader::Profile &profile=ProfileLoader::Profile())
 
std::string getDescriptionFromErrorCode(const int code)
Get the string description corresponding to the error code provided by ffmpeg/libav. 
 
std::map< std::string, std::string > Profile
 
const std::string avProfileIdentificator
 
const std::string avProfileIdentificatorHuman
 
const std::string avProfilePixelFormat
 
Option & getOption(const std::string &optionName)
 
Wrapper of AVOption. Get its type to know what the option is about: Int, Double, Ratio, Choice... Parse its array of options to get the potential childs (Choice and Group). 
 
VideoEncoder(const std::string &videoCodecName)
 
This class describes decoded (raw) audio or video data. 
 
void openCodec()
Initialize the codec context. 
 
const std::string avProfileWidth
 
const std::string avProfileHeight
 
AVCodecContext & getAVCodecContext()
 
This class describes coded data. 
 
const std::string avProfileCodec
 
const std::string avProfileThreads
 
const std::string avProfileType
 
bool encode(const AVFrame *decodedData, AVPacket &encodedData)
 
static bool checkVideoProfile(const Profile &profileToCheck)