4 #include <libavcodec/avcodec.h> 
    5 #include <libavformat/avformat.h> 
    6 #include <libavutil/avutil.h> 
   27         LOG_INFO(
"Setup audio encoder with:\n" << profile)
 
   41     if(!isValid && !profile.empty())
 
   43         const std::string msg(
"Invalid audio profile to setup encoder.");
 
   45         throw std::runtime_error(msg);
 
   55     for(ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it)
 
   67         catch(std::exception& e)
 
   75     for(ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it)
 
   87         catch(std::exception& e)
 
   89             LOG_WARN(
"AudioEncoder - can't set option " << (*it).first << 
" to " << (*it).second << 
": " << e.what())
 
   99     if((avCodecContext.coded_frame) && (avCodecContext.coded_frame->pts != (
int)AV_NOPTS_VALUE))
 
  101         packet.pts = avCodecContext.coded_frame->pts;
 
  104     if(avCodecContext.coded_frame && avCodecContext.coded_frame->key_frame)
 
  106         packet.flags |= AV_PKT_FLAG_KEY;
 
  120     encodedData.data = NULL;
 
  123 #if LIBAVCODEC_VERSION_MAJOR > 53 
  125     const int ret = avcodec_encode_audio2(&avCodecContext, &encodedData, decodedData, &gotPacket);
 
  128         throw std::runtime_error(
"Encode audio frame error: avcodec encode audio frame - " +
 
  131     return gotPacket == 1;
 
  133     const int ret = avcodec_encode_audio(&avCodecContext, encodedData.data, encodedData.size, decodedData);
 
  136         throw std::runtime_error(
"Encode audio frame error: avcodec encode audio frame - " +
 
void setString(const std::string &value)
 
bool encodeFrame(const Frame &sourceFrame, CodedData &codedFrame)
Encode a new frame, and get coded frame. 
 
AudioEncoder(const std::string &audioCodecName)
 
void setupAudioEncoder(const AudioFrameDesc &frameDesc, const ProfileLoader::Profile &profile=ProfileLoader::Profile())
 
void setInt(const int value)
 
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
 
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). 
 
Description to create an audio frame. This corresponds to the number of samples, which corresponds to...
 
static bool checkAudioProfile(const Profile &profileToCheck)
 
This class describes decoded (raw) audio or video data. 
 
void openCodec()
Initialize the codec context. 
 
AVCodecContext & getAVCodecContext()
 
This class describes coded data. 
 
const std::string avProfileCodec
 
const std::string avProfileSampleFormat
 
const std::string avProfileThreads
 
void setAudioParameters(const AudioFrameDesc &audioFrameDesc)
 
const std::string avProfileType
 
bool encode(const AVFrame *decodedData, AVPacket &encodedData)
 
void setupEncoder(const ProfileLoader::Profile &profile=ProfileLoader::Profile())
Setup the encoder.