avcpp 3.2.1
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
av Namespace Reference

Root namespace of the library. More...

Namespaces

namespace  v1
 The AvDeleter struct Unified delete functor for variois FFMPEG/libavformat/libavcodec and so on resource allocators.

Classes

struct  ArrayIterator
 Wrapped array iterator. More...
struct  ArraySentinel
 Policy based sentinel marker. More...
class  ArrayView
 C-array (FFmpeg) wrapper witch can iterate over collection and represents any element via light-weight view U. More...
class  AudioCodecContext
 Audio-specific parameters shared by audio encoders and decoders. More...
class  AudioDecoderContext
 Decodes audio packets into sample buffers. More...
class  AudioEncoderContext
 Encodes audio samples into packets. More...
class  AudioResampler
 Converts audio between sample rates, sample formats and channel layouts. More...
class  AudioSamples
 One buffer of decoded audio samples. More...
class  AvcppCategory
 The AvcppCategory class Describes internal AvCpp errors. More...
class  BufferRef
 Light weight wrapper for the FFmpeg AVBufferRef functionality. More...
class  BufferRefView
 Non-owning view for the nested AVBufferRef. More...
class  BufferSinkFilterContext
 Exit point of a filter graph. More...
class  BufferSrcFilterContext
 Entry point of a filter graph. More...
class  ChannelLayout
 Owning channel layout. More...
class  ChannelLayoutView
 Non-owning view of an AVChannelLayout. More...
class  Codec
 Codec descriptor. More...
class  CodecContext2
 Base class for audio and video codec contexts. More...
class  CodecContextBase
 Base class that fixes the direction and media type of a codec context. More...
class  CodecParameters
 Owning codec parameters. More...
class  CodecParametersView
 The CodecParametersView class. More...
struct  CustomIO
 Interface class to customize IO operations with FormatContext. More...
struct  DefaultNextElement
 This functor uses simple notation to take next element from linked list. More...
struct  DefaultResetPtr
 This functor used by default to set new pointer that will be wrapped by W wrapper. More...
struct  DefaultWrapperCast
 This functor used by default to take access to raw pointer that wrapped by W wrapper. More...
class  Dictionary
 Implements interface to access to the AVDictionary entity. More...
class  DictionaryArray
 Array of Dictinaries wrapper. More...
struct  EmptyDeleter
 Deleter that does nothing. More...
struct  EqualComparator
 Predicate that compares an element with a stored value. More...
class  Exception
 The AvException class Default exception that thows from function that does not accept error code storage. More...
class  FfmpegCategory
 The FfmpegCategory class Describers FFmpeg internal errors. More...
class  Filter
 A filter descriptor: the static description of one filter. More...
class  FilterContext
 One filter instance inside a graph. More...
class  FilterGraph
 A filter graph: filters, the links between them, and their configuration. More...
class  FilterPadList
 Pads of a filter: its inputs or its outputs. More...
struct  Format
 Common interface of input and output format descriptors. More...
class  FormatContext
 Container context: the entry point for demuxing, muxing and seeking. More...
class  Frame
 CRTP base that gives a frame type its copy and move assignment. More...
class  FrameCommon
 Common interface of video frames and audio samples. More...
class  FrameSideData
 Simple view for the AVFrameSideData elements. More...
class  GenericCodecContext
 The GenericCodecContext class to copy contexts from input streams to output one. More...
struct  IncrementNextElement
 This functor uses increment operation to take next element in list/array. More...
class  InputFormat
 Demuxer descriptor. More...
class  LinkedListWrapper
 Universal wrapper for one directional linked list elements. More...
class  noncopyable
 Base class that deletes copying and assignment. More...
struct  NullDeleter
 This deleter does nothing. More...
class  OptionalErrorCode
 Carries the caller's choice between exceptions and error codes. More...
class  OutputFormat
 Muxer descriptor. More...
class  Packet
 Compressed data and its metadata. More...
class  PacketSideData
 Simple view for the AVPacketSideData elements. More...
class  PixelFormat
 The PixelFormat class is a simple wrapper for AVPixelFormat that allow to acces it it properties. More...
struct  PtrDeleter
 This deleter simple call 'delete' operator. More...
class  Rational
 Rational number: a numerator and a denominator. More...
class  Rect
 Rectangle: a position and a size. More...
struct  ReferenceSelector
struct  ReferenceSelector< T, U, false >
 Selects a value as the dereference result. More...
struct  ReferenceSelector< T, U, true >
 Selects a reference as the dereference result. More...
class  SampleFormat
 The SampleFormat class is a simple proxy class for AVSampleFormat. More...
class  ScopedValue
 Functor to take next element in list/array. More...
