10 : _avFormatContext(NULL)
15 int ret = avformat_open_input(&
_avFormatContext, filename.c_str(), NULL, options);
18 std::string msg =
"Unable to open file ";
22 throw std::ios_base::failure(msg);
33 : _avFormatContext(NULL)
68 const int err = avio_open2(&
_avFormatContext->pb, url.c_str(), flags, NULL, NULL);
127 const int ret = av_dict_set(&
_avFormatContext->metadata, key.c_str(), value.c_str(), 0);
137 AVStream* stream = avformat_new_stream(
_avFormatContext, const_cast<AVCodec*>(&avCodec));
140 throw std::runtime_error(
"Unable to add new video stream");
151 LOG_ERROR(
"Error when seek at " << position <<
" (in AV_TIME_BASE units) in file")
160 std::vector<Option> optionsArray;
163 optionsArray.push_back(it->second);
172 std::stringstream msg;
173 msg <<
"Can't acces stream at index ";
175 throw std::runtime_error(msg.str());
187 AVOutputFormat* oformat = av_guess_format(shortName.c_str(), filename.c_str(), mimeType.c_str());
190 std::string msg(
"Unable to find format for ");
192 if(!shortName.empty())
194 msg +=
", formatName = ";
197 if(!mimeType.empty())
199 msg +=
", mimeType = ";
202 throw std::ios_base::failure(msg);
size_t getNbStreams() const
const int _flags
Flags with which the options are loaded (see AV_OPT_FLAG_xxx)
void closeRessource()
Close the resource accessed by the AVIOContext and free it.
void loadOptions(OptionMap &outOptions, void *av_class, int req_flags)
bool seek(const uint64_t position, const int flag)
Seek at a specific position.
void setOutputFormat(const std::string &filename, const std::string &shortName="", const std::string &mimeType="")
std::string getDescriptionFromErrorCode(const int code)
Get the string description corresponding to the error code provided by ffmpeg/libav.
void addMetaData(const std::string &key, const std::string &value)
AVStream & addAVStream(const AVCodec &avCodec)
void writeTrailer()
Write the stream trailer to an output media file.
OptionArray getOptions()
Get options as array.
void writeHeader(AVDictionary **options=NULL)
Write the stream header to an output media file.
bool _isOpen
Is the AVFormatContext open (in constructor with a filename)
void findStreamInfo(AVDictionary **options=NULL)
Read packets of a media file to get stream information.
void writeFrame(AVPacket &packet, bool interleaved=true)
Write a packet to an output media file.
AVFormatContext * _avFormatContext
Has ownership.
void openRessource(const std::string &url, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
FormatContext(const FormatContext &formatContext)
AVStream & getAVStream(size_t index) const
void setFilename(const std::string &filename)