class  ScopeOutAction
 The ScopeOutAction class - guard-type class that allows points callback that will be called at the scope out. More...
struct  SentinelEndPolicy
 Sentinel policy that defines well-known range end pointer. More...
struct  SentinelUntilPolicy
 Sentinel policy that defines well-known sequence end marker, like '\0' at the C-string end or special value like NULL. More...
struct  SmartDeleter
 Template facade over the per-type deleters of namespace v1. More...
class  Stream
 One stream inside a container. More...
class  SubtitleCodecContext
 Base class for subtitle codec contexts. More...
class  SubtitleDecoderContext
 Decodes subtitle packets into subtitle frames. More...
class  SubtitleEncoderContext
 Encodes subtitle frames into packets. More...
class  SubtitleFrame
 Owning, move-only subtitle frame. More...
class  SubtitleRect
 Non-owning view over AVSubtitleRect. More...
class  Timestamp
 The Timestamp class represents timestamp value and it timebase. More...
class  VideoCodecContext
 Video-specific parameters shared by video encoders and decoders. More...
class  VideoDecoderContext
 Decodes video packets into frames. More...
class  VideoEncoderContext
 Encodes video frames into packets. More...
class  VideoFrame
 One video frame. More...
class  VideoRescaler
 Converts video frames between sizes and pixel formats. More...

Typedefs

template<typename T>
using avcpp_format_const
 Const or non-const FFmpeg format type, depending on the FFmpeg version.
using FmtCodec = class Codec
 Forward declaration of av::Codec, so this header need not include it.
using AvioInterruptCb = std::function<int()>
 Callback that can abort a blocking IO operation.

Enumerations

enum class  Errors {
  NoError = 0 , Generic , Unallocated , InvalidArgument ,
  OutOfRange , CantAllocateFrame , CodecStreamInvalid , CodecInvalidDirection ,
  CodecAlreadyOpened , CodecIsNotOpened , CodecInvalid , CodecNotOpened ,
  CodecInvalidDecodeProc , CodecInvalidEncodeProc , CodecDecodingOffsetToLarge , CodecInvalidForEncode ,
  CodecInvalidForDecoce , CodecInvalidMediaType , FrameInvalid , DictOutOfRage ,
  DictNoKey , BufferReadonly , FormatCantAddStream , FormatAlreadyOpened ,
  FormatNullOutputFormat , FormatWrongCountOfStreamOptions , FormatNoStreams , FormatInvalidStreamIndex ,
  FormatNotOpened , FormatInvalidDirection , FormatHeaderNotWriten , FormatCodecUnsupported ,
  ResamplerInvalidParameters , ResamplerNotInited , ResamplerInputChanges , ResamplerOutputChanges ,
  RescalerInvalidParameters , RescalerInternalSwsError , FilterNotInFilterGraph , FilterGraphDescriptionEmpty ,
  IncorrectBufferSrcFilter , IncorrectBufferSrcMediaType , IncorrectBufferSinkFilter , IncorrectBufferSinkMediaType ,
  MixBufferSinkAccess , CodecUnsupportedOperation , HardwareDeviceUnavailable , HardwareDeviceInvalid ,
  HardwareConfigNotFound , HardwareFramesInvalid , HardwareTransferUnsupported , HardwareCodecNotFound
}
 Errors the library raises itself, as opposed to FFmpeg's return codes. More...
enum class  Direction { Invalid = -1 , Encoding , Decoding }
 Direction a codec or a stream is used in. More...
enum class  FilterMediaType { Unknown , Video , Audio }
 Media type a filter works with. More...
enum  { RationalMaxPrecision = 5 }
enum  SwsFlags {
  SwsFlagAuto = 0 , SwsFlagFastBilinear = SWS_FAST_BILINEAR , SwsFlagBilinear = SWS_BILINEAR , SwsFlagBicubic = SWS_BICUBIC ,
  SwsFlagExprerimental = SWS_X , SwsFlagNeighbor = SWS_POINT , SwsFlagArea = SWS_AREA , SwsFlagBicublin = SWS_BICUBLIN ,
  SwsFlagGauss = SWS_GAUSS , SwsFlagSinc = SWS_SINC , SwsFlagLanczos = SWS_LANCZOS , SwsFlagSpline = SWS_SPLINE ,
  SwsFlagPrintInfo = SWS_PRINT_INFO , SwsFlagAccurateRnd = SWS_ACCURATE_RND , SwsFlagFullChromaInt = SWS_FULL_CHR_H_INT , SwsFlagFullChromaInp = SWS_FULL_CHR_H_INP ,
  SwsFlagBitexact = SWS_BITEXACT , SwsFlagErrorDiffusion = SWS_ERROR_DIFFUSION
}
 Scaling algorithms and options of libswscale. More...

Functions

void init ()
 Initialize all subsystems the library needs.
const AvcppCategory & avcpp_category ()
 Error category of the library's own errors.
FfmpegCategory & ffmpeg_category ()
 Error category that wraps FFmpeg return codes.
std::error_condition make_error_condition (av::Errors errc) noexcept
 Build an error condition from an avcpp error.
std::error_code make_error_code (av::Errors errc) noexcept
 Build an error code from an avcpp error.
std::error_code make_avcpp_error (Errors code)
 Build an error code from an avcpp error.
std::error_condition make_avcpp_condition (Errors code)
 Build an error condition from an avcpp error.
std::error_code make_ffmpeg_error (int code)
 Build an error code from an FFmpeg return value.
std::error_condition make_ffmpeg_condition (int code)
 Build an error condition from an FFmpeg return value.
template<typename Exception = av::Exception>
void throw_error_code (const std::error_code &ec)
 Throw an exception carrying the given error code.
template<typename Exception = av::Exception>
void throw_error_code (Errors errc)
 Throw an exception carrying an avcpp error.
OptionalErrorCode throws ()
 Helper to construct null OptionalErrorCode object.
template<typename Category, typename Exception = av::Exception>
void throws_if (OptionalErrorCode ec, int errcode, const Category &cat)
 Throw or store an error, depending on what the caller passed.
template<typename T, typename Exception = av::Exception>
void throws_if (OptionalErrorCode ec, T errcode)
 Throw or store an error code, depending on the caller's choice.
void clear_if (OptionalErrorCode ec)
 clear_if - clear error code if it is not av::throws()
bool is_error (OptionalErrorCode ec)
 Whether an error was stored in the caller's variable.
int64_t gettime ()
 Get the current time in microseconds.
int usleep (unsigned usec)
 Sleep for a period of time.
template<typename R, typename T>
R lexical_cast (const T &v)
 Convert a value through its stream representation.
void set_logging_level (int32_t level)
 This method can be used to turn up or down FFmpeg's logging level.
void set_logging_level (const std::string &level)
 Like.
void dumpBinaryBuffer (uint8_t *buffer, int buffer_size, int width=16)
 dump_binary_buffer Dump binary buffer to std out in HEX view
std::string error2string (int error)
 C++ verstion of the av_err2str().
std::string_view wrap2sview (const char *value) noexcept
 Wraps a nullable C string into a string_view without copying.
template<typename T>
std::unique_ptr< T, void(*)(void *)> malloc (size_t size)
 Allocate memory with the FFmpeg allocator.
template<typename T>
std::unique_ptr< T, void(*)(void *)> mallocz (size_t size)
 Allocate zeroed memory with the FFmpeg allocator.
template<typename T>
std::unique_ptr< T, void(*)(void *)> memdup (const void *p, size_t size)
 Copy a memory block using the FFmpeg allocator.
std::unique_ptr< char, void(*)(void *)> strdup (std::string_view value)
 Duplicates a string using the FFmpeg allocator.
template<typename T>
void freep (T *&ptr) noexcept
 Frees a buffer allocated by the FFmpeg allocator and resets the pointer.
template<class U>
auto make_array_view_size (auto *ptr, std::size_t size)
 Helper to create array view with well-known size.
template<class U>
auto make_array_view_until (auto *ptr, auto value)
 Helper to create array view with end marker.
template<typename T, typename L>
requires std::ranges::range<L> && requires(L& r) { std::ranges::empty(r); }
T guessValue (const T &value, L list)
 Select more approptiate value from given value list.
template<typename T, typename L, typename C>
T guessValue (const T &value, const L *list, C endListComparator)
 Select more approptiate value from given value list.
template<typename T, typename Container>
void array_to_container (const T *array, std::size_t nelements, Container &container)
 Append a fixed number of array elements to a container.
template<typename T, typename Container, typename Callable>
void array_to_container (const T *array, std::size_t nelements, Container &container, Callable convert)
 Append converted array elements to a container.
template<typename T, typename Container, typename Compare>
void array_to_container (const T *array, Container &container, Compare isEnd)
 Append elements until the predicate reports the end of the list.
template<typename T, typename Container, typename Compare, typename Callable>
void array_to_container (const T *array, Container &container, Compare isEnd, Callable convert)
 Append converted elements until the predicate reports the end of the list.
void hex_dump (FILE *f, const uint8_t *buf, std::size_t size)
 Write a hexadecimal dump of a buffer to a C stream.
void hex_dump_log (void *avcl, int level, const uint8_t *buf, std::size_t size)
 Write a hexadecimal dump of a buffer through the FFmpeg log system.
void hex_dump (FILE *f, std::span< const uint8_t > buf)
 Write a hexadecimal dump of a span to a C stream.
void hex_dump_log (void *avcl, int level, std::span< const uint8_t > buf)
 Write a hexadecimal dump of a span through the FFmpeg log system.
std::string channel_name (AVChannel channel)
 Name of a speaker position.
std::string channel_description (AVChannel channel)
 Human-readable description of a speaker position.
AVChannel channel_from_string (const std::string &name)
 Look a speaker position up by name.
AVChannel channel_from_string (const char *name)
 Look a speaker position up by a C string name.
Codec findEncodingCodec (AVCodecID id)
 Find an encoder by codec identifier.
Codec findEncodingCodec (const std::string &name)
 Find an encoder by name.
Codec findDecodingCodec (AVCodecID id)
 Find a decoder by codec identifier.
Codec findDecodingCodec (const std::string &name)
 Find a decoder by name.
Codec findEncodingCodec (const OutputFormat &format, bool isVideo=true)
 Find the encoder a muxer uses when the caller does not choose one.
Codec guessEncodingCodec (OutputFormat format, const char *name, const char *url, const char *mime, AVMediaType mediaType)
 Guess the encoder for an output from its hints.
OutputFormat guessOutputFormat (const std::string &name, const std::string &url=std::string(), const std::string &mime=std::string())
 Find the muxer FFmpeg would pick for this output.
template<typename T>
auto operator/ (T num, Rational value) -> std::enable_if_t< std::is_floating_point_v< T >||std::is_integral_v< T >, Rational >
 Divide a number by a rational.
template<typename T>
auto operator/ (Rational value, T num) -> std::enable_if_t< std::is_floating_point_v< T >||std::is_integral_v< T >, Rational >
 Divide a rational by a number.
std::ostream & operator<< (std::ostream &stream, const Rational &value)
 Print the rational as "numerator/denominator".
std::istream & operator>> (std::istream &stream, Rational &value)
 Read a rational written as "numerator/denominator".
bool operator> (const Timestamp &left, const Timestamp &right) noexcept
 Compare two timestamps, taking their time bases into account.
bool operator< (const Timestamp &left, const Timestamp &right) noexcept
 Compare two timestamps, taking their time bases into account.
bool operator== (const Timestamp &left, const Timestamp &right) noexcept
 Compare two timestamps, taking their time bases into account.
bool operator!= (const Timestamp &left, const Timestamp &right) noexcept
 Compare two timestamps.
bool operator>= (const Timestamp &left, const Timestamp &right) noexcept
 Compare two timestamps.
bool operator<= (const Timestamp &left, const Timestamp &right) noexcept
 Compare two timestamps.
Timestamp operator+ (const Timestamp &left, const Timestamp &right) noexcept
 Add two timestamps, aligning the time bases.
Timestamp operator- (const Timestamp &left, const Timestamp &right) noexcept
 Subtract two timestamps, aligning the time bases.
Timestamp operator* (const Timestamp &left, const Timestamp &right) noexcept
 Multiply two timestamps.
Timestamp operator/ (const Timestamp &left, const Timestamp &right) noexcept
 Divide two timestamps.
std::ostream & operator<< (std::ostream &ost, const Timestamp &ts)
 Print the timestamp as "value*timebase", or NO_PTS.

Variables

constexpr auto NoPts = static_cast<int64_t>(AV_NOPTS_VALUE)
 Timestamp value meaning "no timestamp".
constexpr auto TimeBase = static_cast<int>(AV_TIME_BASE)
 Denominator of the global time base used for container-level timestamps.
constexpr auto TimeBaseQ = AVRational{1, AV_TIME_BASE}
 The global time base as a rational value.

Detailed Description

Every public type and function lives in av, usually as a thin RAII wrapper over the corresponding FFmpeg type. Wrappers do not copy data unless the documentation of the specific method says so; ownership and lifetime are stated per class and per method.

Call av::init() before anything else.

Typedef Documentation

◆ avcpp_format_const

template<typename T>
using av::avcpp_format_const
Initial value:
typename std::conditional<
std::is_const<
typename std::remove_pointer<
decltype(AVFormatContext::iformat)
>::type
>::value, const T, T>::type

FFmpeg 59 made the muxer/demuxer descriptors const; this alias keeps one code path compiling against both.

Template Parameters
TAVFormat type to qualify

◆ AvioInterruptCb

using av::AvioInterruptCb = std::function<int()>

The callback runs periodically while FFmpeg waits on a socket. A non-zero result interrupts the read or write and surfaces as an FFmpeg error, which is how a stalled network source is made cancellable.

Enumeration Type Documentation

◆ Direction

enum class av::Direction
strong

The value is part of the codec context type, so passing a decoder context where an encoder is expected does not compile.

Enumerator
Invalid 

Not a direction; the default state of a context that has none.

Encoding 

Compressing frames into packets.

Decoding 

Decompressing packets into frames.

◆ Errors

enum class av::Errors
strong

The values are carried by avcpp_category(), so they compare directly with an std::error_code obtained from any avcpp call.

◆ FilterMediaType

enum class av::FilterMediaType
strong

Filters are typed: a video filter rejects audio frames and vice versa, which is what this value records when FFmpeg does not state it explicitly.

Enumerator
Unknown 

The filter did not declare a type, or it was not inspected yet.

Video 

The filter processes video frames.

Audio 

The filter processes audio samples.

◆ SwsFlags

The values mirror SWS_*; the avcpp names only prefix them for readability.

Enumerator
SwsFlagAuto 

Let libswscale pick the algorithm.

SwsFlagFastBilinear 

Bilinear filtering with reduced chroma interpolation.

SwsFlagBilinear 

Bilinear filtering.

SwsFlagBicubic 

Bicubic filtering.

SwsFlagExprerimental 

Experimental filter, kept for compatibility.

SwsFlagNeighbor 

Nearest neighbour, the fastest and crudest option.

SwsFlagArea 

Averaging over the source area; good for downscaling.

SwsFlagBicublin 

Bicubic for luma, bilinear for chroma.

SwsFlagGauss 

Gaussian filter.

SwsFlagSinc 

Sinc filter.

SwsFlagLanczos 

Lanczos filter, a good default for high quality.

SwsFlagSpline 

Spline filter.

SwsFlagPrintInfo 

Print the chosen filter configuration.

SwsFlagAccurateRnd 

Rounding mode that costs speed and gains accuracy.

SwsFlagFullChromaInt 

Full chroma interpolation by the scaler.

SwsFlagFullChromaInp 

Treat the input chroma as full resolution.

SwsFlagBitexact 

Bit-exact output where the algorithm allows it.

SwsFlagErrorDiffusion 

Error diffusion for palette conversion.

Function Documentation

◆ array_to_container() [1/4]

template<typename T, typename Container, typename Compare>
void av::array_to_container ( const T * array,
Container & container,
Compare isEnd )
Parameters
arraythe source array; null is ignored
containerdestination container
isEndpredicate that marks the terminator, evaluated before each element is appended

◆ array_to_container() [2/4]

template<typename T, typename Container, typename Compare, typename Callable>
void av::array_to_container ( const T * array,
Container & container,
Compare isEnd,
Callable convert )
Parameters
arraythe source array; null is ignored
containerdestination container
isEndpredicate that marks the terminator
convertcallable applied to each element before it is appended

◆ array_to_container() [3/4]

template<typename T, typename Container>
void av::array_to_container ( const T * array,
std::size_t nelements,
Container & container )
Parameters
arraythe source array; null is ignored
nelementsnumber of elements to copy
containerdestination container

◆ array_to_container() [4/4]

template<typename T, typename Container, typename Callable>
void av::array_to_container ( const T * array,
std::size_t nelements,
Container & container,
Callable convert )
Parameters
arraythe source array; null is ignored
nelementsnumber of elements to copy
containerdestination container
convertcallable applied to each element before it is appended

◆ avcpp_category()

const AvcppCategory & av::avcpp_category ( )
inline
Returns
the category, a process-wide singleton

◆ channel_description()

std::string av::channel_description ( AVChannel channel)
Parameters
channelthe AV_CHAN_* value
Returns
a description such as "front left"; empty for an unknown channel

◆ channel_from_string() [1/2]

AVChannel av::channel_from_string ( const char * name)
Parameters
namethe null-terminated name to resolve
Returns
the AV_CHAN_* value, or AV_CHAN_NONE when the name is unknown

◆ channel_from_string() [2/2]

AVChannel av::channel_from_string ( const std::string & name)
Parameters
namethe name to resolve, for example "FL"
Returns
the AV_CHAN_* value, or AV_CHAN_NONE when the name is unknown

◆ channel_name()

std::string av::channel_name ( AVChannel channel)
Parameters
channelthe AV_CHAN_* value
Returns
the name FFmpeg uses, for example "FL"; empty for an unknown channel

◆ clear_if()

void av::clear_if ( OptionalErrorCode ec)
inline
Parameters
ecerror code to clear

◆ dumpBinaryBuffer()

void av::dumpBinaryBuffer ( uint8_t * buffer,
int buffer_size,
int width = 16 )
Parameters
bufferpointer to buffer start
buffer_sizebuffer size
widthoutput width in hex values (real text screen with is: sw = width * 3 - 1)
Deprecated
Use av::hex_dump()

◆ error2string()

std::string av::error2string ( int error)
Parameters
error- error code to convert to string
Returns
string representation of error code

◆ ffmpeg_category()

FfmpegCategory & av::ffmpeg_category ( )
inline
Returns
the category, a process-wide singleton

◆ findDecodingCodec() [1/2]

Codec av::findDecodingCodec ( AVCodecID id)
Parameters
idthe AV_CODEC_ID_* value
Returns
the decoder, or an invalid codec when none exists
Examples
api2-decode-audio.cpp, api2-decode-filter-encode.cpp, api2-decode-rasample-audio.cpp, and api2-decode-raw-h264.cpp.

◆ findDecodingCodec() [2/2]

Codec av::findDecodingCodec ( const std::string & name)
Parameters
namethe decoder name, for example "h264"
Returns
the decoder, or an invalid codec when the name is unknown

◆ findEncodingCodec() [1/3]

Codec av::findEncodingCodec ( AVCodecID id)
Parameters
idthe AV_CODEC_ID_* value
Returns
the encoder, or an invalid codec when none exists
Examples
api2-decode-encode-audio.cpp, api2-decode-encode-video.cpp, api2-decode-filter-encode.cpp, api2-decode-overlay-encode.cpp, api2-generate-subtitles.cpp, and api2-scale-video.cpp.

◆ findEncodingCodec() [2/3]

Codec av::findEncodingCodec ( const OutputFormat & format,
bool isVideo = true )
Parameters
formatthe muxer
isVideotrue for the video codec, false for the audio one
Returns
the default encoder, or an invalid codec when the muxer has none

◆ findEncodingCodec() [3/3]

Codec av::findEncodingCodec ( const std::string & name)
Parameters
namethe encoder name, for example "libx264"
Returns
the encoder, or an invalid codec when the name is unknown

◆ freep()

template<typename T>
void av::freep ( T *& ptr)
noexcept

The pointer must come from av_malloc() or a compatible FFmpeg allocation.

Parameters
ptr

◆ gettime()

int64_t av::gettime ( )

Monotonic time source used by the library.

Returns
the current time in milliseconds since an unspecified origin

◆ guessEncodingCodec()

Codec av::guessEncodingCodec ( OutputFormat format,
const char * name,
const char * url,
const char * mime,
AVMediaType mediaType )
Parameters
formatthe muxer
namefile name that hints at the codec; may be empty
urlURL that hints at the codec; may be empty
mimeMIME type that hints at the codec; may be empty
mediaTypemedia type to guess for
Returns
the guessed encoder, or an invalid codec when nothing matches

◆ guessOutputFormat()

OutputFormat av::guessOutputFormat ( const std::string & name,
const std::string & url = std::string(),
const std::string & mime = std::string() )
Parameters
namefile name or muxer name
urlURL that hints at the format; may be empty
mimeMIME type that hints at the format; may be empty
Returns
the muxer, or an empty format when nothing matches
Examples
api2-decode-encode-audio.cpp.

◆ guessValue() [1/2]

template<typename T, typename L, typename C>
T av::guessValue ( const T & value,
const L * list,
C endListComparator )

Useful for AVCodec::supported_framerates, AVCodec::pix_fmts and so on.

T - type of value and (by default) list elements L - type of list elements C - end list comparator

If T and L different types, T must be have ctor from L.

Parameters
valuevalue to set
listlist of allowed values
endListComparatorpredicate that tells whether the element ends the list
Returns
value if list null or if it present in list, or more appropriate value from list

◆ guessValue() [2/2]

template<typename T, typename L>
requires std::ranges::range<L> && requires(L& r) { std::ranges::empty(r); }
T av::guessValue ( const T & value,
L list )

Useful for AVCodec::supported_framerates, AVCodec::pix_fmts and so on.

T - type of value and (by default) list elements L - type of list elements, range compatible

If T and elements of L has different types, T must be have ctor from L-element.

Parameters
valuevalue to set
listlist of allowed values
Returns
value if list null or if it present in list, or more appropriate value from list

◆ hex_dump() [1/2]

void av::hex_dump ( FILE * f,
const uint8_t * buf,
std::size_t size )
Parameters
fdestination stream
bufbuffer to dump; null is ignored
sizenumber of bytes to dump

◆ hex_dump() [2/2]

void av::hex_dump ( FILE * f,
std::span< const uint8_t > buf )
Parameters
fdestination stream
bufbytes to dump

◆ hex_dump_log() [1/2]

void av::hex_dump_log ( void * avcl,
int level,
const uint8_t * buf,
std::size_t size )
Parameters
avcllog context, usually a codec or format context
levelan AV_LOG_* level
bufbuffer to dump; null is ignored
sizenumber of bytes to dump

◆ hex_dump_log() [2/2]

void av::hex_dump_log ( void * avcl,
int level,
std::span< const uint8_t > buf )
Parameters
avcllog context, usually a codec or format context
levelan AV_LOG_* level
bufbytes to dump

◆ init()

◆ is_error()

bool av::is_error ( OptionalErrorCode ec)
inline
Parameters
ecthe holder to inspect
Returns
true when a variable was passed and it holds an error

◆ lexical_cast()

template<typename R, typename T>
R av::lexical_cast ( const T & v)
Template Parameters
Rthe type to produce
Tthe type to convert from
Parameters
vthe value to convert
Returns
the converted value; the result is default-constructed when the conversion fails

◆ make_array_view_size()

template<class U>
auto av::make_array_view_size ( auto * ptr,
std::size_t size )
Parameters
ptr
size
Returns
a non-owning view over the array

◆ make_array_view_until()

template<class U>
auto av::make_array_view_until ( auto * ptr,
auto value )
Parameters
ptr
value
Returns
a non-owning view that ends at the first element equal to the value

◆ make_avcpp_condition()

std::error_condition av::make_avcpp_condition ( Errors code)
inline
Parameters
codethe error
Returns
the condition in the avcpp category

◆ make_avcpp_error()

std::error_code av::make_avcpp_error ( Errors code)
inline
Parameters
codethe error
Returns
the code in the avcpp category

◆ make_error_code()

std::error_code av::make_error_code ( av::Errors errc)
inlinenoexcept
Parameters
errcthe error
Returns
the code in the avcpp category

◆ make_error_condition()

std::error_condition av::make_error_condition ( av::Errors errc)
inlinenoexcept
Parameters
errcthe error
Returns
the condition in the avcpp category

◆ make_ffmpeg_condition()

std::error_condition av::make_ffmpeg_condition ( int code)
inline
Parameters
codethe negative AVERROR value
Returns
the condition in the FFmpeg category

◆ make_ffmpeg_error()

std::error_code av::make_ffmpeg_error ( int code)
inline
Parameters
codethe negative AVERROR value
Returns
the code in the FFmpeg category

◆ malloc()

template<typename T>
std::unique_ptr< T, void(*)(void *)> av::malloc ( size_t size)
Template Parameters
Tthe element type
Parameters
sizesize in bytes
Returns
an owning pointer freed with av_free(), or a null one on failure

◆ mallocz()

template<typename T>
std::unique_ptr< T, void(*)(void *)> av::mallocz ( size_t size)
Template Parameters
Tthe element type
Parameters
sizesize in bytes
Returns
an owning pointer freed with av_free(), or a null one on failure

◆ memdup()

template<typename T>
std::unique_ptr< T, void(*)(void *)> av::memdup ( const void * p,
size_t size )
Template Parameters
Tthe element type
Parameters
psource block; may be null
sizenumber of bytes to copy
Returns
an owning pointer freed with av_free(), or a null one on failure

◆ operator!=()

bool av::operator!= ( const Timestamp & left,
const Timestamp & right )
inlinenoexcept
Parameters
leftthe left timestamp
rightthe right timestamp
Returns
true when the moments differ

◆ operator*()

Timestamp av::operator* ( const Timestamp & left,
const Timestamp & right )
noexcept
Parameters
leftthe left operand
rightthe right operand
Returns
the product

◆ operator+()

Timestamp av::operator+ ( const Timestamp & left,
const Timestamp & right )
noexcept
Parameters
leftthe left operand
rightthe right operand
Returns
the sum

◆ operator-()

Timestamp av::operator- ( const Timestamp & left,
const Timestamp & right )
noexcept
Parameters
leftthe left operand
rightthe right operand
Returns
the difference

◆ operator/() [1/3]

Timestamp av::operator/ ( const Timestamp & left,
const Timestamp & right )
noexcept
Parameters
leftthe left operand
rightthe right operand
Returns
the quotient

◆ operator/() [2/3]

template<typename T>
auto av::operator/ ( Rational value,
T num ) -> std::enable_if_t< std::is_floating_point_v< T >||std::is_integral_v< T >, Rational >
Template Parameters
Tarithmetic type
Parameters
valuethe dividend
numthe divisor
Returns
the quotient as a rational

◆ operator/() [3/3]

template<typename T>
auto av::operator/ ( T num,
Rational value ) -> std::enable_if_t< std::is_floating_point_v< T >||std::is_integral_v< T >, Rational >
Template Parameters
Tarithmetic type
Parameters
numthe dividend
valuethe divisor
Returns
the quotient as a rational

◆ operator<()

bool av::operator< ( const Timestamp & left,
const Timestamp & right )
inlinenoexcept
Parameters
leftthe left timestamp
rightthe right timestamp
Returns
true when the left one is earlier

◆ operator<<() [1/2]

std::ostream & av::operator<< ( std::ostream & ost,
const Timestamp & ts )
inline
Parameters
ostthe stream to write to
tsthe timestamp to print
Returns
the stream, for chaining

◆ operator<<() [2/2]

std::ostream & av::operator<< ( std::ostream & stream,
const Rational & value )
inline
Parameters
streamthe stream to write to
valuethe rational to print
Returns
the stream, for chaining

◆ operator<=()

bool av::operator<= ( const Timestamp & left,
const Timestamp & right )
inlinenoexcept
Parameters
leftthe left timestamp
rightthe right timestamp
Returns
true when the left one is not later

◆ operator==()

bool av::operator== ( const Timestamp & left,
const Timestamp & right )
inlinenoexcept
Parameters
leftthe left timestamp
rightthe right timestamp
Returns
true when both denote the same moment

◆ operator>()

bool av::operator> ( const Timestamp & left,
const Timestamp & right )
inlinenoexcept
Parameters
leftthe left timestamp
rightthe right timestamp
Returns
true when the left one is later

◆ operator>=()

bool av::operator>= ( const Timestamp & left,
const Timestamp & right )
inlinenoexcept
Parameters
leftthe left timestamp
rightthe right timestamp
Returns
true when the left one is not earlier

◆ operator>>()

std::istream & av::operator>> ( std::istream & stream,
Rational & value )
inline
Parameters
streamthe stream to read from
valuethe rational to fill; left unchanged when parsing fails
Returns
the stream, for chaining

◆ set_logging_level() [1/2]

void av::set_logging_level ( const std::string & level)
See also
set_logging_level, but can assept logging level as string.
Parameters
level- string representation of loggin level: 'quiet', 'panic', 'fatal', 'error', 'warning', 'info', 'verbose' or 'debug', it also can be numeric (but in string representation), it it case boost::lexical_cast will be used and set_logging_level(int32_t) will be called.

◆ set_logging_level() [2/2]

void av::set_logging_level ( int32_t level)
Parameters
levelAn integer value for level. Lower numbers mean less logging. A negative number tells FFmpeg to shut up.
Examples
api2-remux.cpp.

◆ strdup()

std::unique_ptr< char, void(*)(void *)> av::strdup ( std::string_view value)
inline

Returns nullptr for an empty input.

Parameters
value
Returns
an owning pointer freed with av_free(), or a null one for an empty input

◆ throw_error_code() [1/2]

template<typename Exception = av::Exception>
void av::throw_error_code ( const std::error_code & ec)
Template Parameters
Exceptionexception type to throw
Parameters
ecthe error to throw

◆ throw_error_code() [2/2]

template<typename Exception = av::Exception>
void av::throw_error_code ( Errors errc)
Template Parameters
Exceptionexception type to throw
Parameters
errcthe error to throw

◆ throws()

OptionalErrorCode av::throws ( )
inline
Returns
null OptionalErrorCode object

◆ throws_if() [1/2]

template<typename Category, typename Exception = av::Exception>
void av::throws_if ( OptionalErrorCode ec,
int errcode,
const Category & cat )
Parameters
ecthe caller's choice between exceptions and error codes
errcodethe raw error value
catthe category the value belongs to

◆ throws_if() [2/2]

template<typename T, typename Exception = av::Exception>
void av::throws_if ( OptionalErrorCode ec,
T errcode )
Template Parameters
Terror type with an std::error_code adapter
Parameters
ecthe caller's choice between exceptions and error codes
errcodethe error value

◆ usleep()

int av::usleep ( unsigned usec)

Although the duration is expressed in microseconds, the actual delay may be rounded to the precision of the system timer.

Parameters
usecNumber of microseconds to sleep.
Returns
zero on success or (negative) error code.

◆ wrap2sview()

std::string_view av::wrap2sview ( const char * value)
inlinenoexcept
Parameters
value
Returns
a view of the string, or an empty view for null

Variable Documentation

◆ NoPts

auto av::NoPts = static_cast<int64_t>(AV_NOPTS_VALUE)
constexpr

The avcpp spelling of AV_NOPTS_VALUE; compare timestamps against it instead of hard-coding the integer.

Examples
api2-decode-audio.cpp, and api2-decode-encode-audio.cpp.