FFmpeg Low-Level Reference

This page documents low-level FFmpeg constants, types, and functions that are available through VideoIO's libffmpeg module.

Overview

VideoIO provides Julia bindings to FFmpeg through the VideoIO.libffmpeg module. This module contains over 1,000 functions, constants, and types from FFmpeg's C libraries. While most users will use VideoIO's high-level API (see Reading Videos and Writing Videos), advanced users may need direct access to FFmpeg functionality.

FFmpeg Subpackages

Each FFmpeg library is exposed as a VideoIO subpackage:

FFmpeg LibraryVideoIO ModuleDescription
libavcodecAVCodecsCodec library - encoding/decoding
libavdeviceAVDeviceDevice library - camera/screen capture
libavfilterAVFiltersFilter library - video/audio processing
libavformatAVFormatFormat library - muxing/demuxing
libavutilAVUtilUtility library - common functions
libswscaleSWScaleScaling library - pixel format conversion
libswresampleSWResampleResampling library - audio conversion

Usage Example

using VideoIO

# Access low-level FFmpeg functionality
import VideoIO.libffmpeg

# Check pixel format constant
pix_fmt = VideoIO.libffmpeg.AV_PIX_FMT_RGB24

# Use AVRational for time base
time_base = VideoIO.libffmpeg.AVRational(1, 30)  # 1/30 second per frame

# Convert to Julia Rational
julia_rational = Rational(time_base.num, time_base.den)

Key Concepts

Pixel Formats: FFmpeg supports numerous pixel formats via AV_PIX_FMT_* constants. Common ones include:

  • AV_PIX_FMT_RGB24 - Packed RGB 8:8:8, 24bpp
  • AV_PIX_FMT_GRAY8 - Grayscale, 8bpp
  • AV_PIX_FMT_YUV420P - Planar YUV 4:2:0, 12bpp

Media Types: Stream types are identified by AVMEDIA_TYPE_* constants:

  • AVMEDIA_TYPE_VIDEO - Video stream
  • AVMEDIA_TYPE_AUDIO - Audio stream
  • AVMEDIA_TYPE_SUBTITLE - Subtitle stream

Special Values:

  • AV_NOPTS_VALUE - Indicates no presentation timestamp (0x8000000000000000)
  • AVPROBE_SCORE_MAX - Maximum probe score (100)

Codec Properties:

  • AV_CODEC_PROP_FIELDS - Flag indicating field-based (interlaced) codec support

For detailed information on FFmpeg 8 compatibility changes, see:

Complete API Reference

The following sections provide auto-generated documentation for all exported items in VideoIO.libffmpeg.

Functions

VideoIO.libffmpeg.av_add_index_entryMethod
av_add_index_entry(st, pos::Int64, timestamp::Int64, size::Integer, distance::Integer, flags::Integer)

Add an index entry into a sorted list. Update the entry if the list already contains it.

Arguments

  • timestamp: timestamp in the time base of the given stream
source
VideoIO.libffmpeg.av_add_stableMethod
av_add_stable(ts_tb::AVRational, ts::Int64, inc_tb::AVRational, inc::Int64)

Add a value to a timestamp.

This function guarantees that when the same value is repeatedly added that no accumulation of rounding errors occurs.

Arguments

  • ts:[in] Input timestamp
  • ts_tb:[in] Input timestamp time base
  • inc:[in] Value to be added
  • inc_tb:[in] Time base of inc
source
VideoIO.libffmpeg.av_adler32_updateMethod
av_adler32_update(adler::AVAdler, buf, len::Csize_t)

Calculate the Adler32 checksum of a buffer.

Passing the return value to a subsequent av_adler32_update() call allows the checksum of multiple buffers to be calculated as though they were concatenated.

Arguments

  • adler: initial checksum value
  • buf: pointer to input buffer
  • len: size of input buffer

Returns

updated checksum

source
VideoIO.libffmpeg.av_adts_header_parseMethod
av_adts_header_parse(buf, samples, frames)

Extract the number of samples and frames from AAC data.

Arguments

  • buf:[in] pointer to AAC data buffer
  • samples:[out] Pointer to where number of samples is written
  • frames:[out] Pointer to where number of frames is written

Returns

Returns 0 on success, error code on failure.

source
VideoIO.libffmpeg.av_aes_cryptMethod
av_aes_crypt(a, dst, src, count::Integer, iv, decrypt::Integer)

Encrypt or decrypt a buffer using a previously initialized context.

Arguments

  • a: The AVAES context
  • dst: destination array, can be equal to src
  • src: source array, can be equal to dst
  • count: number of 16 byte blocks
  • iv: initialization vector for CBC mode, if NULL then ECB will be used
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_aes_ctr_cryptMethod
av_aes_ctr_crypt(a, dst, src, size::Integer)

Process a buffer using a previously initialized context.

Arguments

  • a: The AVAESCTR context
  • dst: destination array, can be equal to src
  • src: source array, can be equal to dst
  • size: the size of src and dst
source
VideoIO.libffmpeg.av_aes_initMethod
av_aes_init(a, key, key_bits::Integer, decrypt::Integer)

Initialize an AVAES context.

Arguments

  • a: The AVAES context
  • key: Pointer to the key
  • key_bits: 128, 192 or 256
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_append_packetMethod
av_append_packet(s, pkt, size::Integer)

Read data and append it to the current content of the AVPacket. If pkt->size is 0 this is identical to av_get_packet. Note that this uses av_grow_packet and thus involves a realloc which is inefficient. Thus this function should only be used when there is no reasonable way to know (an upper bound of) the final size.

Arguments

  • s: associated IO context
  • pkt: packet
  • size: amount of data to read

Returns

0 (read size) if OK, AVERROR_xxx otherwise, previous data will not be lost even if an error occurs.

source
VideoIO.libffmpeg.av_append_path_componentMethod
av_append_path_component(path, component)

Append path component to the existing path. Path separator '/' is placed between when needed. Resulting string have to be freed with av_free().

Arguments

  • path: base path
  • component: component to be appended

Returns

new path or NULL on error.

source
VideoIO.libffmpeg.av_audio_fifo_allocMethod
av_audio_fifo_alloc(sample_fmt::AVSampleFormat, channels::Integer, nb_samples::Integer)

Allocate an AVAudioFifo.

Arguments

  • sample_fmt: sample format
  • channels: number of channels
  • nb_samples: initial allocation size, in samples

Returns

newly allocated AVAudioFifo, or NULL on error

source
VideoIO.libffmpeg.av_audio_fifo_peekMethod
av_audio_fifo_peek(af, data, nb_samples::Integer)

Peek data from an AVAudioFifo.

Arguments

  • af: AVAudioFifo to read from
  • data: audio data plane pointers
  • nb_samples: number of samples to peek

Returns

number of samples actually peek, or negative AVERROR code on failure. The number of samples actually peek will not be greater than nb_samples, and will only be less than nb_samples if av_audio_fifo_size is less than nb_samples.

See also

enum AVSampleFormat The documentation for AVSampleFormat describes the data layout.

source
VideoIO.libffmpeg.av_audio_fifo_peek_atMethod
av_audio_fifo_peek_at(af, data, nb_samples::Integer, offset::Integer)

Peek data from an AVAudioFifo.

Arguments

  • af: AVAudioFifo to read from
  • data: audio data plane pointers
  • nb_samples: number of samples to peek
  • offset: offset from current read position

Returns

number of samples actually peek, or negative AVERROR code on failure. The number of samples actually peek will not be greater than nb_samples, and will only be less than nb_samples if av_audio_fifo_size is less than nb_samples.

See also

enum AVSampleFormat The documentation for AVSampleFormat describes the data layout.

source
VideoIO.libffmpeg.av_audio_fifo_readMethod
av_audio_fifo_read(af, data, nb_samples::Integer)

Read data from an AVAudioFifo.

Arguments

  • af: AVAudioFifo to read from
  • data: audio data plane pointers
  • nb_samples: number of samples to read

Returns

number of samples actually read, or negative AVERROR code on failure. The number of samples actually read will not be greater than nb_samples, and will only be less than nb_samples if av_audio_fifo_size is less than nb_samples.

See also

enum AVSampleFormat The documentation for AVSampleFormat describes the data layout.

source
VideoIO.libffmpeg.av_audio_fifo_writeMethod
av_audio_fifo_write(af, data, nb_samples::Integer)

Write data to an AVAudioFifo.

The AVAudioFifo will be reallocated automatically if the available space is less than nb_samples.

Arguments

  • af: AVAudioFifo to write to
  • data: audio data plane pointers
  • nb_samples: number of samples to write

Returns

number of samples actually written, or negative AVERROR code on failure. If successful, the number of samples actually written will always be nb_samples.

See also

enum AVSampleFormat The documentation for AVSampleFormat describes the data layout.

source
VideoIO.libffmpeg.av_base64_decodeMethod
av_base64_decode(out, in, out_size::Integer)

Decode a base64-encoded string.

Arguments

  • out: buffer for decoded data
  • in: null-terminated input string
  • out_size: size in bytes of the out buffer, must be at least 3/4 of the length of in, that is AV_BASE64_DECODE_SIZE(strlen(in))

Returns

number of bytes written, or a negative value in case of invalid input

source
VideoIO.libffmpeg.av_base64_encodeMethod
av_base64_encode(out, out_size::Integer, in, in_size::Integer)

Encode data to base64 and null-terminate.

Arguments

  • out: buffer for encoded data
  • out_size: size in bytes of the out buffer (including the null terminator), must be at least AV_BASE64_SIZE(in_size)
  • in: input buffer containing the data to encode
  • in_size: size in bytes of the in buffer

Returns

out or NULL in case of error

source
VideoIO.libffmpeg.av_basenameMethod
av_basename(path)

Thread safe basename.

Arguments

  • path: the string to parse, on DOS both \ and / are considered separators.

Returns

pointer to the basename substring. If path does not contain a slash, the function returns a copy of path. If path is a NULL pointer or points to an empty string, a pointer to a string "." is returned.

source
VideoIO.libffmpeg.av_blowfish_cryptMethod
av_blowfish_crypt(ctx, dst, src, count::Integer, iv, decrypt::Integer)

Encrypt or decrypt a buffer using a previously initialized context.

Arguments

  • ctx: an AVBlowfish context
  • dst: destination array, can be equal to src
  • src: source array, can be equal to dst
  • count: number of 8 byte blocks
  • iv: initialization vector for CBC mode, if NULL ECB will be used
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_blowfish_crypt_ecbMethod
av_blowfish_crypt_ecb(ctx, xl, xr, decrypt::Integer)

Encrypt or decrypt a buffer using a previously initialized context.

Arguments

  • ctx: an AVBlowfish context
  • xl: left four bytes halves of input to be encrypted
  • xr: right four bytes halves of input to be encrypted
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_bmg_getMethod
av_bmg_get(lfg, out)

Get the next two numbers generated by a Box-Muller Gaussian generator using the random numbers issued by lfg.

Arguments

  • lfg: pointer to the context structure
  • out: array where the two generated numbers are placed
source
VideoIO.libffmpeg.av_bprint_escapeMethod
av_bprint_escape(dstbuf, src, special_chars, mode::AVEscapeMode, flags::Integer)

Escape the content in src and append it to dstbuf.

Arguments

  • dstbuf: already inited destination bprint buffer
  • src: string containing the text to escape
  • special_chars: string containing the special characters which need to be escaped, can be NULL
  • mode: escape mode to employ, see AV_ESCAPE_MODE_* macros. Any unknown value for mode will be considered equivalent to AV_ESCAPE_MODE_BACKSLASH, but this behaviour can change without notice.
  • flags: flags which control how to escape, see AV_ESCAPE_FLAG_* macros
source
VideoIO.libffmpeg.av_bprint_finalizeMethod
av_bprint_finalize(buf, ret_str)

Finalize a print buffer.

The print buffer can no longer be used afterwards, but the len and size fields are still valid.

  • [out] ret_str if not NULL, used to return a permanent copy of the buffer contents, or NULL if memory allocation fails; if NULL, the buffer is discarded and freed

Returns

0 for success or error code (probably AVERROR(ENOMEM))

source
VideoIO.libffmpeg.av_bprint_get_bufferMethod
av_bprint_get_buffer(buf, size::Integer, mem, actual_size)

Allocate bytes in the buffer for external use.

Arguments

  • buf:[in] buffer structure
  • size:[in] required size
  • mem:[out] pointer to the memory area
  • actual_size:[out] size of the memory area after allocation; can be larger or smaller than size
source
VideoIO.libffmpeg.av_bprint_initMethod
av_bprint_init(buf, size_init::Integer, size_max::Integer)

Init a print buffer.

Arguments

  • buf: buffer to init
  • size_init: initial size (including the final 0)
  • size_max: maximum size; - 0 means do not write anything, just count the length - 1 is replaced by the maximum value for automatic storage any large value means that the internal buffer will be reallocated as needed up to that limit - -1 is converted to UINT_MAX, the largest limit possible. Check also AV\_BPRINT\_SIZE\_* macros.
source
VideoIO.libffmpeg.av_bprint_is_completeMethod
av_bprint_is_complete(buf)

Test if the print buffer is complete (not truncated).

It may have been truncated due to a memory allocation failure or the size_max limit (compare size and size_max if necessary).

source
VideoIO.libffmpeg.av_bprint_strftimeMethod
av_bprint_strftime(buf, fmt, tm_)

Append a formatted date and time to a print buffer.

Note

due to poor design of the standard strftime function, it may produce poor results if the format string expands to a very long text and the bprint buffer is near the limit stated by the size_max option.

Arguments

  • buf: bprint buffer to use
  • fmt: date and time format string, see strftime()
  • tm: broken-down time structure to translate
source
VideoIO.libffmpeg.av_bsf_allocMethod
av_bsf_alloc(filter, ctx)

Allocate a context for a given bitstream filter. The caller must fill in the context parameters as described in the documentation and then call av_bsf_init() before sending any data to the filter.

Arguments

  • filter: the filter for which to allocate an instance.
  • ctx:[out] a pointer into which the pointer to the newly-allocated context will be written. It must be freed with av_bsf_free() after the filtering is done.

Returns

0 on success, a negative AVERROR code on failure

source
VideoIO.libffmpeg.av_bsf_iterateMethod
av_bsf_iterate(opaque)

Iterate over all registered bitstream filters.

Arguments

  • opaque: a pointer where libavcodec will store the iteration state. Must point to NULL to start the iteration.

Returns

the next registered bitstream filter or NULL when the iteration is finished

source
VideoIO.libffmpeg.av_bsf_list_appendMethod
av_bsf_list_append(lst, bsf)

Append bitstream filter to the list of bitstream filters.

Arguments

  • lst: List to append to
  • bsf: Filter context to be appended

Returns

=0 on success, negative AVERROR in case of failure

source
VideoIO.libffmpeg.av_bsf_list_append2Method
av_bsf_list_append2(lst, bsf_name, options)

Construct new bitstream filter context given it's name and options and append it to the list of bitstream filters.

Arguments

  • lst: List to append to
  • bsf_name: Name of the bitstream filter
  • options: Options for the bitstream filter, can be set to NULL

Returns

=0 on success, negative AVERROR in case of failure

source
VideoIO.libffmpeg.av_bsf_list_finalizeMethod
av_bsf_list_finalize(lst, bsf)

Finalize list of bitstream filters.

This function will transform AVBSFList to single AVBSFContext, so the whole chain of bitstream filters can be treated as single filter freshly allocated by av_bsf_alloc(). If the call is successful, AVBSFList structure is freed and lst will be set to NULL. In case of failure, caller is responsible for freeing the structure by av_bsf_list_free()

Arguments

  • lst: Filter list structure to be transformed
  • bsf:[out] Pointer to be set to newly created AVBSFContext structure representing the chain of bitstream filters

Returns

=0 on success, negative AVERROR in case of failure

source
VideoIO.libffmpeg.av_bsf_list_parse_strMethod
av_bsf_list_parse_str(str, bsf)

Parse string describing list of bitstream filters and create single AVBSFContext describing the whole chain of bitstream filters. Resulting AVBSFContext can be treated as any other AVBSFContext freshly allocated by av_bsf_alloc().

Arguments

  • str: String describing chain of bitstream filters in format bsf1[=opt1=val1:opt2=val2][,bsf2]
  • bsf:[out] Pointer to be set to newly created AVBSFContext structure representing the chain of bitstream filters

Returns

=0 on success, negative AVERROR in case of failure

source
VideoIO.libffmpeg.av_bsf_receive_packetMethod
av_bsf_receive_packet(ctx, pkt)

Retrieve a filtered packet.

Note

one input packet may result in several output packets, so after sending a packet with av_bsf_send_packet(), this function needs to be called repeatedly until it stops returning 0. It is also possible for a filter to output fewer packets than were sent to it, so this function may return AVERROR(EAGAIN) immediately after a successful av_bsf_send_packet() call.

Arguments

  • ctx: an initialized AVBSFContext
  • pkt:[out] this struct will be filled with the contents of the filtered packet. It is owned by the caller and must be freed using av_packet_unref() when it is no longer needed. This parameter should be "clean" (i.e. freshly allocated with av_packet_alloc() or unreffed with av_packet_unref()) when this function is called. If this function returns successfully, the contents of pkt will be completely overwritten by the returned data. On failure, pkt is not touched.

Returns

  • 0 on success. - AVERROR(EAGAIN) if more packets need to be sent to the filter (using av_bsf_send_packet()) to get more output. - AVERROR_EOF if there will be no further output from the filter. - Another negative AVERROR value if an error occurs.
source
VideoIO.libffmpeg.av_bsf_send_packetMethod
av_bsf_send_packet(ctx, pkt)

Submit a packet for filtering.

After sending each packet, the filter must be completely drained by calling av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or AVERROR_EOF.

Arguments

  • ctx: an initialized AVBSFContext
  • pkt: the packet to filter. The bitstream filter will take ownership of the packet and reset the contents of pkt. pkt is not touched if an error occurs. If pkt is empty (i.e. NULL, or pkt->data is NULL and pkt->side_data_elems zero), it signals the end of the stream (i.e. no more non-empty packets will be sent; sending more empty packets does nothing) and will cause the filter to output any packets it may have buffered internally.

Returns

  • 0 on success. - AVERROR(EAGAIN) if packets need to be retrieved from the filter (using av_bsf_receive_packet()) before new input can be consumed. - Another negative AVERROR value if an error occurs.
source
VideoIO.libffmpeg.av_buffer_createMethod
av_buffer_create(data, size::Csize_t, free, opaque, flags::Integer)

Create an AVBuffer from an existing array.

If this function is successful, data is owned by the AVBuffer. The caller may only access data through the returned AVBufferRef and references derived from it. If this function fails, data is left untouched.

Arguments

  • data: data array
  • size: size of data in bytes
  • free: a callback for freeing this buffer's data
  • opaque: parameter to be got for processing or passed to free
  • flags: a combination of AV_BUFFER_FLAG_*

Returns

an AVBufferRef referring to data on success, NULL on failure.

source
VideoIO.libffmpeg.av_buffer_make_writableMethod
av_buffer_make_writable(buf)

Create a writable reference from a given buffer reference, avoiding data copy if possible.

Arguments

  • buf: buffer reference to make writable. On success, buf is either left untouched, or it is unreferenced and a new writable AVBufferRef is written in its place. On failure, buf is left untouched.

Returns

0 on success, a negative AVERROR on failure.

source
VideoIO.libffmpeg.av_buffer_pool_buffer_get_opaqueMethod
av_buffer_pool_buffer_get_opaque(ref)

Query the original opaque parameter of an allocated buffer in the pool.

Note

the opaque parameter of ref is used by the buffer pool implementation, therefore you have to use this function to access the original opaque parameter of an allocated buffer.

Arguments

Returns

the opaque parameter set by the buffer allocator function of the buffer pool.

source
VideoIO.libffmpeg.av_buffer_pool_getMethod
av_buffer_pool_get(pool)

Allocate a new AVBuffer, reusing an old buffer from the pool when available. This function may be called simultaneously from multiple threads.

Returns

a reference to the new buffer on success, NULL on error.

source
VideoIO.libffmpeg.av_buffer_pool_initMethod
av_buffer_pool_init(size::Csize_t, alloc)

Allocate and initialize a buffer pool.

Arguments

  • size: size of each buffer in this pool
  • alloc: a function that will be used to allocate new buffers when the pool is empty. May be NULL, then the default allocator will be used (av_buffer_alloc()).

Returns

newly created buffer pool on success, NULL on error.

source
VideoIO.libffmpeg.av_buffer_pool_init2Method
av_buffer_pool_init2(size::Csize_t, opaque, alloc, pool_free)

Allocate and initialize a buffer pool with a more complex allocator.

Arguments

  • size: size of each buffer in this pool
  • opaque: arbitrary user data used by the allocator
  • alloc: a function that will be used to allocate new buffers when the pool is empty. May be NULL, then the default allocator will be used (av_buffer_alloc()).
  • pool_free: a function that will be called immediately before the pool is freed. I.e. after av_buffer_pool_uninit() is called by the caller and all the frames are returned to the pool and freed. It is intended to uninitialize the user opaque data. May be NULL.

Returns

newly created buffer pool on success, NULL on error.

source
VideoIO.libffmpeg.av_buffer_pool_uninitMethod
av_buffer_pool_uninit(pool)

Mark the pool as being available for freeing. It will actually be freed only once all the allocated buffers associated with the pool are released. Thus it is safe to call this function while some of the allocated buffers are still in use.

Arguments

  • pool: pointer to the pool to be freed. It will be set to NULL.
source
VideoIO.libffmpeg.av_buffer_reallocMethod
av_buffer_realloc(buf, size::Csize_t)

Reallocate a given buffer.

Note

the buffer is actually reallocated with av_realloc() only if it was initially allocated through av_buffer_realloc(NULL) and there is only one reference to it (i.e. the one passed to this function). In all other cases a new buffer is allocated and the data is copied.

Arguments

  • buf: a buffer reference to reallocate. On success, buf will be unreferenced and a new reference with the required size will be written in its place. On failure buf will be left untouched. *buf may be NULL, then a new buffer is allocated.
  • size: required new buffer size.

Returns

0 on success, a negative AVERROR on failure.

source
VideoIO.libffmpeg.av_buffer_replaceMethod
av_buffer_replace(dst, src)

Ensure dst refers to the same data as src.

When *dst is already equivalent to src, do nothing. Otherwise unreference dst and replace it with a new reference to src.

Arguments

  • dst: Pointer to either a valid buffer reference or NULL. On success, this will point to a buffer reference equivalent to src. On failure, dst will be left untouched.
  • src: A buffer reference to replace dst with. May be NULL, then this function is equivalent to av_buffer_unref(dst).

Returns

0 on success AVERROR(ENOMEM) on memory allocation failure.

source
VideoIO.libffmpeg.av_buffer_unrefMethod
av_buffer_unref(buf)

Free a given reference and automatically free the buffer if there are no more references to it.

Arguments

  • buf: the reference to be freed. The pointer is set to NULL on return.
source
VideoIO.libffmpeg.av_buffersink_get_frameMethod
av_buffersink_get_frame(ctx, frame)

Get a frame with filtered data from sink and put it in frame.

Arguments

  • ctx: pointer to a context of a buffersink or abuffersink AVFilter.
  • frame: pointer to an allocated frame that will be filled with data. The data must be freed using av_frame_unref() / av_frame_free()

Returns

  • = 0 if a frame was successfully returned. - AVERROR(EAGAIN) if no frames are available at this point; more input frames must be added to the filtergraph to get more output. - AVERROR_EOF if there will be no more output frames on this sink. - A different negative AVERROR code in other failure cases.

source
VideoIO.libffmpeg.av_buffersink_get_frame_flagsMethod
av_buffersink_get_frame_flags(ctx, frame, flags::Integer)

Get a frame with filtered data from sink and put it in frame.

Arguments

  • ctx: pointer to a buffersink or abuffersink filter context.
  • frame: pointer to an allocated frame that will be filled with data. The data must be freed using av_frame_unref() / av_frame_free()
  • flags: a combination of AV_BUFFERSINK_FLAG_* flags

Returns

= 0 in for success, a negative AVERROR code for failure.

source
VideoIO.libffmpeg.av_buffersink_get_samplesMethod
av_buffersink_get_samples(ctx, frame, nb_samples::Integer)

Same as av_buffersink_get_frame(), but with the ability to specify the number of samples read. This function is less efficient than av_buffersink_get_frame(), because it copies the data around.

Warning

do not mix this function with av_buffersink_get_frame(). Use only one or the other with a single sink, not both.

Arguments

  • ctx: pointer to a context of the abuffersink AVFilter.
  • frame: pointer to an allocated frame that will be filled with data. The data must be freed using av_frame_unref() / av_frame_free() frame will contain exactly nb_samples audio samples, except at the end of stream, when it can contain less than nb_samples.

Returns

The return codes have the same meaning as for av_buffersink_get_frame().

source
VideoIO.libffmpeg.av_buffersink_set_frame_sizeMethod
av_buffersink_set_frame_size(ctx, frame_size::Integer)

Set the frame size for an audio buffer sink.

All calls to av_buffersink_get_buffer_ref will return a buffer with exactly the specified number of samples, or AVERROR(EAGAIN) if there is not enough. The last buffer at EOF will be padded with 0.

source
VideoIO.libffmpeg.av_buffersrc_add_frameMethod
av_buffersrc_add_frame(ctx, frame)

Add a frame to the buffer source.

Note

the difference between this function and av_buffersrc_write_frame() is that av_buffersrc_write_frame() creates a new reference to the input frame, while this function takes ownership of the reference passed to it.

This function is equivalent to av_buffersrc_add_frame_flags() without the AV_BUFFERSRC_FLAG_KEEP_REF flag.

Arguments

  • ctx: an instance of the buffersrc filter
  • frame: frame to be added. If the frame is reference counted, this function will take ownership of the reference(s) and reset the frame. Otherwise the frame data will be copied. If this function returns an error, the input frame is not touched.

Returns

0 on success, a negative AVERROR on error.

source
VideoIO.libffmpeg.av_buffersrc_add_frame_flagsMethod
av_buffersrc_add_frame_flags(buffer_src, frame, flags::Integer)

Add a frame to the buffer source.

By default, if the frame is reference-counted, this function will take ownership of the reference(s) and reset the frame. This can be controlled using the flags.

If this function returns an error, the input frame is not touched.

Arguments

  • buffer_src: pointer to a buffer source context
  • frame: a frame, or NULL to mark EOF
  • flags: a combination of AV_BUFFERSRC_FLAG_*

Returns

= 0 in case of success, a negative AVERROR code in case of failure

source
VideoIO.libffmpeg.av_buffersrc_parameters_setMethod
av_buffersrc_parameters_set(ctx, param)

Initialize the buffersrc or abuffersrc filter with the provided parameters. This function may be called multiple times, the later calls override the previous ones. Some of the parameters may also be set through AVOptions, then whatever method is used last takes precedence.

Arguments

  • ctx: an instance of the buffersrc or abuffersrc filter
  • param: the stream parameters. The frames later passed to this filter must conform to those parameters. All the allocated fields in param remain owned by the caller, libavfilter will make internal copies or references when necessary.

Returns

0 on success, a negative AVERROR code on failure.

source
VideoIO.libffmpeg.av_buffersrc_write_frameMethod
av_buffersrc_write_frame(ctx, frame)

Add a frame to the buffer source.

This function is equivalent to av_buffersrc_add_frame_flags() with the AV_BUFFERSRC_FLAG_KEEP_REF flag.

Arguments

  • ctx: an instance of the buffersrc filter
  • frame: frame to be added. If the frame is reference counted, this function will make a new reference to it. Otherwise the frame data will be copied.

Returns

0 on success, a negative AVERROR on error

source
VideoIO.libffmpeg.av_callocMethod
av_calloc(nmemb::Csize_t, size::Csize_t)

Allocate a memory block for an array with av_mallocz().

The allocated memory will have size size * nmemb bytes.

Arguments

  • nmemb: Number of elements
  • size: Size of the single element

Returns

Pointer to the allocated block, or NULL if the block cannot be allocated

See also

av_mallocz(), av_malloc_array()

source
VideoIO.libffmpeg.av_camellia_cryptMethod
av_camellia_crypt(ctx, dst, src, count::Integer, iv, decrypt::Integer)

Encrypt or decrypt a buffer using a previously initialized context

Arguments

  • ctx: an AVCAMELLIA context
  • dst: destination array, can be equal to src
  • src: source array, can be equal to dst
  • count: number of 16 byte blocks
  • iv: initialization vector for CBC mode, NULL for ECB mode
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_cast5_cryptMethod
av_cast5_crypt(ctx, dst, src, count::Integer, decrypt::Integer)

Encrypt or decrypt a buffer using a previously initialized context, ECB mode only

Arguments

  • ctx: an AVCAST5 context
  • dst: destination array, can be equal to src
  • src: source array, can be equal to dst
  • count: number of 8 byte blocks
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_cast5_crypt2Method
av_cast5_crypt2(ctx, dst, src, count::Integer, iv, decrypt::Integer)

Encrypt or decrypt a buffer using a previously initialized context

Arguments

  • ctx: an AVCAST5 context
  • dst: destination array, can be equal to src
  • src: source array, can be equal to dst
  • count: number of 8 byte blocks
  • iv: initialization vector for CBC mode, NULL for ECB mode
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_cast5_initMethod
av_cast5_init(ctx, key, key_bits::Integer)

Initialize an AVCAST5 context.

Arguments

  • ctx: an AVCAST5 context
  • key: a key of 5,6,...16 bytes used for encryption/decryption
  • key_bits: number of keybits: possible are 40,48,...,128

Returns

0 on success, less than 0 on failure

source
VideoIO.libffmpeg.av_channel_descriptionMethod
av_channel_description(buf, buf_size::Csize_t, channel::AVChannel)

Get a human readable string describing a given channel.

Arguments

  • buf: pre-allocated buffer where to put the generated string
  • buf_size: size in bytes of the buffer.
  • channel: the AVChannel whose description to get

Returns

amount of bytes needed to hold the output string, or a negative AVERROR on failure. If the returned value is bigger than buf_size, then the string was truncated.

source
VideoIO.libffmpeg.av_channel_layout_ambisonic_orderMethod
av_channel_layout_ambisonic_order(channel_layout)

Return the order if the layout is n-th order standard-order ambisonic. The presence of optional extra non-diegetic channels at the end is not taken into account.

Arguments

  • channel_layout: input channel layout

Returns

the order of the layout, a negative error code otherwise.

source
VideoIO.libffmpeg.av_channel_layout_channel_from_indexMethod
av_channel_layout_channel_from_index(channel_layout, idx::Integer)

Get the channel with the given index in a channel layout.

Arguments

  • channel_layout: input channel layout
  • idx: index of the channel

Returns

channel with the index idx in channel_layout on success or AV_CHAN_NONE on failure (if idx is not valid or the channel order is unspecified)

source
VideoIO.libffmpeg.av_channel_layout_channel_from_stringMethod
av_channel_layout_channel_from_string(channel_layout, name)

Get a channel described by the given string.

This function accepts channel names in the same format as avchannelfrom_string().

Arguments

  • channel_layout: input channel layout
  • name: string describing the channel to obtain

Returns

a channel described by the given string in channel_layout on success or AV_CHAN_NONE on failure (if the string is not valid or the channel order is unspecified)

source
VideoIO.libffmpeg.av_channel_layout_checkMethod
av_channel_layout_check(channel_layout)

Check whether a channel layout is valid, i.e. can possibly describe audio data.

Arguments

  • channel_layout: input channel layout

Returns

1 if channel_layout is valid, 0 otherwise.

source
VideoIO.libffmpeg.av_channel_layout_compareMethod
av_channel_layout_compare(chl, chl1)

Check whether two channel layouts are semantically the same, i.e. the same channels are present on the same positions in both.

If one of the channel layouts is AV_CHANNEL_ORDER_UNSPEC, while the other is not, they are considered to be unequal. If both are AV_CHANNEL_ORDER_UNSPEC, they are considered equal iff the channel counts are the same in both.

Arguments

  • chl: input channel layout
  • chl1: input channel layout

Returns

0 if chl and chl1 are equal, 1 if they are not equal. A negative AVERROR code if one or both are invalid.

source
VideoIO.libffmpeg.av_channel_layout_copyMethod
av_channel_layout_copy(dst, src)

Make a copy of a channel layout. This differs from just assigning src to dst in that it allocates and copies the map for AV_CHANNEL_ORDER_CUSTOM.

Note

the destination channel_layout will be always uninitialized before copy.

Arguments

  • dst: destination channel layout
  • src: source channel layout

Returns

0 on success, a negative AVERROR on error.

source
VideoIO.libffmpeg.av_channel_layout_custom_initMethod
av_channel_layout_custom_init(channel_layout, nb_channels::Integer)

Initialize a custom channel layout with the specified number of channels. The channel map will be allocated and the designation of all channels will be set to AV_CHAN_UNKNOWN.

This is only a convenience helper function, a custom channel layout can also be constructed without using this.

Arguments

  • channel_layout: the layout structure to be initialized
  • nb_channels: the number of channels

Returns

0 on success AVERROR(EINVAL) if the number of channels <= 0 AVERROR(ENOMEM) if the channel map could not be allocated

source
VideoIO.libffmpeg.av_channel_layout_defaultMethod
av_channel_layout_default(ch_layout, nb_channels::Integer)

Get the default channel layout for a given number of channels.

Arguments

  • ch_layout: the layout structure to be initialized
  • nb_channels: number of channels
source
VideoIO.libffmpeg.av_channel_layout_describeMethod
av_channel_layout_describe(channel_layout, buf, buf_size::Csize_t)

Get a human-readable string describing the channel layout properties. The string will be in the same format that is accepted by avchannellayoutfromstring(), allowing to rebuild the same channel layout, except for opaque pointers.

Arguments

  • channel_layout: channel layout to be described
  • buf: pre-allocated buffer where to put the generated string
  • buf_size: size in bytes of the buffer.

Returns

amount of bytes needed to hold the output string, or a negative AVERROR on failure. If the returned value is bigger than buf_size, then the string was truncated.

source
VideoIO.libffmpeg.av_channel_layout_from_maskMethod
av_channel_layout_from_mask(channel_layout, mask::UInt64)

Initialize a native channel layout from a bitmask indicating which channels are present.

Arguments

  • channel_layout: the layout structure to be initialized
  • mask: bitmask describing the channel layout

Returns

0 on success AVERROR(EINVAL) for invalid mask values

source
VideoIO.libffmpeg.av_channel_layout_from_stringMethod
av_channel_layout_from_string(channel_layout, str)

Initialize a channel layout from a given string description. The input string can be represented by: - the formal channel layout name (returned by av_channel_layout_describe()) - single or multiple channel names (returned by av_channel_name(), eg. "FL", or concatenated with "+", each optionally containing a custom name after a "@", eg. "FL@Left+FR@Right+LFE") - a decimal or hexadecimal value of a native channel layout (eg. "4" or "0x4") - the number of channels with default layout (eg. "4c") - the number of unordered channels (eg. "4C" or "4 channels") - the ambisonic order followed by optional non-diegetic channels (eg. "ambisonic 2+stereo") On error, the channel layout will remain uninitialized, but not necessarily untouched.

Arguments

  • channel_layout: uninitialized channel layout for the result
  • str: string describing the channel layout

Returns

0 on success parsing the channel layout AVERROR(EINVAL) if an invalid channel layout string was provided AVERROR(ENOMEM) if there was not enough memory

source
VideoIO.libffmpeg.av_channel_layout_index_from_channelMethod
av_channel_layout_index_from_channel(channel_layout, channel::AVChannel)

Get the index of a given channel in a channel layout. In case multiple channels are found, only the first match will be returned.

Arguments

  • channel_layout: input channel layout
  • channel: the channel whose index to obtain

Returns

index of channel in channel_layout on success or a negative number if channel is not present in channel_layout.

source
VideoIO.libffmpeg.av_channel_layout_index_from_stringMethod
av_channel_layout_index_from_string(channel_layout, name)

Get the index in a channel layout of a channel described by the given string. In case multiple channels are found, only the first match will be returned.

This function accepts channel names in the same format as avchannelfrom_string().

Arguments

  • channel_layout: input channel layout
  • name: string describing the channel whose index to obtain

Returns

a channel index described by the given string, or a negative AVERROR value.

source
VideoIO.libffmpeg.av_channel_layout_retypeMethod
av_channel_layout_retype(channel_layout, order::AVChannelOrder, flags::Integer)

Change the AVChannelOrder of a channel layout.

Change of AVChannelOrder can be either lossless or lossy. In case of a lossless conversion all the channel designations and the associated channel names (if any) are kept. On a lossy conversion the channel names and channel designations might be lost depending on the capabilities of the desired AVChannelOrder. Note that some conversions are simply not possible in which case this function returns AVERROR(ENOSYS).

The following conversions are supported:

Any -> Custom : Always possible, always lossless. Any -> Unspecified: Always possible, lossless if channel designations are all unknown and channel names are not used, lossy otherwise. Custom -> Ambisonic : Possible if it contains ambisonic channels with optional non-diegetic channels in the end. Lossy if the channels have custom names, lossless otherwise. Custom -> Native : Possible if it contains native channels in native order. Lossy if the channels have custom names, lossless otherwise.

On error this function keeps the original channel layout untouched.

Arguments

  • channel_layout: channel layout which will be changed
  • order: the desired channel layout order
  • flags: a combination of AV_CHANNEL_LAYOUT_RETYPE_FLAG_* constants

Returns

0 if the conversion was successful and lossless or if the channel layout was already in the desired order >0 if the conversion was successful but lossy AVERROR(ENOSYS) if the conversion was not possible (or would be lossy and AV_CHANNEL_LAYOUT_RETYPE_FLAG_LOSSLESS was specified) AVERROR(EINVAL), AVERROR(ENOMEM) on error

source
VideoIO.libffmpeg.av_channel_layout_standardMethod
av_channel_layout_standard(opaque)

Iterate over all standard channel layouts.

Arguments

  • opaque: a pointer where libavutil will store the iteration state. Must point to NULL to start the iteration.

Returns

the standard channel layout or NULL when the iteration is finished

source
VideoIO.libffmpeg.av_channel_layout_subsetMethod
av_channel_layout_subset(channel_layout, mask::UInt64)

Find out what channels from a given set are present in a channel layout, without regard for their positions.

Arguments

  • channel_layout: input channel layout
  • mask: a combination of AV_CH_* representing a set of channels

Returns

a bitfield representing all the channels from mask that are present in channel_layout

source
VideoIO.libffmpeg.av_channel_layout_uninitMethod
av_channel_layout_uninit(channel_layout)

Free any allocated data in the channel layout and reset the channel count to 0.

Arguments

  • channel_layout: the layout structure to be uninitialized
source
VideoIO.libffmpeg.av_channel_nameMethod
av_channel_name(buf, buf_size::Csize_t, channel::AVChannel)

Get a human readable string in an abbreviated form describing a given channel. This is the inverse function of avchannelfrom_string().

Arguments

  • buf: pre-allocated buffer where to put the generated string
  • buf_size: size in bytes of the buffer.
  • channel: the AVChannel whose name to get

Returns

amount of bytes needed to hold the output string, or a negative AVERROR on failure. If the returned value is bigger than buf_size, then the string was truncated.

source
VideoIO.libffmpeg.av_chroma_location_enum_to_posMethod
av_chroma_location_enum_to_pos(xpos, ypos, pos::AVChromaLocation)

Converts AVChromaLocation to swscale x/y chroma position.

The positions represent the chroma (0,0) position in a coordinates system with luma (0,0) representing the origin and luma(1,1) representing 256,256

Arguments

  • xpos: horizontal chroma sample position
  • ypos: vertical chroma sample position
source
VideoIO.libffmpeg.av_chroma_location_pos_to_enumMethod
av_chroma_location_pos_to_enum(xpos::Integer, ypos::Integer)

Converts swscale x/y chroma position to AVChromaLocation.

The positions represent the chroma (0,0) position in a coordinates system with luma (0,0) representing the origin and luma(1,1) representing 256,256

Arguments

  • xpos: horizontal chroma sample position
  • ypos: vertical chroma sample position
source
VideoIO.libffmpeg.av_clip64_cMethod
av_clip64_c(a::Int64, amin::Int64, amax::Int64)

Clip a signed 64bit integer value into the amin-amax range.

Arguments

  • a: value to clip
  • amin: minimum value of the clip range
  • amax: maximum value of the clip range

Returns

clipped value

source
VideoIO.libffmpeg.av_clip_cMethod
av_clip_c(a::Integer, amin::Integer, amax::Integer)

Clip a signed integer value into the amin-amax range.

Arguments

  • a: value to clip
  • amin: minimum value of the clip range
  • amax: maximum value of the clip range

Returns

clipped value

source
VideoIO.libffmpeg.av_clip_intp2_cMethod
av_clip_intp2_c(a::Integer, p::Integer)

Clip a signed integer into the -(2^p),(2^p-1) range.

Arguments

  • a: value to clip
  • p: bit position to clip at

Returns

clipped value

source
VideoIO.libffmpeg.av_clip_uintp2_cMethod
av_clip_uintp2_c(a::Integer, p::Integer)

Clip a signed integer to an unsigned power of two range.

Arguments

  • a: value to clip
  • p: bit position to clip at

Returns

clipped value

source
VideoIO.libffmpeg.av_clipd_cMethod
av_clipd_c(a::Cdouble, amin::Cdouble, amax::Cdouble)

Clip a double value into the amin-amax range. If a is nan or -inf amin will be returned. If a is +inf amax will be returned.

Arguments

  • a: value to clip
  • amin: minimum value of the clip range
  • amax: maximum value of the clip range

Returns

clipped value

source
VideoIO.libffmpeg.av_clipf_cMethod
av_clipf_c(a::Cfloat, amin::Cfloat, amax::Cfloat)

Clip a float value into the amin-amax range. If a is nan or -inf amin will be returned. If a is +inf amax will be returned.

Arguments

  • a: value to clip
  • amin: minimum value of the clip range
  • amax: maximum value of the clip range

Returns

clipped value

source
VideoIO.libffmpeg.av_cmp_qMethod
av_cmp_q(a::AVRational, b::AVRational)

Compare two rationals.

Arguments

  • a: First rational
  • b: Second rational

Returns

One of the following values: - 0 if a == b - 1 if a > b - -1 if a < b - INT_MIN if one of the values is of the form 0 / 0

source
VideoIO.libffmpeg.av_codec_get_tag2Method
av_codec_get_tag2(tags, id::AVCodecID, tag)

Get the codec tag for the given codec id.

Arguments

  • tags: list of supported codec_id - codec_tag pairs, as stored in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
  • id: codec id that should be searched for in the list
  • tag: A pointer to the found tag

Returns

0 if id was not found in tags, > 0 if it was found

source
VideoIO.libffmpeg.av_codec_iterateMethod
av_codec_iterate(opaque)

Iterate over all registered codecs.

Arguments

  • opaque: a pointer where libavcodec will store the iteration state. Must point to NULL to start the iteration.

Returns

the next registered codec or NULL when the iteration is finished

source
VideoIO.libffmpeg.av_compare_modMethod
av_compare_mod(a::UInt64, b::UInt64, mod::UInt64)

Compare the remainders of two integer operands divided by a common divisor.

In other words, compare the least significant log2(mod) bits of integers a and b.

{.c}
 av_compare_mod(0x11, 0x02, 0x10) < 0 // since 0x11 % 0x10  (0x1) < 0x02 % 0x10  (0x2)
 av_compare_mod(0x11, 0x02, 0x20) > 0 // since 0x11 % 0x20 (0x11) > 0x02 % 0x20 (0x02)

Arguments

  • a: Operand
  • b: Operand
  • mod: Divisor; must be a power of 2

Returns

  • a negative value if a % mod < b % mod - a positive value if a % mod > b % mod - zero if a % mod == b % mod
source
VideoIO.libffmpeg.av_compare_tsMethod
av_compare_ts(ts_a::Int64, tb_a::AVRational, ts_b::Int64, tb_b::AVRational)

Compare two timestamps each in its own time base.

Warning

The result of the function is undefined if one of the timestamps is outside the int64_t range when represented in the other's timebase.

Returns

One of the following values: - -1 if ts_a is before ts_b - 1 if ts_a is after ts_b - 0 if they represent the same position

source
VideoIO.libffmpeg.av_container_fifo_allocMethod
av_container_fifo_alloc(opaque, container_alloc, container_reset, container_free, fifo_transfer, flags::Integer)

Allocate a new AVContainerFifo for the container type defined by provided callbacks.

Arguments

  • opaque: user data that will be passed to the callbacks provided to this function
  • container_alloc: allocate a new container instance and return a pointer to it, or NULL on failure
  • container_reset: reset the provided container instance to a clean state
  • container_free: free the provided container instance
  • fifo_transfer: Transfer the contents of container src to dst.
  • flags: currently unused

Returns

newly allocated AVContainerFifo, or NULL on failure

source
VideoIO.libffmpeg.av_container_fifo_peekMethod
av_container_fifo_peek(cf, pobj, offset::Csize_t)

Access objects stored in the FIFO without retrieving them. The fifo_transfer() callback will NOT be invoked and the FIFO state will not be modified.

\retval0 success, a pointer was written into pobj

\retvalAVERROR(EINVAL) invalid offset value

Arguments

  • pobj: Pointer to the object stored in the FIFO will be written here on success. The object remains owned by the FIFO and the caller may only access it as long as the FIFO is not modified.
  • offset: Position of the object to retrieve - 0 is the next item that would be read, 1 the one after, etc. Must be smaller than av_container_fifo_can_read().
source
VideoIO.libffmpeg.av_cpb_properties_allocMethod
av_cpb_properties_alloc(size)

Allocate a CPB properties structure and initialize its fields to default values.

Arguments

  • size: if non-NULL, the size of the allocated struct will be written here. This is useful for embedding it in side data.

Returns

the newly allocated struct or NULL on failure

source
VideoIO.libffmpeg.av_cpu_max_alignMethod
av_cpu_max_align()

Get the maximum data alignment that may be required by FFmpeg.

Note that this is affected by the build configuration and the CPU flags mask, so e.g. if the CPU supports AVX, but libavutil has been built with –disable-avx or the AV_CPU_FLAG_AVX flag has been disabled through av_set_cpu_flags_mask(), then this function will behave as if AVX is not present.

source
VideoIO.libffmpeg.av_crcMethod
av_crc(ctx, crc::Integer, buffer, length::Csize_t)

Calculate the CRC of a block.

Arguments

  • ctx: initialized AVCRC array (see av_crc_init())
  • crc: CRC of previous blocks if any or initial value for CRC
  • buffer: buffer whose CRC to calculate
  • length: length of the buffer

Returns

CRC updated with the data from the given block

See also

av_crc_init() "le" parameter

source
VideoIO.libffmpeg.av_crc_get_tableMethod
av_crc_get_table(crc_id::AVCRCId)

Get an initialized standard CRC table.

Arguments

  • crc_id: ID of a standard CRC

Returns

a pointer to the CRC table or NULL on failure

source
VideoIO.libffmpeg.av_crc_initMethod
av_crc_init(ctx, le::Integer, bits::Integer, poly::Integer, ctx_size::Integer)

Initialize a CRC table.

Arguments

  • ctx: must be an array of size sizeof(AVCRC)257 or sizeof(AVCRC)1024
  • le: If 1, the lowest bit represents the coefficient for the highest exponent of the corresponding polynomial (both for poly and actual CRC). If 0, you must swap the CRC parameter and the result of av_crc if you need the standard representation (can be simplified in most cases to e.g. bswap16): av_bswap32(crc << (32-bits))
  • bits: number of bits for the CRC
  • poly: generator polynomial without the x**bits coefficient, in the representation as specified by le
  • ctx_size: size of ctx in bytes

Returns

<0 on failure

source
VideoIO.libffmpeg.av_csp_approximate_trc_gammaMethod
av_csp_approximate_trc_gamma(trc::AVColorTransferCharacteristic)

Determine a suitable 'gamma' value to match the supplied AVColorTransferCharacteristic.

See Apple Technical Note TN2257 (https://developer.apple.com/library/mac/technotes/tn2257/_index.html)

This function returns the gamma exponent for the OETF. For example, sRGB is approximated by gamma 2.2, not by gamma 0.45455.

Returns

Will return an approximation to the simple gamma function matching the supplied Transfer Characteristic, Will return 0.0 for any we cannot reasonably match against.

source
VideoIO.libffmpeg.av_csp_itu_eotfMethod
av_csp_itu_eotf(trc::AVColorTransferCharacteristic)

Returns the ITU EOTF corresponding to a given TRC. This converts from the signal level [0,1] to the raw output display luminance in nits (cd/m^2). This is done per channel in RGB space, except for AVCOL_TRC_SMPTE428, which assumes CIE XYZ in- and output.

Note

In general, the resulting function is defined (wherever possible) for out-of-range values, even though these values do not have a physical meaning on the given display. Users should clamp inputs (or outputs) if this behavior is not desired.

This is also the case for functions like PQ, which are defined over an absolute signal range independent of the target display capabilities.

Returns

A pointer to the function implementing the given TRC, or NULL if no such function is defined.

source
VideoIO.libffmpeg.av_csp_luma_coeffs_from_avcspMethod
av_csp_luma_coeffs_from_avcsp(csp::AVColorSpace)

Retrieves the Luma coefficients necessary to construct a conversion matrix from an enum constant describing the colorspace.

Arguments

  • csp: An enum constant indicating YUV or similar colorspace.

Returns

The Luma coefficients associated with that colorspace, or NULL if the constant is unknown to libavutil.

source
VideoIO.libffmpeg.av_csp_primaries_desc_from_idMethod
av_csp_primaries_desc_from_id(prm::AVColorPrimaries)

Retrieves a complete gamut description from an enum constant describing the color primaries.

Arguments

  • prm: An enum constant indicating primaries

Returns

A description of the colorspace gamut associated with that enum constant, or NULL if the constant is unknown to libavutil.

source
VideoIO.libffmpeg.av_csp_trc_func_from_idMethod
av_csp_trc_func_from_id(trc::AVColorTransferCharacteristic)

Determine the function needed to apply the given AVColorTransferCharacteristic to linear input.

The function returned should expect a nominal domain and range of [0.0-1.0] values outside of this range maybe valid depending on the chosen characteristic function.

Returns

Will return pointer to the function matching the supplied Transfer Characteristic. If unspecified will return NULL:

source
VideoIO.libffmpeg.av_d2qMethod
av_d2q(d::Cdouble, max::Integer)

Convert a double precision floating point number to a rational.

In case of infinity, the returned value is expressed as {1, 0} or {-1, 0} depending on the sign.

In general rational numbers with |num| <= 1<<26 && |den| <= 1<<26 can be recovered exactly from their double representation. (no exceptions were found within 1B random ones)

Arguments

  • d: double to convert
  • max: Maximum allowed numerator and denominator

Returns

d in AVRational form

See also

av_q2d()

source
VideoIO.libffmpeg.av_demuxer_iterateMethod
av_demuxer_iterate(opaque)

Iterate over all registered demuxers.

Arguments

  • opaque: a pointer where libavformat will store the iteration state. Must point to NULL to start the iteration.

Returns

the next registered demuxer or NULL when the iteration is finished

source
VideoIO.libffmpeg.av_des_cryptMethod
av_des_crypt(d, dst, src, count::Integer, iv, decrypt::Integer)

Encrypts / decrypts using the DES algorithm.

Arguments

  • d: pointer to the AVDES structure
  • dst: destination array, can be equal to src, must be 8-byte aligned
  • src: source array, can be equal to dst, must be 8-byte aligned, may be NULL
  • count: number of 8 byte blocks
  • iv: initialization vector for CBC mode, if NULL then ECB will be used, must be 8-byte aligned
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_des_initMethod
av_des_init(d, key, key_bits::Integer, decrypt::Integer)

Initializes an AVDES context.

Arguments

  • d: pointer to a AVDES structure to initialize
  • key: pointer to the key to use
  • key_bits: must be 64 or 192
  • decrypt: 0 for encryption/CBC-MAC, 1 for decryption

Returns

zero on success, negative value otherwise

source
VideoIO.libffmpeg.av_des_macMethod
av_des_mac(d, dst, src, count::Integer)

Calculates CBC-MAC using the DES algorithm.

Arguments

  • d: pointer to the AVDES structure
  • dst: destination array, can be equal to src, must be 8-byte aligned
  • src: source array, can be equal to dst, must be 8-byte aligned, may be NULL
  • count: number of 8 byte blocks
source
VideoIO.libffmpeg.av_detection_bbox_allocMethod
av_detection_bbox_alloc(nb_bboxes::Integer, out_size)

Allocates memory for AVDetectionBBoxHeader, plus an array of {

 nb_bboxes}
 AVDetectionBBox, and initializes the variables.
 Can be freed with a normal av_free() call.

 @param nb_bboxes number of AVDetectionBBox structures to allocate
 @param out_size if non-NULL, the size in bytes of the resulting data array is
 written here.
 
source
VideoIO.libffmpeg.av_dict_copyMethod
av_dict_copy(dst, src, flags::Integer)

Copy entries from one AVDictionary struct into another.

Note

Metadata is read using the ::AV_DICT_IGNORE_SUFFIX flag

Arguments

  • dst: Pointer to a pointer to a AVDictionary struct to copy into. If *dst is NULL, this function will allocate a struct for you and put it in *dst
  • src: Pointer to the source AVDictionary struct to copy items from.
  • flags: Flags to use when setting entries in *dst

Returns

0 on success, negative AVERROR code on failure. If dst was allocated by this function, callers should free the associated memory.

source
VideoIO.libffmpeg.av_dict_getMethod
av_dict_get(m, key, prev, flags::Integer)

Get a dictionary entry with matching key.

The returned entry key or value must not be changed, or it will cause undefined behavior.

Arguments

  • prev: Set to the previous matching element to find the next. If set to NULL the first matching element is returned.
  • key: Matching key
  • flags: A collection of AV_DICT_* flags controlling how the entry is retrieved

Returns

Found entry or NULL in case no matching entry was found in the dictionary

source
VideoIO.libffmpeg.av_dict_get_stringMethod
av_dict_get_string(m, buffer, key_val_sep::Cchar, pairs_sep::Cchar)

Get dictionary entries as a string.

Create a string containing dictionary's entries. Such string may be passed back to av_dict_parse_string().

Note

String is escaped with backslashes ('\').

Warning

Separators cannot be neither '\' nor '\0'. They also cannot be the same.

Arguments

  • m:[in] The dictionary
  • buffer:[out] Pointer to buffer that will be allocated with string containing entries. Buffer must be freed by the caller when is no longer needed.
  • key_val_sep:[in] Character used to separate key from value
  • pairs_sep:[in] Character used to separate two pairs from each other

Returns

= 0 on success, negative on error

source
VideoIO.libffmpeg.av_dict_iterateMethod
av_dict_iterate(m, prev)

Iterate over a dictionary

Iterates through all entries in the dictionary.

Warning

The returned AVDictionaryEntry key/value must not be changed.

Warning

As av_dict_set() invalidates all previous entries returned by this function, it must not be called while iterating over the dict.

Typical usage:

 const AVDictionaryEntry *e = NULL;
 while ((e = av_dict_iterate(m, e))) {
     // ...
 }

\retvalAVDictionaryEntry* The next element in the dictionary

\retvalNULL No more elements in the dictionary

Arguments

  • m: The dictionary to iterate over
  • prev: Pointer to the previous AVDictionaryEntry, NULL initially
source
VideoIO.libffmpeg.av_dict_parse_stringMethod
av_dict_parse_string(pm, str, key_val_sep, pairs_sep, flags::Integer)

Parse the key/value pairs list and add the parsed entries to a dictionary.

In case of failure, all the successfully set entries are stored in *pm. You may need to manually free the created dictionary.

Arguments

  • key_val_sep: A 0-terminated list of characters used to separate key from value
  • pairs_sep: A 0-terminated list of characters used to separate two pairs from each other
  • flags: Flags to use when adding to the dictionary. ::AV_DICT_DONT_STRDUP_KEY and ::AV_DICT_DONT_STRDUP_VAL are ignored since the key/value tokens will always be duplicated.

Returns

0 on success, negative AVERROR code on failure

source
VideoIO.libffmpeg.av_dict_setMethod
av_dict_set(pm, key, value, flags::Integer)

Set the given entry in *pm, overwriting an existing entry.

Note: If AV_DICT_DONT_STRDUP_KEY or AV_DICT_DONT_STRDUP_VAL is set, these arguments will be freed on error.

Warning

Adding a new entry to a dictionary invalidates all existing entries previously returned with av_dict_get() or av_dict_iterate().

Arguments

  • pm: Pointer to a pointer to a dictionary struct. If *pm is NULL a dictionary struct is allocated and put in *pm.
  • key: Entry key to add to *pm (will either be av_strduped or added as a new key depending on flags)
  • value: Entry value to add to *pm (will be av_strduped or added as a new key depending on flags). Passing a NULL value will cause an existing entry to be deleted.

Returns

= 0 on success otherwise an error code <0

source
VideoIO.libffmpeg.av_dirac_parse_sequence_headerMethod
av_dirac_parse_sequence_header(dsh, buf, buf_size::Csize_t, log_ctx)

Parse a Dirac sequence header.

Arguments

  • dsh: this function will allocate and fill an AVDiracSeqHeader struct and write it into this pointer. The caller must free it with av_free().
  • buf: the data buffer
  • buf_size: the size of the data buffer in bytes
  • log_ctx: if non-NULL, this function will log errors here

Returns

0 on success, a negative AVERROR code on failure

source
VideoIO.libffmpeg.av_dirnameMethod
av_dirname(path)

Thread safe dirname.

Note

the function may modify the contents of the path, so copies should be passed.

Arguments

  • path: the string to parse, on DOS both \ and / are considered separators.

Returns

A pointer to a string that's the parent directory of path. If path is a NULL pointer or points to an empty string, a pointer to a string "." is returned.

source
VideoIO.libffmpeg.av_display_matrix_flipMethod
av_display_matrix_flip(matrix, hflip::Integer, vflip::Integer)

Flip the input matrix horizontally and/or vertically.

Arguments

  • matrix:[in,out] a transformation matrix
  • hflip: whether the matrix should be flipped horizontally
  • vflip: whether the matrix should be flipped vertically
source
VideoIO.libffmpeg.av_display_rotation_getMethod
av_display_rotation_get(matrix)

Extract the rotation component of the transformation matrix.

Note

floating point numbers are inherently inexact, so callers are recommended to round the return value to nearest integer before use.

Arguments

  • matrix: the transformation matrix

Returns

the angle (in degrees) by which the transformation rotates the frame counterclockwise. The angle will be in range [-180.0, 180.0], or NaN if the matrix is singular.

source
VideoIO.libffmpeg.av_display_rotation_setMethod
av_display_rotation_set(matrix, angle::Cdouble)

Initialize a transformation matrix describing a pure clockwise rotation by the specified angle (in degrees).

Arguments

  • matrix:[out] a transformation matrix (will be fully overwritten by this function)
  • angle: rotation angle in degrees.
source
VideoIO.libffmpeg.av_disposition_to_stringMethod
av_disposition_to_string(disposition::Integer)

Arguments

  • disposition: a combination of AV_DISPOSITION_* values

Returns

The string description corresponding to the lowest set bit in disposition. NULL when the lowest set bit does not correspond to a known disposition or when disposition is 0.

source
VideoIO.libffmpeg.av_div_qMethod
av_div_q(b::AVRational, c::AVRational)

Divide one rational by another.

Arguments

  • b: First rational
  • c: Second rational

Returns

b/c

source
VideoIO.libffmpeg.av_dovi_find_levelMethod
av_dovi_find_level(data, level::UInt8)

Find an extension block with a given level, or NULL. In the case of multiple extension blocks, only the first is returned.

source
VideoIO.libffmpeg.av_dovi_metadata_allocMethod
av_dovi_metadata_alloc(size)

Allocate an AVDOVIMetadata structure and initialize its fields to default values.

Arguments

  • size: If this parameter is non-NULL, the size in bytes of the allocated struct will be written here on success

Returns

the newly allocated struct or NULL on failure

source
VideoIO.libffmpeg.av_downmix_info_update_side_dataMethod
av_downmix_info_update_side_data(frame)

Get a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing.

If the side data is absent, it is created and added to the frame.

Arguments

  • frame: the frame for which the side data is to be obtained or created

Returns

the AVDownmixInfo structure to be edited by the caller, or NULL if the structure cannot be allocated.

source
VideoIO.libffmpeg.av_dump_formatMethod
av_dump_format(ic, index::Integer, url, is_output::Integer)

Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.

Arguments

  • ic: the context to analyze
  • index: index of the stream to dump information about
  • url: the URL to print, such as source or destination file
  • is_output: Select whether the specified context is an input(0) or output(1)
source
VideoIO.libffmpeg.av_dv_codec_profile2Method
av_dv_codec_profile2(width::Integer, height::Integer, pix_fmt::AVPixelFormat, frame_rate::AVRational)

Get a DV profile for the provided stream parameters. The frame rate is used as a best-effort parameter.

source
VideoIO.libffmpeg.av_dv_frame_profileMethod
av_dv_frame_profile(sys, frame, buf_size::Integer)

Get a DV profile for the provided compressed frame.

Arguments

  • sys: the profile used for the previous frame, may be NULL
  • frame: the compressed data buffer
  • buf_size: size of the buffer in bytes

Returns

the DV profile for the supplied data or NULL on failure

source
VideoIO.libffmpeg.av_dynamic_hdr_plus_from_t35Method
av_dynamic_hdr_plus_from_t35(s, data, size::Csize_t)

Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus). The T.35 buffer must begin with the application mode, skipping the country code, terminal provider codes, and application identifier.

Arguments

  • s: A pointer containing the decoded AVDynamicHDRPlus structure.
  • data: The byte array containing the raw ITU-T T.35 data.
  • size: Size of the data array in bytes.

Returns

= 0 on success. Otherwise, returns the appropriate AVERROR.

source
VideoIO.libffmpeg.av_dynamic_hdr_plus_to_t35Method
av_dynamic_hdr_plus_to_t35(s, data, size)

Serialize dynamic HDR10+ metadata to a user data registered ITU-T T.35 buffer, excluding the first 48 bytes of the header, and beginning with the application mode.

Arguments

  • s: A pointer containing the decoded AVDynamicHDRPlus structure.
  • data:[in,out] A pointer to pointer to a byte buffer to be filled with the serialized metadata. If *data is NULL, a buffer be will be allocated and a pointer to it stored in its place. The caller assumes ownership of the buffer. May be NULL, in which case the function will only store the required buffer size in *size.
  • size:[in,out] A pointer to a size to be set to the returned buffer's size. If *data is not NULL, *size must contain the size of the input buffer. May be NULL only if *data is NULL.

Returns

= 0 on success. Otherwise, returns the appropriate AVERROR.

source
VideoIO.libffmpeg.av_dynarray2_addMethod
av_dynarray2_add(tab_ptr, nb_ptr, elem_size::Csize_t, elem_data)

Add an element of size elem_size to a dynamic array.

The array is reallocated when its number of elements reaches powers of 2. Therefore, the amortized cost of adding an element is constant.

In case of success, the pointer to the array is updated in order to point to the new grown array, and the number pointed to by nb_ptr is incremented. In case of failure, the array is freed, *tab\_ptr is set to NULL and *nb\_ptr is set to 0.

Arguments

  • tab_ptr:[in,out] Pointer to the array to grow
  • nb_ptr:[in,out] Pointer to the number of elements in the array
  • elem_size:[in] Size in bytes of an element in the array
  • elem_data:[in] Pointer to the data of the element to add. If NULL, the space of the newly added element is allocated but left uninitialized.

Returns

Pointer to the data of the element to copy in the newly allocated space

See also

av_dynarray_add(), av_dynarray_add_nofree()

source
VideoIO.libffmpeg.av_dynarray_addMethod
av_dynarray_add(tab_ptr, nb_ptr, elem)

Add the pointer to an element to a dynamic array.

The array to grow is supposed to be an array of pointers to structures, and the element to add must be a pointer to an already allocated structure.

The array is reallocated when its size reaches powers of 2. Therefore, the amortized cost of adding an element is constant.

In case of success, the pointer to the array is updated in order to point to the new grown array, and the number pointed to by nb_ptr is incremented. In case of failure, the array is freed, *tab\_ptr is set to NULL and *nb\_ptr is set to 0.

Arguments

  • tab_ptr:[in,out] Pointer to the array to grow
  • nb_ptr:[in,out] Pointer to the number of elements in the array
  • elem:[in] Element to add

See also

av_dynarray_add_nofree(), av_dynarray2_add()

source
VideoIO.libffmpeg.av_encryption_info_allocMethod
av_encryption_info_alloc(subsample_count::Integer, key_id_size::Integer, iv_size::Integer)

Allocates an AVEncryptionInfo structure and sub-pointers to hold the given number of subsamples. This will allocate pointers for the key ID, IV, and subsample entries, set the size members, and zero-initialize the rest.

Arguments

  • subsample_count: The number of subsamples.
  • key_id_size: The number of bytes in the key ID, should be 16.
  • iv_size: The number of bytes in the IV, should be 16.

Returns

The new AVEncryptionInfo structure, or NULL on error.

source
VideoIO.libffmpeg.av_escapeMethod
av_escape(dst, src, special_chars, mode::AVEscapeMode, flags::Integer)

Escape string in src, and put the escaped string in an allocated string in *dst, which must be freed with av_free().

Arguments

  • dst: pointer where an allocated string is put
  • src: string to escape, must be non-NULL
  • special_chars: string containing the special characters which need to be escaped, can be NULL
  • mode: escape mode to employ, see AV_ESCAPE_MODE_* macros. Any unknown value for mode will be considered equivalent to AV_ESCAPE_MODE_BACKSLASH, but this behaviour can change without notice.
  • flags: flags which control how to escape, see AV_ESCAPE_FLAG_ macros

Returns

the length of the allocated string, or a negative error code in case of error

See also

av_bprint_escape()

source
VideoIO.libffmpeg.av_executor_allocMethod
av_executor_alloc(callbacks, thread_count::Integer)

Alloc executor

Arguments

  • callbacks: callback structure for executor
  • thread_count: worker thread number, 0 for run on caller's thread directly

Returns

return the executor

source
VideoIO.libffmpeg.av_expr_count_funcMethod
av_expr_count_func(e, counter, size::Integer, arg::Integer)

Track the presence of user provided functions and their number of occurrences in a parsed expression.

Arguments

  • e: the AVExpr to track user provided functions in
  • counter: a zero-initialized array where the count of each function will be stored if you passed 5 functions with 2 arguments to av_expr_parse() then for arg=2 this will use up to 5 entries.
  • size: size of array
  • arg: number of arguments the counted functions have

Returns

0 on success, a negative value indicates that no expression or array was passed or size was zero

source
VideoIO.libffmpeg.av_expr_count_varsMethod
av_expr_count_vars(e, counter, size::Integer)

Track the presence of variables and their number of occurrences in a parsed expression

Arguments

  • e: the AVExpr to track variables in
  • counter: a zero-initialized array where the count of each variable will be stored
  • size: size of array

Returns

0 on success, a negative value indicates that no expression or array was passed or size was zero

source
VideoIO.libffmpeg.av_expr_evalMethod
av_expr_eval(e, const_values, opaque)

Evaluate a previously parsed expression.

Arguments

  • e: the AVExpr to evaluate
  • const_values: a zero terminated array of values for the identifiers from av_expr_parse() const_names
  • opaque: a pointer which will be passed to all functions from funcs1 and funcs2

Returns

the value of the expression

source
VideoIO.libffmpeg.av_expr_parseMethod
av_expr_parse(expr, s, const_names, func1_names, funcs1, func2_names, funcs2, log_offset::Integer, log_ctx)

Parse an expression.

Arguments

  • expr: a pointer where is put an AVExpr containing the parsed value in case of successful parsing, or NULL otherwise. The pointed to AVExpr must be freed with av_expr_free() by the user when it is not needed anymore.
  • s: expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
  • const_names: NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
  • func1_names: NULL terminated array of zero terminated strings of funcs1 identifiers
  • funcs1: NULL terminated array of function pointers for functions which take 1 argument
  • func2_names: NULL terminated array of zero terminated strings of funcs2 identifiers
  • funcs2: NULL terminated array of function pointers for functions which take 2 arguments
  • log_offset: log level offset, can be used to silence error messages
  • log_ctx: parent logging context

Returns

= 0 in case of success, a negative value corresponding to an AVERROR code otherwise

source
VideoIO.libffmpeg.av_expr_parse_and_evalMethod
av_expr_parse_and_eval(res, s, const_names, const_values, func1_names, funcs1, func2_names, funcs2, opaque, log_offset::Integer, log_ctx)

Parse and evaluate an expression. Note, this is significantly slower than av_expr_eval().

Arguments

  • res: a pointer to a double where is put the result value of the expression, or NAN in case of error
  • s: expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
  • const_names: NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
  • const_values: a zero terminated array of values for the identifiers from const_names
  • func1_names: NULL terminated array of zero terminated strings of funcs1 identifiers
  • funcs1: NULL terminated array of function pointers for functions which take 1 argument
  • func2_names: NULL terminated array of zero terminated strings of funcs2 identifiers
  • funcs2: NULL terminated array of function pointers for functions which take 2 arguments
  • opaque: a pointer which will be passed to all functions from funcs1 and funcs2
  • log_offset: log level offset, can be used to silence error messages
  • log_ctx: parent logging context

Returns

= 0 in case of success, a negative value corresponding to an AVERROR code otherwise

source
VideoIO.libffmpeg.av_fast_mallocMethod
av_fast_malloc(ptr, size, min_size::Csize_t)

Allocate a buffer, reusing the given one if large enough.

Contrary to av_fast_realloc(), the current buffer contents might not be preserved and on error the old buffer is freed, thus no special handling to avoid memleaks is necessary.

*ptr is allowed to be NULL, in which case allocation always happens if size_needed is greater than 0.

{.c}
 uint8_t *buf = ...;
 av_fast_malloc(&buf, &current_size, size_needed);
 if (!buf) {
     // Allocation failed; buf already freed
     return AVERROR(ENOMEM);
 }

Arguments

  • ptr:[in,out] Pointer to pointer to an already allocated buffer. *ptr will be overwritten with pointer to new buffer on success or NULL on failure
  • size:[in,out] Pointer to the size of buffer *ptr. *size is updated to the new allocated size, in particular 0 in case of failure.
  • min_size:[in] Desired minimal size of buffer *ptr

See also

av_realloc(), av_fast_mallocz()

source
VideoIO.libffmpeg.av_fast_malloczMethod
av_fast_mallocz(ptr, size, min_size::Csize_t)

Allocate and clear a buffer, reusing the given one if large enough.

Like av_fast_malloc(), but all newly allocated space is initially cleared. Reused buffer is not cleared.

*ptr is allowed to be NULL, in which case allocation always happens if size_needed is greater than 0.

Arguments

  • ptr:[in,out] Pointer to pointer to an already allocated buffer. *ptr will be overwritten with pointer to new buffer on success or NULL on failure
  • size:[in,out] Pointer to the size of buffer *ptr. *size is updated to the new allocated size, in particular 0 in case of failure.
  • min_size:[in] Desired minimal size of buffer *ptr

See also

av_fast_malloc()

source
VideoIO.libffmpeg.av_fast_reallocMethod
av_fast_realloc(ptr, size, min_size::Csize_t)

Reallocate the given buffer if it is not large enough, otherwise do nothing.

If the given buffer is NULL, then a new uninitialized buffer is allocated.

If the given buffer is not large enough, and reallocation fails, NULL is returned and *size is set to 0, but the original buffer is not changed or freed.

A typical use pattern follows:

{.c}
 uint8_t *buf = ...;
 uint8_t *new_buf = av_fast_realloc(buf, &current_size, size_needed);
 if (!new_buf) {
     // Allocation failed; clean up original buffer
     av_freep(&buf);
     return AVERROR(ENOMEM);
 }

Arguments

  • ptr:[in,out] Already allocated buffer, or NULL
  • size:[in,out] Pointer to the size of buffer ptr. *size is updated to the new allocated size, in particular 0 in case of failure.
  • min_size:[in] Desired minimal size of buffer ptr

Returns

ptr if the buffer is large enough, a pointer to newly reallocated buffer if the buffer was not large enough, or NULL in case of error

See also

av_realloc(), av_fast_malloc()

source
VideoIO.libffmpeg.av_fifo_alloc2Method
av_fifo_alloc2(elems::Csize_t, elem_size::Csize_t, flags::Integer)

Allocate and initialize an AVFifo with a given element size.

Arguments

  • elems: initial number of elements that can be stored in the FIFO
  • elem_size: Size in bytes of a single element. Further operations on the returned FIFO will implicitly use this element size.
  • flags: a combination of AV_FIFO_FLAG_*

Returns

newly-allocated AVFifo on success, a negative error code on failure

source
VideoIO.libffmpeg.av_fifo_can_writeMethod
av_fifo_can_write(f)

In other words, this number of elements or less is guaranteed to fit into the FIFO. More data may be written when the AV_FIFO_FLAG_AUTO_GROW flag was specified at FIFO creation, but this may involve memory allocation, which can fail.

Returns

Number of elements that can be written into the given FIFO without growing it.

source
VideoIO.libffmpeg.av_fifo_grow2Method
av_fifo_grow2(f, inc::Csize_t)

Enlarge an AVFifo.

On success, the FIFO will be large enough to hold exactly inc + av_fifo_can_read() + av_fifo_can_write() elements. In case of failure, the old FIFO is kept unchanged.

Arguments

  • f: AVFifo to resize
  • inc: number of elements to allocate for, in addition to the current allocated size

Returns

a non-negative number on success, a negative error code on failure

source
VideoIO.libffmpeg.av_fifo_peekMethod
av_fifo_peek(f, buf, nb_elems::Csize_t, offset::Csize_t)

Read data from a FIFO without modifying FIFO state.

Returns an error if an attempt is made to peek to nonexistent elements (i.e. if offset + nb_elems is larger than av_fifo_can_read(f)).

Arguments

  • f: the FIFO buffer
  • buf: Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes will be written into buf.
  • nb_elems: number of elements to read from FIFO
  • offset: number of initial elements to skip.

Returns

a non-negative number on success, a negative error code on failure

source
VideoIO.libffmpeg.av_fifo_peek_to_cbMethod
av_fifo_peek_to_cb(f, write_cb::AVFifoCB, opaque, nb_elems, offset::Csize_t)

Feed data from a FIFO into a user-provided callback.

Arguments

  • f: the FIFO buffer
  • write_cb: Callback the data will be supplied to. May be called multiple times.
  • opaque: opaque user data to be provided to write_cb
  • nb_elems: Should point to the maximum number of elements that can be read. Will be updated to contain the total number of elements actually sent to the callback.
  • offset: number of initial elements to skip; offset + *nb_elems must not be larger than av_fifo_can_read(f).

Returns

a non-negative number on success, a negative error code on failure

source
VideoIO.libffmpeg.av_fifo_readMethod
av_fifo_read(f, buf, nb_elems::Csize_t)

Read data from a FIFO.

In case nb_elems > av_fifo_can_read(f), nothing is read and an error is returned.

Arguments

  • f: the FIFO buffer
  • buf: Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes will be written into buf on success.
  • nb_elems: number of elements to read from FIFO

Returns

a non-negative number on success, a negative error code on failure

source
VideoIO.libffmpeg.av_fifo_read_to_cbMethod
av_fifo_read_to_cb(f, write_cb::AVFifoCB, opaque, nb_elems)

Feed data from a FIFO into a user-provided callback.

Arguments

  • f: the FIFO buffer
  • write_cb: Callback the data will be supplied to. May be called multiple times.
  • opaque: opaque user data to be provided to write_cb
  • nb_elems: Should point to the maximum number of elements that can be read. Will be updated to contain the total number of elements actually sent to the callback.

Returns

non-negative number on success, a negative error code on failure

source
VideoIO.libffmpeg.av_fifo_writeMethod
av_fifo_write(f, buf, nb_elems::Csize_t)

Write data into a FIFO.

In case nb_elems > av_fifo_can_write(f) and the AV_FIFO_FLAG_AUTO_GROW flag was not specified at FIFO creation, nothing is written and an error is returned.

Calling function is guaranteed to succeed if nb_elems <= av_fifo_can_write(f).

Arguments

  • f: the FIFO buffer
  • buf: Data to be written. nb_elems * av_fifo_elem_size(f) bytes will be read from buf on success.
  • nb_elems: number of elements to write into FIFO

Returns

a non-negative number on success, a negative error code on failure

source
VideoIO.libffmpeg.av_fifo_write_from_cbMethod
av_fifo_write_from_cb(f, read_cb::AVFifoCB, opaque, nb_elems)

Write data from a user-provided callback into a FIFO.

Arguments

  • f: the FIFO buffer
  • read_cb: Callback supplying the data to the FIFO. May be called multiple times.
  • opaque: opaque user data to be provided to read_cb
  • nb_elems: Should point to the maximum number of elements that can be written. Will be updated to contain the number of elements actually written.

Returns

non-negative number on success, a negative error code on failure

source
VideoIO.libffmpeg.av_file_mapMethod
av_file_map(filename, bufptr, size, log_offset::Integer, log_ctx)

Read the file with name filename, and put its content in a newly allocated buffer or map it with mmap() when available. In case of success set *bufptr to the read or mmapped buffer, and *size to the size in bytes of the buffer in *bufptr. Unlike mmap this function succeeds with zero sized files, in this case *bufptr will be set to NULL and *size will be set to 0. The returned buffer must be released with av_file_unmap().

Arguments

  • filename: path to the file
  • bufptr:[out] pointee is set to the mapped or allocated buffer
  • size:[out] pointee is set to the size in bytes of the buffer
  • log_offset: loglevel offset used for logging
  • log_ctx: context used for logging

Returns

a non negative number in case of success, a negative value corresponding to an AVERROR error code in case of failure

source
VideoIO.libffmpeg.av_filename_number_testMethod
av_filename_number_test(filename)

Check whether filename actually is a numbered sequence generator.

Arguments

  • filename: possible numbered sequence string

Returns

1 if a valid numbered sequence string, 0 otherwise

source
VideoIO.libffmpeg.av_film_grain_params_selectMethod
av_film_grain_params_select(frame)

Select the most appropriate film grain parameters set for the frame, taking into account the frame's format, resolution and video signal characteristics.

Note

, for H.274, this may select a film grain parameter set with greater chroma resolution than the frame. Users should take care to correctly adjust the chroma grain frequency to the frame.

source
VideoIO.libffmpeg.av_filter_iterateMethod
av_filter_iterate(opaque)

Iterate over all registered filters.

Arguments

  • opaque: a pointer where libavfilter will store the iteration state. Must point to NULL to start the iteration.

Returns

the next registered filter or NULL when the iteration is finished

source
VideoIO.libffmpeg.av_find_best_pix_fmt_of_2Method
av_find_best_pix_fmt_of_2(dst_pix_fmt1::AVPixelFormat, dst_pix_fmt2::AVPixelFormat, src_pix_fmt::AVPixelFormat, has_alpha::Integer, loss_ptr)

Compute what kind of losses will occur when converting from one specific pixel format to another. When converting from one pixel format to another, information loss may occur. For example, when converting from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when converting from some formats to other formats. These losses can involve loss of chroma, but also loss of resolution, loss of color depth, loss due to the color space conversion, loss of the alpha bits or loss due to color quantization. av_get_fix_fmt_loss() informs you about the various types of losses which will occur when converting from one pixel format to another.

Arguments

  • dst_pix_fmt:[in] destination pixel format
  • src_pix_fmt:[in] source pixel format
  • has_alpha:[in] Whether the source pixel format alpha channel is used.

Returns

Combination of flags informing you what kind of losses will occur (maximum loss for an invalid dst_pix_fmt).

source
VideoIO.libffmpeg.av_find_best_streamMethod
av_find_best_stream(ic, type::AVMediaType, wanted_stream_nb::Integer, related_stream::Integer, decoder_ret, flags::Integer)

Find the "best" stream in the file. The best stream is determined according to various heuristics as the most likely to be what the user expects. If the decoder parameter is non-NULL, av_find_best_stream will find the default decoder for the stream's codec; streams for which no decoder can be found are ignored.

Note

If av_find_best_stream returns successfully and decoder_ret is not NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec.

Arguments

  • ic: media file handle
  • type: stream type: video, audio, subtitles, etc.
  • wanted_stream_nb: user-requested stream number, or -1 for automatic selection
  • related_stream: try to find a stream related (eg. in the same program) to this one, or -1 if none
  • decoder_ret: if non-NULL, returns the decoder for the selected stream
  • flags: flags; none are currently defined

Returns

the non-negative stream number in case of success, AVERROR_STREAM_NOT_FOUND if no stream with the requested type could be found, AVERROR_DECODER_NOT_FOUND if streams were found but no decoder

source
VideoIO.libffmpeg.av_find_info_tagMethod
av_find_info_tag(arg, arg_size::Integer, tag1, info)

Attempt to find a specific tag in a URL.

syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done. Return 1 if found.

source
VideoIO.libffmpeg.av_find_nearest_q_idxMethod
av_find_nearest_q_idx(q::AVRational, q_list)

Find the value in a list of rationals nearest a given reference rational.

Arguments

  • q: Reference rational
  • q_list: Array of rationals terminated by {0, 0}

Returns

Index of the nearest value found in the array

source
VideoIO.libffmpeg.av_find_program_from_streamMethod
av_find_program_from_stream(ic, last, s::Integer)

Find the programs which belong to a given stream.

Arguments

  • ic: media file handle
  • last: the last found program, the search will start after this program, or from the beginning if it is NULL
  • s: stream index

Returns

the next program which belongs to s, NULL if no program is found or the last program is not among the programs of ic.

source
VideoIO.libffmpeg.av_frame_apply_croppingMethod
av_frame_apply_cropping(frame, flags::Integer)

Crop the given video AVFrame according to its crop_left/crop_top/crop_right/ crop_bottom fields. If cropping is successful, the function will adjust the data pointers and the width/height fields, and set the crop fields to 0.

In all cases, the cropping boundaries will be rounded to the inherent alignment of the pixel format. In some cases, such as for opaque hwaccel formats, the left/top cropping is ignored. The crop fields are set to 0 even if the cropping was rounded or ignored.

Arguments

  • frame: the frame which should be cropped
  • flags: Some combination of AV_FRAME_CROP_* flags, or 0.

Returns

= 0 on success, a negative AVERROR on error. If the cropping fields were invalid, AVERROR(ERANGE) is returned, and nothing is changed.

source
VideoIO.libffmpeg.av_frame_copyMethod
av_frame_copy(dst, src)

Copy the frame data from src to dst.

This function does not allocate anything, dst must be already initialized and allocated with the same parameters as src.

This function only copies the frame data (i.e. the contents of the data / extended data arrays), not any other properties.

Returns

= 0 on success, a negative AVERROR on error.

source
VideoIO.libffmpeg.av_frame_copy_propsMethod
av_frame_copy_props(dst, src)

Copy only "metadata" fields from src to dst.

Metadata for the purpose of this function are those fields that do not affect the data layout in the buffers. E.g. pts, sample rate (for audio) or sample aspect ratio (for video), but not width/height or channel layout. Side data is also copied.

source
VideoIO.libffmpeg.av_frame_freeMethod
av_frame_free(frame)

Free the frame and any dynamically allocated objects in it, e.g. extended_data. If the frame is reference counted, it will be unreferenced first.

Arguments

  • frame: frame to be freed. The pointer will be set to NULL.
source
VideoIO.libffmpeg.av_frame_get_bufferMethod
av_frame_get_buffer(frame, align::Integer)

Allocate new buffer(s) for audio or video data.

The following fields must be set on frame before calling this function: - format (pixel format for video, sample format for audio) - width and height for video - nb_samples and ch_layout for audio

This function will fill AVFrame.data and AVFrame.buf arrays and, if necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf. For planar formats, one buffer will be allocated for each plane.

Warning

: if frame already has been allocated, calling this function will leak memory. In addition, undefined behavior can occur in certain cases.

Arguments

  • frame: frame in which to store the new buffers.
  • align: Required buffer size and data pointer alignment. If equal to 0, alignment will be chosen automatically for the current CPU. It is highly recommended to pass 0 here unless you know what you are doing.

Returns

0 on success, a negative AVERROR on error.

source
VideoIO.libffmpeg.av_frame_get_plane_bufferMethod
av_frame_get_plane_buffer(frame, plane::Integer)

Get the buffer reference a given data plane is stored in.

Arguments

  • frame: the frame to get the plane's buffer from
  • plane: index of the data plane of interest in frame->extended_data.

Returns

the buffer reference that contains the plane or NULL if the input frame is not valid.

source
VideoIO.libffmpeg.av_frame_get_side_dataMethod
av_frame_get_side_data(frame, type::AVFrameSideDataType)

Returns

a pointer to the side data of a given type on success, NULL if there is no side data with such type in this frame.

source
VideoIO.libffmpeg.av_frame_is_writableMethod
av_frame_is_writable(frame)

Check if the frame data is writable.

If 1 is returned the answer is valid until av_buffer_ref() is called on any of the underlying AVBufferRefs (e.g. through av_frame_ref() or directly).

Returns

A positive value if the frame data is writable (which is true if and only if each of the underlying buffers has only one reference, namely the one stored in this frame). Return 0 otherwise.

See also

av_frame_make_writable(), av_buffer_is_writable()

source
VideoIO.libffmpeg.av_frame_move_refMethod
av_frame_move_ref(dst, src)

Move everything contained in src to dst and reset src.

Warning

: dst is not unreferenced, but directly overwritten without reading or deallocating its contents. Call av_frame_unref(dst) manually before calling this function to ensure that no memory is leaked.

source
VideoIO.libffmpeg.av_frame_new_side_dataMethod
av_frame_new_side_data(frame, type::AVFrameSideDataType, size::Csize_t)

Add a new side data to a frame.

Arguments

  • frame: a frame to which the side data should be added
  • type: type of the added side data
  • size: size of the side data

Returns

newly added side data on success, NULL on error

source
VideoIO.libffmpeg.av_frame_new_side_data_from_bufMethod
av_frame_new_side_data_from_buf(frame, type::AVFrameSideDataType, buf)

Add a new side data to a frame from an existing AVBufferRef

Arguments

  • frame: a frame to which the side data should be added
  • type: the type of the added side data
  • buf: an AVBufferRef to add as side data. The ownership of the reference is transferred to the frame.

Returns

newly added side data on success, NULL on error. On failure the frame is unchanged and the AVBufferRef remains owned by the caller.

source
VideoIO.libffmpeg.av_frame_refMethod
av_frame_ref(dst, src)

Set up a new reference to the data described by the source frame.

Copy frame properties from src to dst and create a new reference for each AVBufferRef from src.

If src is not reference counted, new buffers are allocated and the data is copied.

Warning

: dst MUST have been either unreferenced with av_frame_unref(dst), or newly allocated with av_frame_alloc() before calling this function, or undefined behavior will occur.

Returns

0 on success, a negative AVERROR on error

source
VideoIO.libffmpeg.av_frame_replaceMethod
av_frame_replace(dst, src)

Ensure the destination frame refers to the same data described by the source frame, either by creating a new reference for each AVBufferRef from src if they differ from those in dst, by allocating new buffers and copying data if src is not reference counted, or by unrefencing it if src is empty.

Frame properties on dst will be replaced by those from src.

Returns

0 on success, a negative AVERROR on error. On error, dst is unreferenced.

source
VideoIO.libffmpeg.av_frame_side_data_addMethod
av_frame_side_data_add(sd, nb_sd, type::AVFrameSideDataType, buf, flags::Integer)

Add a new side data entry to an array from an existing AVBufferRef.

Note

In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching AVFrameSideDataType will be removed before the addition is attempted.

Note

In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an entry of the same type already exists, it will be replaced instead.

Arguments

  • sd: pointer to array of side data to which to add another entry, or to NULL in order to start a new array.
  • nb_sd: pointer to an integer containing the number of entries in the array.
  • type: type of the added side data
  • buf: Pointer to AVBufferRef to add to the array. On success, the function takes ownership of the AVBufferRef and *buf is set to NULL, unless AV_FRAME_SIDE_DATA_FLAG_NEW_REF is set in which case the ownership will remain with the caller.
  • flags: Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.

Returns

newly added side data on success, NULL on error.

source
VideoIO.libffmpeg.av_frame_side_data_cloneMethod
av_frame_side_data_clone(sd, nb_sd, src, flags::Integer)

Add a new side data entry to an array based on existing side data, taking a reference towards the contained AVBufferRef.

Note

In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching AVFrameSideDataType will be removed before the addition is attempted.

Note

In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an entry of the same type already exists, it will be replaced instead.

Arguments

  • sd: pointer to array of side data to which to add another entry, or to NULL in order to start a new array.
  • nb_sd: pointer to an integer containing the number of entries in the array.
  • src: side data to be cloned, with a new reference utilized for the buffer.
  • flags: Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.

Returns

negative error code on failure, >=0 on success.

source
VideoIO.libffmpeg.av_frame_side_data_freeMethod
av_frame_side_data_free(sd, nb_sd)

Free all side data entries and their contents, then zeroes out the values which the pointers are pointing to.

Arguments

  • sd: pointer to array of side data to free. Will be set to NULL upon return.
  • nb_sd: pointer to an integer containing the number of entries in the array. Will be set to 0 upon return.
source
VideoIO.libffmpeg.av_frame_side_data_get_cMethod
av_frame_side_data_get_c(sd, nb_sd::Integer, type::AVFrameSideDataType)

Get a side data entry of a specific type from an array.

Arguments

  • sd: array of side data.
  • nb_sd: integer containing the number of entries in the array.
  • type: type of side data to be queried

Returns

a pointer to the side data of a given type on success, NULL if there is no side data with such type in this set.

source
VideoIO.libffmpeg.av_frame_side_data_newMethod
av_frame_side_data_new(sd, nb_sd, type::AVFrameSideDataType, size::Csize_t, flags::Integer)

Add new side data entry to an array.

Note

In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching AVFrameSideDataType will be removed before the addition is attempted.

Note

In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an entry of the same type already exists, it will be replaced instead.

Arguments

  • sd: pointer to array of side data to which to add another entry, or to NULL in order to start a new array.
  • nb_sd: pointer to an integer containing the number of entries in the array.
  • type: type of the added side data
  • size: size of the side data
  • flags: Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.

Returns

newly added side data on success, NULL on error.

source
VideoIO.libffmpeg.av_freeMethod
av_free(ptr)

Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family.

Note

ptr = NULL is explicitly allowed.

Note

It is recommended that you use av_freep() instead, to prevent leaving behind dangling pointers.

Arguments

  • ptr: Pointer to the memory block which should be freed.

See also

av_freep()

source
VideoIO.libffmpeg.av_freepMethod
av_freep(ptr)

Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family, and set the pointer pointing to it to NULL.

{.c}
 uint8_t *buf = av_malloc(16);
 av_free(buf);
 // buf now contains a dangling pointer to freed memory, and accidental
 // dereference of buf will result in a use-after-free, which may be a
 // security risk.

 uint8_t *buf = av_malloc(16);
 av_freep(&buf);
 // buf is now NULL, and accidental dereference will only result in a
 // NULL-pointer dereference.
Note

*ptr = NULL is safe and leads to no action.

Arguments

  • ptr: Pointer to the pointer to the memory block which should be freed

See also

av_free()

source
VideoIO.libffmpeg.av_gcdMethod
av_gcd(a::Int64, b::Int64)

Compute the greatest common divisor of two integer operands.

Arguments

  • a: Operand
  • b: Operand

Returns

GCD of a and b up to sign; if a >= 0 and b >= 0, return value is >= 0; if a == 0 and b == 0, returns 0.

source
VideoIO.libffmpeg.av_gcd_qMethod
av_gcd_q(a::AVRational, b::AVRational, max_den::Integer, def::AVRational)

Return the best rational so that a and b are multiple of it. If the resulting denominator is larger than max_den, return def.

source
VideoIO.libffmpeg.av_get_alt_sample_fmtMethod
av_get_alt_sample_fmt(sample_fmt::AVSampleFormat, planar::Integer)

Return the planar<->packed alternative form of the given sample format, or AV_SAMPLE_FMT_NONE on error. If the passed sample_fmt is already in the requested planar/packed format, the format returned is the same as the input.

source
VideoIO.libffmpeg.av_get_audio_frame_durationMethod
av_get_audio_frame_duration(avctx, frame_bytes::Integer)

Return audio frame duration.

Arguments

  • avctx: codec context
  • frame_bytes: size of the frame, or 0 if unknown

Returns

frame duration, in samples, if known. 0 if not able to determine.

source
VideoIO.libffmpeg.av_get_bits_per_pixelMethod
av_get_bits_per_pixel(pixdesc)

Return the number of bits per pixel used by the pixel format described by pixdesc. Note that this is not the same as the number of bits per sample.

The returned number of bits refers to the number of bits actually used for storing the pixel information, that is padding bits are not counted.

source
VideoIO.libffmpeg.av_get_bits_per_sampleMethod
av_get_bits_per_sample(codec_id::AVCodecID)

Return codec bits per sample.

Arguments

  • codec_id:[in] the codec

Returns

Number of bits per sample or zero if unknown for the given codec.

source
VideoIO.libffmpeg.av_get_bytes_per_sampleMethod
av_get_bytes_per_sample(sample_fmt::AVSampleFormat)

Return number of bytes per sample.

Arguments

  • sample_fmt: the sample format

Returns

number of bytes per sample or zero if unknown for the given sample format

source
VideoIO.libffmpeg.av_get_exact_bits_per_sampleMethod
av_get_exact_bits_per_sample(codec_id::AVCodecID)

Return codec bits per sample. Only return non-zero if the bits per sample is exactly correct, not an approximation.

Arguments

  • codec_id:[in] the codec

Returns

Number of bits per sample or zero if unknown for the given codec.

source
VideoIO.libffmpeg.av_get_frame_filename2Method
av_get_frame_filename2(buf, buf_size::Integer, path, number::Integer, flags::Integer)

Return in 'buf' the path with 'd' replaced by a number.

Also handles the '0nd' format where 'n' is the total number of digits and '%%'.

Arguments

  • buf: destination buffer
  • buf_size: destination buffer size
  • path: numbered sequence string
  • number: frame number
  • flags: AV_FRAME_FILENAME_FLAGS_*

Returns

0 if OK, -1 on format error

source
VideoIO.libffmpeg.av_get_known_color_nameMethod
av_get_known_color_name(color_idx::Integer, rgb)

Get the name of a color from the internal table of hard-coded named colors.

This function is meant to enumerate the color names recognized by av_parse_color().

Arguments

  • color_idx: index of the requested color, starting from 0
  • rgb: if not NULL, will point to a 3-elements array with the color value in RGB

Returns

the color name string or NULL if color_idx is not in the array

source
VideoIO.libffmpeg.av_get_output_timestampMethod
av_get_output_timestamp(s, stream::Integer, dts, wall)

Get timing information for the data currently output. The exact meaning of "currently output" depends on the format. It is mostly relevant for devices that have an internal buffer and/or work in real time.

\retval0 Success

\retvalAVERROR(ENOSYS) The format does not support it

Note

Some formats or devices may not allow to measure dts and wall atomically.

Arguments

  • s: media file handle
  • stream: stream in the media file
  • dts:[out] DTS of the last packet output for the stream, in stream time_base units
  • wall:[out] absolute time when that packet whas output, in microsecond
source
VideoIO.libffmpeg.av_get_packed_sample_fmtMethod
av_get_packed_sample_fmt(sample_fmt::AVSampleFormat)

Get the packed alternative form of the given sample format.

If the passed sample_fmt is already in packed format, the format returned is the same as the input.

Returns

the packed alternative form of the given sample format or AV_SAMPLE_FMT_NONE on error.

source
VideoIO.libffmpeg.av_get_packetMethod
av_get_packet(s, pkt, size::Integer)

Allocate and read the payload of a packet and initialize its fields with default values.

Arguments

  • s: associated IO context
  • pkt: packet
  • size: desired payload size

Returns

0 (read size) if OK, AVERROR_xxx otherwise

source
VideoIO.libffmpeg.av_get_pcm_codecMethod
av_get_pcm_codec(fmt::AVSampleFormat, be::Integer)

Return the PCM codec associated with a sample format.

Arguments

  • be: endianness, 0 for little, 1 for big, -1 (or anything else) for native

Returns

AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE

source
VideoIO.libffmpeg.av_get_picture_type_charMethod
av_get_picture_type_char(pict_type::AVPictureType)

Return a single letter to describe the given picture type pict_type.

Arguments

  • pict_type:[in] the picture type

Returns

a single character representing the picture type, '?' if pict_type is unknown

source
VideoIO.libffmpeg.av_get_pix_fmtMethod
av_get_pix_fmt(name)

Return the pixel format corresponding to name.

If there is no pixel format with name name, then looks for a pixel format with the name corresponding to the native endian format of name. For example in a little-endian system, first looks for "gray16", then for "gray16le".

Finally if no pixel format has been found, returns AV_PIX_FMT_NONE.

source
VideoIO.libffmpeg.av_get_pix_fmt_lossMethod
av_get_pix_fmt_loss(dst_pix_fmt::AVPixelFormat, src_pix_fmt::AVPixelFormat, has_alpha::Integer)

Compute what kind of losses will occur when converting from one specific pixel format to another. When converting from one pixel format to another, information loss may occur. For example, when converting from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when converting from some formats to other formats. These losses can involve loss of chroma, but also loss of resolution, loss of color depth, loss due to the color space conversion, loss of the alpha bits or loss due to color quantization. av_get_fix_fmt_loss() informs you about the various types of losses which will occur when converting from one pixel format to another.

Arguments

  • dst_pix_fmt:[in] destination pixel format
  • src_pix_fmt:[in] source pixel format
  • has_alpha:[in] Whether the source pixel format alpha channel is used.

Returns

Combination of flags informing you what kind of losses will occur (maximum loss for an invalid dst_pix_fmt).

source
VideoIO.libffmpeg.av_get_pix_fmt_stringMethod
av_get_pix_fmt_string(buf, buf_size::Integer, pix_fmt::AVPixelFormat)

Print in buf the string corresponding to the pixel format with number pix_fmt, or a header if pix_fmt is negative.

Arguments

  • buf: the buffer where to write the string
  • buf_size: the size of buf
  • pix_fmt: the number of the pixel format to print the corresponding info string, or a negative value to print the corresponding header.
source
VideoIO.libffmpeg.av_get_planar_sample_fmtMethod
av_get_planar_sample_fmt(sample_fmt::AVSampleFormat)

Get the planar alternative form of the given sample format.

If the passed sample_fmt is already in planar format, the format returned is the same as the input.

Returns

the planar alternative form of the given sample format or AV_SAMPLE_FMT_NONE on error.

source
VideoIO.libffmpeg.av_get_profile_nameMethod
av_get_profile_name(codec, profile::Integer)

Return a name for the specified profile, if available.

Arguments

  • codec: the codec that is searched for the given profile
  • profile: the profile value for which a name is requested

Returns

A name for the profile if found, NULL otherwise.

source
VideoIO.libffmpeg.av_get_random_seedMethod
av_get_random_seed()

Get a seed to use in conjunction with random functions. This function tries to provide a good seed at a best effort bases. Its possible to call this function multiple times if more bits are needed. It can be quite slow, which is why it should only be used as seed for a faster PRNG. The quality of the seed depends on the platform.

source
VideoIO.libffmpeg.av_get_sample_fmt_stringMethod
av_get_sample_fmt_string(buf, buf_size::Integer, sample_fmt::AVSampleFormat)

Generate a string corresponding to the sample format with sample_fmt, or a header if sample_fmt is negative.

Arguments

  • buf: the buffer where to write the string
  • buf_size: the size of buf
  • sample_fmt: the number of the sample format to print the corresponding info string, or a negative value to print the corresponding header.

Returns

the pointer to the filled buffer or NULL if sample_fmt is unknown or in case of other errors

source
VideoIO.libffmpeg.av_get_tokenMethod
av_get_token(buf, term)

Unescape the given string until a non escaped terminating char, and return the token corresponding to the unescaped string.

The normal \ and ' escaping is supported. Leading and trailing whitespaces are removed, unless they are escaped with '\' or are enclosed between ''.

Arguments

  • buf: the buffer to parse, buf will be updated to point to the terminating char
  • term: a 0-terminated list of terminating chars

Returns

the malloced unescaped string, which must be av_freed by the user, NULL in case of allocation failure

source
VideoIO.libffmpeg.av_gettime_relativeMethod
av_gettime_relative()

Get the current time in microseconds since some unspecified starting point. On platforms that support it, the time comes from a monotonic clock This property makes this time source ideal for measuring relative time. The returned values may not be monotonic on platforms where a monotonic clock is not available.

source
VideoIO.libffmpeg.av_grow_packetMethod
av_grow_packet(pkt, grow_by::Integer)

Increase packet size, correctly zeroing padding

Arguments

  • pkt: packet
  • grow_by: number of bytes by which to increase the size of the packet
source
VideoIO.libffmpeg.av_guess_formatMethod
av_guess_format(short_name, filename, mime_type)

Return the output format in the list of registered output formats which best matches the provided parameters, or return NULL if there is no match.

Arguments

  • short_name: if non-NULL checks if short_name matches with the names of the registered formats
  • filename: if non-NULL checks if filename terminates with the extensions of the registered formats
  • mime_type: if non-NULL checks if mime_type matches with the MIME type of the registered formats
source
VideoIO.libffmpeg.av_guess_frame_rateMethod
av_guess_frame_rate(ctx, stream, frame)

Guess the frame rate, based on both the container and codec information.

Arguments

  • ctx: the format context which the stream is part of
  • stream: the stream which the frame is part of
  • frame: the frame for which the frame rate should be determined, may be NULL

Returns

the guessed (valid) frame rate, 0/1 if no idea

source
VideoIO.libffmpeg.av_guess_sample_aspect_ratioMethod
av_guess_sample_aspect_ratio(format, stream, frame)

Guess the sample aspect ratio of a frame, based on both the stream and the frame aspect ratio.

Since the frame aspect ratio is set by the codec but the stream aspect ratio is set by the demuxer, these two may not be equal. This function tries to return the value that you should use if you would like to display the frame.

Basic logic is to use the stream aspect ratio if it is set to something sane otherwise use the frame aspect ratio. This way a container setting, which is usually easy to modify can override the coded value in the frames.

Arguments

  • format: the format context which the stream is part of
  • stream: the stream which the frame is part of
  • frame: the frame with the aspect ratio to be determined

Returns

the guessed (valid) sample_aspect_ratio, 0/1 if no idea

source
VideoIO.libffmpeg.av_hash_allocMethod
av_hash_alloc(ctx, name)

Allocate a hash context for the algorithm specified by name.

Note

The context is not initialized after a call to this function; you must call av_hash_init() to do so.

Returns

= 0 for success, a negative error code for failure

source
VideoIO.libffmpeg.av_hash_finalMethod
av_hash_final(ctx, dst)

Finalize a hash context and compute the actual hash value.

The minimum size of dst buffer is given by av_hash_get_size() or #AV_HASH_MAX_SIZE. The use of the latter macro is discouraged.

It is not safe to update or finalize a hash context again, if it has already been finalized.

Arguments

  • ctx:[in,out] Hash context
  • dst:[out] Where the final hash value will be stored

See also

av_hash_final_bin() provides an alternative API

source
VideoIO.libffmpeg.av_hash_final_b64Method
av_hash_final_b64(ctx, dst, size::Integer)

Finalize a hash context and store the Base64 representation of the actual hash value as a string.

It is not safe to update or finalize a hash context again, if it has already been finalized.

The string is always 0-terminated.

If size is smaller than AV_BASE64_SIZE(hash_size), where hash_size is the value returned by av_hash_get_size(), the string will be truncated.

Arguments

  • ctx:[in,out] Hash context
  • dst:[out] Where the final hash value will be stored
  • size:[in] Maximum number of bytes to write to dst
source
VideoIO.libffmpeg.av_hash_final_binMethod
av_hash_final_bin(ctx, dst, size::Integer)

Finalize a hash context and store the actual hash value in a buffer.

It is not safe to update or finalize a hash context again, if it has already been finalized.

If size is smaller than the hash size (given by av_hash_get_size()), the hash is truncated; if size is larger, the buffer is padded with 0.

Arguments

  • ctx:[in,out] Hash context
  • dst:[out] Where the final hash value will be stored
  • size:[in] Number of bytes to write to dst
source
VideoIO.libffmpeg.av_hash_final_hexMethod
av_hash_final_hex(ctx, dst, size::Integer)

Finalize a hash context and store the hexadecimal representation of the actual hash value as a string.

It is not safe to update or finalize a hash context again, if it has already been finalized.

The string is always 0-terminated.

If size is smaller than 2 * hash\_size + 1, where hash_size is the value returned by av_hash_get_size(), the string will be truncated.

Arguments

  • ctx:[in,out] Hash context
  • dst:[out] Where the string will be stored
  • size:[in] Maximum number of bytes to write to dst
source
VideoIO.libffmpeg.av_hash_get_sizeMethod
av_hash_get_size(ctx)

Get the size of the resulting hash value in bytes.

The maximum value this function will currently return is available as macro #AV_HASH_MAX_SIZE.

Arguments

  • ctx:[in] Hash context

Returns

Size of the hash value in bytes

source
VideoIO.libffmpeg.av_hash_namesMethod
av_hash_names(i::Integer)

Get the names of available hash algorithms.

This function can be used to enumerate the algorithms.

Arguments

  • i:[in] Index of the hash algorithm, starting from 0

Returns

Pointer to a static string or NULL if i is out of range

source
VideoIO.libffmpeg.av_hash_updateMethod
av_hash_update(ctx, src, len::Csize_t)

Update a hash context with additional data.

Arguments

  • ctx:[in,out] Hash context
  • src:[in] Data to be added to the hash context
  • len:[in] Size of the additional data
source
VideoIO.libffmpeg.av_hex_dump_logMethod
av_hex_dump_log(avcl, level::Integer, buf, size::Integer)

Send a nice hexadecimal dump of a buffer to the log.

Arguments

  • avcl: A pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct.
  • level: The importance level of the message, lower values signifying higher importance.
  • buf: buffer
  • size: buffer size

See also

av_hex_dump, av_pkt_dump2, av_pkt_dump_log2

source
VideoIO.libffmpeg.av_hmac_calcMethod
av_hmac_calc(ctx, data, len::Integer, key, keylen::Integer, out, outlen::Integer)

Hash an array of data with a key.

Arguments

  • ctx: The HMAC context
  • data: The data to hash
  • len: The length of the data, in bytes
  • key: The authentication key
  • keylen: The length of the key, in bytes
  • out: The output buffer to write the digest into
  • outlen: The length of the out buffer, in bytes

Returns

The number of bytes written to out, or a negative error code.

source
VideoIO.libffmpeg.av_hmac_finalMethod
av_hmac_final(ctx, out, outlen::Integer)

Finish hashing and output the HMAC digest.

Arguments

  • ctx: The HMAC context
  • out: The output buffer to write the digest into
  • outlen: The length of the out buffer, in bytes

Returns

The number of bytes written to out, or a negative error code.

source
VideoIO.libffmpeg.av_hmac_initMethod
av_hmac_init(ctx, key, keylen::Integer)

Initialize an AVHMAC context with an authentication key.

Arguments

  • ctx: The HMAC context
  • key: The authentication key
  • keylen: The length of the key, in bytes
source
VideoIO.libffmpeg.av_hmac_updateMethod
av_hmac_update(ctx, data, len::Integer)

Hash data with the HMAC.

Arguments

  • ctx: The HMAC context
  • data: The data to hash
  • len: The length of the data, in bytes
source
VideoIO.libffmpeg.av_hwdevice_ctx_createMethod
av_hwdevice_ctx_create(device_ctx, type::AVHWDeviceType, device, opts, flags::Integer)

Open a device of the specified type and create an AVHWDeviceContext for it.

This is a convenience function intended to cover the simple cases. Callers who need to fine-tune device creation/management should open the device manually and then wrap it in an AVHWDeviceContext using av_hwdevice_ctx_alloc()/av_hwdevice_ctx_init().

The returned context is already initialized and ready for use, the caller should not call av_hwdevice_ctx_init() on it. The user_opaque/free fields of the created AVHWDeviceContext are set by this function and should not be touched by the caller.

Arguments

  • device_ctx: On success, a reference to the newly-created device context will be written here. The reference is owned by the caller and must be released with av_buffer_unref() when no longer needed. On failure, NULL will be written to this pointer.
  • type: The type of the device to create.
  • device: A type-specific string identifying the device to open.
  • opts: A dictionary of additional (type-specific) options to use in opening the device. The dictionary remains owned by the caller.
  • flags: currently unused

Returns

0 on success, a negative AVERROR code on failure.

source
VideoIO.libffmpeg.av_hwdevice_ctx_create_derivedMethod
av_hwdevice_ctx_create_derived(dst_ctx, type::AVHWDeviceType, src_ctx, flags::Integer)

Create a new device of the specified type from an existing device.

If the source device is a device of the target type or was originally derived from such a device (possibly through one or more intermediate devices of other types), then this will return a reference to the existing device of the same type as is requested.

Otherwise, it will attempt to derive a new device from the given source device. If direct derivation to the new type is not implemented, it will attempt the same derivation from each ancestor of the source device in turn looking for an implemented derivation method.

Arguments

  • dst_ctx: On success, a reference to the newly-created AVHWDeviceContext.
  • type: The type of the new device to create.
  • src_ctx: A reference to an existing AVHWDeviceContext which will be used to create the new device.
  • flags: Currently unused; should be set to zero.

Returns

Zero on success, a negative AVERROR code on failure.

source
VideoIO.libffmpeg.av_hwdevice_ctx_create_derived_optsMethod
av_hwdevice_ctx_create_derived_opts(dst_ctx, type::AVHWDeviceType, src_ctx, options, flags::Integer)

Create a new device of the specified type from an existing device.

This function performs the same action as av_hwdevice_ctx_create_derived, however, it is able to set options for the new device to be derived.

Arguments

  • dst_ctx: On success, a reference to the newly-created AVHWDeviceContext.
  • type: The type of the new device to create.
  • src_ctx: A reference to an existing AVHWDeviceContext which will be used to create the new device.
  • options: Options for the new device to create, same format as in av_hwdevice_ctx_create.
  • flags: Currently unused; should be set to zero.

Returns

Zero on success, a negative AVERROR code on failure.

source
VideoIO.libffmpeg.av_hwdevice_ctx_initMethod
av_hwdevice_ctx_init(ref)

Finalize the device context before use. This function must be called after the context is filled with all the required information and before it is used in any way.

Arguments

Returns

0 on success, a negative AVERROR code on failure

source
VideoIO.libffmpeg.av_hwdevice_get_hwframe_constraintsMethod
av_hwdevice_get_hwframe_constraints(ref, hwconfig)

Get the constraints on HW frames given a device and the HW-specific configuration to be used with that device. If no HW-specific configuration is provided, returns the maximum possible capabilities of the device.

Arguments

  • ref: a reference to the associated AVHWDeviceContext.
  • hwconfig: a filled HW-specific configuration structure, or NULL to return the maximum possible capabilities of the device.

Returns

AVHWFramesConstraints structure describing the constraints on the device, or NULL if not available.

source
VideoIO.libffmpeg.av_hwdevice_hwconfig_allocMethod
av_hwdevice_hwconfig_alloc(device_ctx)

Allocate a HW-specific configuration structure for a given HW device. After use, the user must free all members as required by the specific hardware structure being used, then free the structure itself with av_free().

Arguments

Returns

The newly created HW-specific configuration structure on success or NULL on failure.

source
VideoIO.libffmpeg.av_hwdevice_iterate_typesMethod
av_hwdevice_iterate_types(prev::AVHWDeviceType)

Iterate over supported device types.

Arguments

  • prev: AV_HWDEVICE_TYPE_NONE initially, then the previous type returned by this function in subsequent iterations.

Returns

The next usable device type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if there are no more.

source
VideoIO.libffmpeg.av_hwframe_ctx_create_derivedMethod
av_hwframe_ctx_create_derived(derived_frame_ctx, format::AVPixelFormat, derived_device_ctx, source_frame_ctx, flags::Integer)

Create and initialise an AVHWFramesContext as a mapping of another existing AVHWFramesContext on a different device.

av_hwframe_ctx_init() should not be called after this.

Arguments

  • derived_frame_ctx: On success, a reference to the newly created AVHWFramesContext.
  • format: The AVPixelFormat for the derived context.
  • derived_device_ctx: A reference to the device to create the new AVHWFramesContext on.
  • source_frame_ctx: A reference to an existing AVHWFramesContext which will be mapped to the derived context.
  • flags: Some combination of AV_HWFRAME_MAP_* flags, defining the mapping parameters to apply to frames which are allocated in the derived device.

Returns

Zero on success, negative AVERROR code on failure.

source
VideoIO.libffmpeg.av_hwframe_ctx_initMethod
av_hwframe_ctx_init(ref)

Finalize the context before use. This function must be called after the context is filled with all the required information and before it is attached to any frames.

Arguments

Returns

0 on success, a negative AVERROR code on failure

source
VideoIO.libffmpeg.av_hwframe_mapMethod
av_hwframe_map(dst, src, flags::Integer)

Map a hardware frame.

This has a number of different possible effects, depending on the format and origin of the src and dst frames. On input, src should be a usable frame with valid buffers and dst should be blank (typically as just created by av_frame_alloc()). src should have an associated hwframe context, and dst may optionally have a format and associated hwframe context.

If src was created by mapping a frame from the hwframe context of dst, then this function undoes the mapping - dst is replaced by a reference to the frame that src was originally mapped from.

If both src and dst have an associated hwframe context, then this function attempts to map the src frame from its hardware context to that of dst and then fill dst with appropriate data to be usable there. This will only be possible if the hwframe contexts and associated devices are compatible - given compatible devices, av_hwframe_ctx_create_derived() can be used to create a hwframe context for dst in which mapping should be possible.

If src has a hwframe context but dst does not, then the src frame is mapped to normal memory and should thereafter be usable as a normal frame. If the format is set on dst, then the mapping will attempt to create dst with that format and fail if it is not possible. If format is unset (is AV_PIX_FMT_NONE) then dst will be mapped with whatever the most appropriate format to use is (probably the sw_format of the src hwframe context).

A return value of AVERROR(ENOSYS) indicates that the mapping is not possible with the given arguments and hwframe setup, while other return values indicate that it failed somehow.

On failure, the destination frame will be left blank, except for the hw_frames_ctx/format fields they may have been set by the caller - those will be preserved as they were.

Arguments

  • dst: Destination frame, to contain the mapping.
  • src: Source frame, to be mapped.
  • flags: Some combination of AV_HWFRAME_MAP_* flags.

Returns

Zero on success, negative AVERROR code on failure.

source
VideoIO.libffmpeg.av_hwframe_transfer_dataMethod
av_hwframe_transfer_data(dst, src, flags::Integer)

Copy data to or from a hw surface. At least one of dst/src must have an AVHWFramesContext attached.

If src has an AVHWFramesContext attached, then the format of dst (if set) must use one of the formats returned by av_hwframe_transfer_get_formats(src, AV_HWFRAME_TRANSFER_DIRECTION_FROM). If dst has an AVHWFramesContext attached, then the format of src must use one of the formats returned by av_hwframe_transfer_get_formats(dst, AV_HWFRAME_TRANSFER_DIRECTION_TO)

dst may be "clean" (i.e. with data/buf pointers unset), in which case the data buffers will be allocated by this function using av_frame_get_buffer(). If dst->format is set, then this format will be used, otherwise (when dst->format is AV_PIX_FMT_NONE) the first acceptable format will be chosen.

The two frames must have matching allocated dimensions (i.e. equal to AVHWFramesContext.width/height), since not all device types support transferring a sub-rectangle of the whole surface. The display dimensions (i.e. AVFrame.width/height) may be smaller than the allocated dimensions, but also have to be equal for both frames. When the display dimensions are smaller than the allocated dimensions, the content of the padding in the destination frame is unspecified.

Arguments

  • dst: the destination frame. dst is not touched on failure.
  • src: the source frame.
  • flags: currently unused, should be set to zero

Returns

0 on success, a negative AVERROR error code on failure.

source
VideoIO.libffmpeg.av_hwframe_transfer_get_formatsMethod
av_hwframe_transfer_get_formats(hwframe_ctx, dir::AVHWFrameTransferDirection, formats, flags::Integer)

Get a list of possible source or target formats usable in av_hwframe_transfer_data().

Arguments

  • hwframe_ctx: the frame context to obtain the information for
  • dir: the direction of the transfer
  • formats: the pointer to the output format list will be written here. The list is terminated with AV_PIX_FMT_NONE and must be freed by the caller when no longer needed using av_free(). If this function returns successfully, the format list will have at least one item (not counting the terminator). On failure, the contents of this pointer are unspecified.
  • flags: currently unused, should be set to zero

Returns

0 on success, a negative AVERROR code on failure.

source
VideoIO.libffmpeg.av_iamf_param_definition_allocMethod
av_iamf_param_definition_alloc(type::AVIAMFParamDefinitionType, nb_subblocks::Integer, size)

Allocates memory for AVIAMFParamDefinition, plus an array of {

 nb_subblocks}
 amount of subblocks of the given type and initializes the variables. Can be
 freed with a normal av_free() call.

 @param size if non-NULL, the size in bytes of the resulting data array is written here.
 
source
VideoIO.libffmpeg.av_iamf_param_definition_get_subblockMethod
av_iamf_param_definition_get_subblock(par, idx::Integer)

Get the subblock at the specified {

 idx}. Must be between 0 and nb_subblocks - 1.

 The @ref AVIAMFParamDefinition.type "param definition type" defines
 the struct type of the returned pointer.
 
source
VideoIO.libffmpeg.av_image_allocMethod
av_image_alloc(pointers, linesizes, w::Integer, h::Integer, pix_fmt::AVPixelFormat, align::Integer)

Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordingly. The allocated image buffer has to be freed by using av_freep(&pointers[0]).

Arguments

  • pointers: array to be filled with the pointer for each image plane
  • linesizes: the array filled with the linesize for each plane
  • w: width of the image in pixels
  • h: height of the image in pixels
  • pix_fmt: the AVPixelFormat of the image
  • align: the value to use for buffer size alignment

Returns

the size in bytes required for the image buffer, a negative error code in case of failure

source
VideoIO.libffmpeg.av_image_check_sarMethod
av_image_check_sar(w::Integer, h::Integer, sar::AVRational)

Check if the given sample aspect ratio of an image is valid.

It is considered invalid if the denominator is 0 or if applying the ratio to the image size would make the smaller dimension less than 1. If the sar numerator is 0, it is considered unknown and will return as valid.

Arguments

  • w: width of the image
  • h: height of the image
  • sar: sample aspect ratio of the image

Returns

0 if valid, a negative AVERROR code otherwise

source
VideoIO.libffmpeg.av_image_check_sizeMethod
av_image_check_size(w::Integer, h::Integer, log_offset::Integer, log_ctx)

Check if the given dimension of an image is valid, meaning that all bytes of the image can be addressed with a signed int.

Arguments

  • w: the width of the picture
  • h: the height of the picture
  • log_offset: the offset to sum to the log level for logging with log_ctx
  • log_ctx: the parent logging context, it may be NULL

Returns

= 0 if valid, a negative error code otherwise

source
VideoIO.libffmpeg.av_image_check_size2Method
av_image_check_size2(w::Integer, h::Integer, max_pixels::Int64, pix_fmt::AVPixelFormat, log_offset::Integer, log_ctx)

Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with the specified pix_fmt can be addressed with a signed int.

Arguments

  • w: the width of the picture
  • h: the height of the picture
  • max_pixels: the maximum number of pixels the user wants to accept
  • pix_fmt: the pixel format, can be AV_PIX_FMT_NONE if unknown.
  • log_offset: the offset to sum to the log level for logging with log_ctx
  • log_ctx: the parent logging context, it may be NULL

Returns

= 0 if valid, a negative error code otherwise

source
VideoIO.libffmpeg.av_image_copyMethod
av_image_copy(dst_data, dst_linesizes, src_data, src_linesizes, pix_fmt::AVPixelFormat, width::Integer, height::Integer)

Copy image in src_data to dst_data.

Arguments

  • dst_data: destination image data buffer to copy to
  • dst_linesizes: linesizes for the image in dst_data
  • src_data: source image data buffer to copy from
  • src_linesizes: linesizes for the image in src_data
  • pix_fmt: the AVPixelFormat of the image
  • width: width of the image in pixels
  • height: height of the image in pixels
source
VideoIO.libffmpeg.av_image_copy2Method
av_image_copy2(dst_data, dst_linesizes, src_data, src_linesizes, pix_fmt::AVPixelFormat, width::Integer, height::Integer)

Wrapper around av_image_copy() to workaround the limitation that the conversion from uint8_t * const * to const uint8_t * const * is not performed automatically in C.

See also

av_image_copy()

source
VideoIO.libffmpeg.av_image_copy_planeMethod
av_image_copy_plane(dst, dst_linesize::Integer, src, src_linesize::Integer, bytewidth::Integer, height::Integer)

Copy image plane from src to dst. That is, copy "height" number of lines of "bytewidth" bytes each. The first byte of each successive line is separated by *_linesize bytes.

bytewidth must be contained by both absolute values of dst_linesize and src_linesize, otherwise the function behavior is undefined.

Arguments

  • dst: destination plane to copy to
  • dst_linesize: linesize for the image plane in dst
  • src: source plane to copy from
  • src_linesize: linesize for the image plane in src
  • height: height (number of lines) of the plane
source
VideoIO.libffmpeg.av_image_copy_plane_uc_fromMethod
av_image_copy_plane_uc_from(dst, dst_linesize::Cptrdiff_t, src, src_linesize::Cptrdiff_t, bytewidth::Cptrdiff_t, height::Integer)

Copy image data located in uncacheable (e.g. GPU mapped) memory. Where available, this function will use special functionality for reading from such memory, which may result in greatly improved performance compared to plain av_image_copy_plane().

bytewidth must be contained by both absolute values of dst_linesize and src_linesize, otherwise the function behavior is undefined.

Note

The linesize parameters have the type ptrdiff_t here, while they are int for av_image_copy_plane().

Note

On x86, the linesizes currently need to be aligned to the cacheline size (i.e. 64) to get improved performance.

source
VideoIO.libffmpeg.av_image_copy_to_bufferMethod
av_image_copy_to_buffer(dst, dst_size::Integer, src_data, src_linesize, pix_fmt::AVPixelFormat, width::Integer, height::Integer, align::Integer)

Copy image data from an image into a buffer.

av_image_get_buffer_size() can be used to compute the required size for the buffer to fill.

Arguments

  • dst: a buffer into which picture data will be copied
  • dst_size: the size in bytes of dst
  • src_data: pointers containing the source image data
  • src_linesize: linesizes for the image in src_data
  • pix_fmt: the pixel format of the source image
  • width: the width of the source image in pixels
  • height: the height of the source image in pixels
  • align: the assumed linesize alignment for dst

Returns

the number of bytes written to dst, or a negative value (error code) on error

source
VideoIO.libffmpeg.av_image_copy_uc_fromMethod
av_image_copy_uc_from(dst_data, dst_linesizes, src_data, src_linesizes, pix_fmt::AVPixelFormat, width::Integer, height::Integer)

Copy image data located in uncacheable (e.g. GPU mapped) memory. Where available, this function will use special functionality for reading from such memory, which may result in greatly improved performance compared to plain av_image_copy().

The data pointers and the linesizes must be aligned to the maximum required by the CPU architecture.

Note

The linesize parameters have the type ptrdiff_t here, while they are int for av_image_copy().

Note

On x86, the linesizes currently need to be aligned to the cacheline size (i.e. 64) to get improved performance.

source
VideoIO.libffmpeg.av_image_fill_arraysMethod
av_image_fill_arrays(dst_data, dst_linesize, src, pix_fmt::AVPixelFormat, width::Integer, height::Integer, align::Integer)

Setup the data pointers and linesizes based on the specified image parameters and the provided array.

The fields of the given image are filled in by using the src address which points to the image data buffer. Depending on the specified pixel format, one or multiple image data pointers and line sizes will be set. If a planar format is specified, several pointers will be set pointing to the different picture planes and the line sizes of the different planes will be stored in the lines_sizes array. Call with src == NULL to get the required size for the src buffer.

To allocate the buffer and fill in the dst_data and dst_linesize in one call, use av_image_alloc().

Arguments

  • dst_data: data pointers to be filled in
  • dst_linesize: linesizes for the image in dst_data to be filled in
  • src: buffer which will contain or contains the actual image data, can be NULL
  • pix_fmt: the pixel format of the image
  • width: the width of the image in pixels
  • height: the height of the image in pixels
  • align: the value used in src for linesize alignment

Returns

the size in bytes required for src, a negative error code in case of failure

source
VideoIO.libffmpeg.av_image_fill_blackMethod
av_image_fill_black(dst_data, dst_linesize, pix_fmt::AVPixelFormat, range::AVColorRange, width::Integer, height::Integer)

Overwrite the image data with black. This is suitable for filling a sub-rectangle of an image, meaning the padding between the right most pixel and the left most pixel on the next line will not be overwritten. For some formats, the image size might be rounded up due to inherent alignment.

If the pixel format has alpha, the alpha is cleared to opaque.

This can return an error if the pixel format is not supported. Normally, all non-hwaccel pixel formats should be supported.

Passing NULL for dst_data is allowed. Then the function returns whether the operation would have succeeded. (It can return an error if the pix_fmt is not supported.)

Arguments

  • dst_data: data pointers to destination image
  • dst_linesize: linesizes for the destination image
  • pix_fmt: the pixel format of the image
  • range: the color range of the image (important for colorspaces such as YUV)
  • width: the width of the image in pixels
  • height: the height of the image in pixels

Returns

0 if the image data was cleared, a negative AVERROR code otherwise

source
VideoIO.libffmpeg.av_image_fill_colorMethod
av_image_fill_color(dst_data, dst_linesize, pix_fmt::AVPixelFormat, color, width::Integer, height::Integer, flags::Integer)

Overwrite the image data with a color. This is suitable for filling a sub-rectangle of an image, meaning the padding between the right most pixel and the left most pixel on the next line will not be overwritten. For some formats, the image size might be rounded up due to inherent alignment.

If the pixel format has alpha, it is also replaced. Color component values are interpreted as native integers (or intfloats) regardless of actual pixel format endianness.

This can return an error if the pixel format is not supported. Normally, all non-hwaccel pixel formats should be supported.

Passing NULL for dst_data is allowed. Then the function returns whether the operation would have succeeded. (It can return an error if the pix_fmt is not supported.)

Arguments

  • dst_data: data pointers to destination image
  • dst_linesize: linesizes for the destination image
  • pix_fmt: the pixel format of the image
  • color: the color components to be used for the fill
  • width: the width of the image in pixels
  • height: the height of the image in pixels
  • flags: currently unused

Returns

0 if the image data was filled, a negative AVERROR code otherwise

source
VideoIO.libffmpeg.av_image_fill_linesizesMethod
av_image_fill_linesizes(linesizes, pix_fmt::AVPixelFormat, width::Integer)

Fill plane linesizes for an image with pixel format pix_fmt and width width.

Arguments

  • linesizes: array to be filled with the linesize for each plane
  • pix_fmt: the AVPixelFormat of the image
  • width: width of the image in pixels

Returns

= 0 in case of success, a negative error code otherwise

source
VideoIO.libffmpeg.av_image_fill_max_pixstepsMethod
av_image_fill_max_pixsteps(max_pixsteps, max_pixstep_comps, pixdesc)

Compute the max pixel step for each plane of an image with a format described by pixdesc.

The pixel step is the distance in bytes between the first byte of the group of bytes which describe a pixel component and the first byte of the successive group in the same plane for the same component.

Arguments

  • max_pixsteps: an array which is filled with the max pixel step for each plane. Since a plane may contain different pixel components, the computed max_pixsteps[plane] is relative to the component in the plane with the max pixel step.
  • max_pixstep_comps: an array which is filled with the component for each plane which has the max pixel step. May be NULL.
  • pixdesc: the AVPixFmtDescriptor for the image, describing its format
source
VideoIO.libffmpeg.av_image_fill_plane_sizesMethod
av_image_fill_plane_sizes(size, pix_fmt::AVPixelFormat, height::Integer, linesizes)

Fill plane sizes for an image with pixel format pix_fmt and height height.

Note

The linesize parameters have the type ptrdiff_t here, while they are int for av_image_fill_linesizes().

Arguments

  • size: the array to be filled with the size of each image plane
  • pix_fmt: the AVPixelFormat of the image
  • height: height of the image in pixels
  • linesizes: the array containing the linesize for each plane, should be filled by av_image_fill_linesizes()

Returns

= 0 in case of success, a negative error code otherwise

source
VideoIO.libffmpeg.av_image_fill_pointersMethod
av_image_fill_pointers(data, pix_fmt::AVPixelFormat, height::Integer, ptr, linesizes)

Fill plane data pointers for an image with pixel format pix_fmt and height height.

Arguments

  • data: pointers array to be filled with the pointer for each image plane
  • pix_fmt: the AVPixelFormat of the image
  • height: height of the image in pixels
  • ptr: the pointer to a buffer which will contain the image
  • linesizes: the array containing the linesize for each plane, should be filled by av_image_fill_linesizes()

Returns

the size in bytes required for the image buffer, a negative error code in case of failure

source
VideoIO.libffmpeg.av_image_get_buffer_sizeMethod
av_image_get_buffer_size(pix_fmt::AVPixelFormat, width::Integer, height::Integer, align::Integer)

Return the size in bytes of the amount of data required to store an image with the given parameters.

Arguments

  • pix_fmt: the pixel format of the image
  • width: the width of the image in pixels
  • height: the height of the image in pixels
  • align: the assumed linesize alignment

Returns

the buffer size in bytes, a negative error code in case of failure

source
VideoIO.libffmpeg.av_image_get_linesizeMethod
av_image_get_linesize(pix_fmt::AVPixelFormat, width::Integer, plane::Integer)

Compute the size of an image line with format pix_fmt and width width for the plane plane.

Returns

the computed size in bytes

source
VideoIO.libffmpeg.av_index_search_timestampMethod
av_index_search_timestamp(st, timestamp::Int64, flags::Integer)

Get the index for a specific timestamp.

Arguments

  • st: stream that the timestamp belongs to
  • timestamp: timestamp to retrieve the index for
  • flags: if AVSEEK_FLAG_BACKWARD then the returned index will correspond to the timestamp which is <= the requested one, if backward is 0, then it will be >= if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise

Returns

< 0 if no such timestamp could be found

source
VideoIO.libffmpeg.av_init_packetMethod
av_init_packet(pkt)

Initialize optional fields of a packet with default values.

Note, this does not touch the data and size members, which have to be initialized separately.

Deprecated

This function is deprecated. Once it's removed, sizeof(AVPacket) will not be a part of the ABI anymore.

Arguments

  • pkt: packet

See also

av_packet_alloc, av_packet_unref

source
VideoIO.libffmpeg.av_input_audio_device_nextMethod
av_input_audio_device_next(d)

Audio input devices iterator.

If d is NULL, returns the first registered input audio/video device, if d is non-NULL, returns the next registered input audio/video device after d or NULL if d is the last one.

source
VideoIO.libffmpeg.av_input_video_device_nextMethod
av_input_video_device_next(d)

Video input devices iterator.

If d is NULL, returns the first registered input audio/video device, if d is non-NULL, returns the next registered input audio/video device after d or NULL if d is the last one.

source
VideoIO.libffmpeg.av_int_list_length_for_sizeMethod
av_int_list_length_for_size(elsize::Integer, list, term::UInt64)

Compute the length of an integer list.

Arguments

  • elsize: size in bytes of each list element (only 1, 2, 4 or 8)
  • term: list terminator (usually 0 or -1)
  • list: pointer to the list

Returns

length of the list, in elements, not counting the terminator

source
VideoIO.libffmpeg.av_interleaved_write_frameMethod
av_interleaved_write_frame(s, pkt)

Write a packet to an output media file ensuring correct interleaving.

This function will buffer the packets internally as needed to make sure the packets in the output file are properly interleaved, usually ordered by increasing dts. Callers doing their own interleaving should call av_write_frame() instead of this function.

Using this function instead of av_write_frame() can give muxers advance knowledge of future packets, improving e.g. the behaviour of the mp4 muxer for VFR content in fragmenting mode.

Arguments

  • s: media file handle
  • pkt: The packet containing the data to be written. <br> If the packet is reference-counted, this function will take ownership of this reference and unreference it later when it sees fit. If the packet is not reference-counted, libavformat will make a copy. The returned packet will be blank (as if returned from av_packet_alloc()), even on error. <br> This parameter can be NULL (at any time, not just at the end), to flush the interleaving queues. <br> Packet's AVPacket.streamindex "stream\index" field must be set to the index of the corresponding stream in AVFormatContext.streams "s->streams". <br> The timestamps (AVPacket.pts "pts", AVPacket.dts "dts") must be set to correct values in the stream's timebase (unless the output format is flagged with the AVFMT_NOTIMESTAMPS flag, then they can be set to AV_NOPTS_VALUE). The dts for subsequent packets in one stream must be strictly increasing (unless the output format is flagged with the AVFMT_TS_NONSTRICT, then they merely have to be nondecreasing). AVPacket.duration "duration" should also be set if known.

Returns

0 on success, a negative AVERROR on error.

See also

av_write_frame(), AVFormatContext.max_interleave_delta

source
VideoIO.libffmpeg.av_interleaved_write_uncoded_frameMethod
av_interleaved_write_uncoded_frame(s, stream_index::Integer, frame)

Write an uncoded frame to an output media file.

If the muxer supports it, this function makes it possible to write an AVFrame structure directly, without encoding it into a packet. It is mostly useful for devices and similar special muxers that use raw video or PCM data and will not serialize it into a byte stream.

To test whether it is possible to use it with a given muxer and stream, use av_write_uncoded_frame_query().

The caller gives up ownership of the frame and must not access it afterwards.

Returns

=0 for success, a negative code on error

source
VideoIO.libffmpeg.av_lfg_getMethod
av_lfg_get(c)

Get the next random unsigned 32-bit number using an ALFG.

Please also consider a simple LCG like state= state*1664525+1013904223, it may be good enough and faster for your specific use case.

source
VideoIO.libffmpeg.av_lzo1x_decodeMethod
av_lzo1x_decode(out, outlen, in, inlen)

Decodes LZO 1x compressed data.

Make sure all buffers are appropriately padded, in must provide AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes.

Arguments

  • out: output buffer
  • outlen: size of output buffer, number of bytes left are returned here
  • in: input buffer
  • inlen: size of input buffer, number of bytes left are returned here

Returns

0 on success, otherwise a combination of the error flags above

source
VideoIO.libffmpeg.av_make_error_stringMethod
av_make_error_string(errbuf, errbuf_size::Csize_t, errnum::Integer)

Fill the provided buffer with a string containing an error string corresponding to the AVERROR code errnum.

Arguments

  • errbuf: a buffer
  • errbuf_size: size in bytes of errbuf
  • errnum: error code to describe

Returns

the buffer in input, filled with the error description

See also

av_strerror()

source
VideoIO.libffmpeg.av_mallocMethod
av_malloc(size::Csize_t)

Allocate a memory block with alignment suitable for all memory accesses (including vectors if available on the CPU).

Arguments

  • size: Size in bytes for the memory block to be allocated

Returns

Pointer to the allocated block, or NULL if the block cannot be allocated

See also

av_mallocz()

source
VideoIO.libffmpeg.av_malloc_arrayMethod
av_malloc_array(nmemb::Csize_t, size::Csize_t)

Allocate a memory block for an array with av_malloc().

The allocated memory will have size size * nmemb bytes.

Arguments

  • nmemb: Number of element
  • size: Size of a single element

Returns

Pointer to the allocated block, or NULL if the block cannot be allocated

See also

av_malloc()

source
VideoIO.libffmpeg.av_malloczMethod
av_mallocz(size::Csize_t)

Allocate a memory block with alignment suitable for all memory accesses (including vectors if available on the CPU) and zero all the bytes of the block.

Arguments

  • size: Size in bytes for the memory block to be allocated

Returns

Pointer to the allocated block, or NULL if it cannot be allocated

See also

av_malloc()

source
VideoIO.libffmpeg.av_match_extMethod
av_match_ext(filename, extensions)

Return a positive value if the given filename has one of the given extensions, 0 otherwise.

Arguments

  • filename: file name to check against the given extensions
  • extensions: a comma-separated list of filename extensions
source
VideoIO.libffmpeg.av_match_listMethod
av_match_list(name, list, separator::Cchar)

Check if a name is in a list.

Returns

0 if not found, or the 1 based index where it has been found in the list.

source
VideoIO.libffmpeg.av_match_nameMethod
av_match_name(name, names)

Match instances of a name in a comma-separated list of names. List entries are checked from the start to the end of the names list, the first match ends further processing. If an entry prefixed with '-' matches, then 0 is returned. The "ALL" list entry is considered to match all names.

Arguments

  • name: Name to look for.
  • names: List of names.

Returns

1 on match, 0 otherwise.

source
VideoIO.libffmpeg.av_max_allocMethod
av_max_alloc(max::Csize_t)

Set the maximum size that may be allocated in one block.

The value specified with this function is effective for all libavutil's lavumemfuncs "heap management functions."

By default, the max value is defined as INT_MAX.

Warning

Exercise extreme caution when using this function. Don't touch this if you do not understand the full consequence of doing so.

Arguments

  • max: Value to be set as the new maximum size
source
VideoIO.libffmpeg.av_md5_finalMethod
av_md5_final(ctx, dst)

Finish hashing and output digest value.

Arguments

  • ctx: hash function context
  • dst: buffer where output digest value is stored
source
VideoIO.libffmpeg.av_md5_sumMethod
av_md5_sum(dst, src, len::Csize_t)

Hash an array of data.

Arguments

  • dst: The output buffer to write the digest into
  • src: The data to hash
  • len: The length of the data, in bytes
source
VideoIO.libffmpeg.av_md5_updateMethod
av_md5_update(ctx, src, len::Csize_t)

Update hash value.

Arguments

  • ctx: hash function context
  • src: input data to update hash with
  • len: input data length
source
VideoIO.libffmpeg.av_mediacodec_default_initMethod
av_mediacodec_default_init(avctx, ctx, surface)

Convenience function that sets up the MediaCodec context.

Arguments

  • avctx: codec context
  • ctx: MediaCodec context to initialize
  • surface: reference to an android/view/Surface

Returns

0 on success, < 0 otherwise

source
VideoIO.libffmpeg.av_mediacodec_release_bufferMethod
av_mediacodec_release_buffer(buffer, render::Integer)

Release a MediaCodec buffer and render it to the surface that is associated with the decoder. This function should only be called once on a given buffer, once released the underlying buffer returns to the codec, thus subsequent calls to this function will have no effect.

Arguments

  • buffer: the buffer to render
  • render: 1 to release and render the buffer to the surface or 0 to discard the buffer

Returns

0 on success, < 0 otherwise

source
VideoIO.libffmpeg.av_mediacodec_render_buffer_at_timeMethod
av_mediacodec_render_buffer_at_time(buffer, time::Int64)

Release a MediaCodec buffer and render it at the given time to the surface that is associated with the decoder. The timestamp must be within one second of the current java/lang/System#nanoTime() (which is implemented using CLOCK_MONOTONIC on Android). See the Android MediaCodec documentation of [android/media/MediaCodec#releaseOutputBuffer(int,long)][0] for more details.

[0]: https://developer.android.com/reference/android/media/MediaCodec#releaseOutputBuffer(int,20long)

Arguments

  • buffer: the buffer to render
  • time: timestamp in nanoseconds of when to render the buffer

Returns

0 on success, < 0 otherwise

source
VideoIO.libffmpeg.av_memcpy_backptrMethod
av_memcpy_backptr(dst, back::Integer, cnt::Integer)

Overlapping memcpy() implementation.

Note

cnt > back is valid, this will copy the bytes we just copied, thus creating a repeating pattern with a period length of back.

Arguments

  • dst: Destination buffer
  • back: Number of bytes back to start copying (i.e. the initial size of the overlapping window); must be > 0
  • cnt: Number of bytes to copy; must be >= 0
source
VideoIO.libffmpeg.av_memdupMethod
av_memdup(p, size::Csize_t)

Duplicate a buffer with av_malloc().

Arguments

  • p: Buffer to be duplicated
  • size: Size in bytes of the buffer copied

Returns

Pointer to a newly allocated buffer containing a copy of p or NULL if the buffer cannot be allocated

source
VideoIO.libffmpeg.av_murmur3_updateMethod
av_murmur3_update(c, src, len::Csize_t)

Update hash context with new data.

Arguments

  • c:[out] Hash context
  • src:[in] Input data to update hash with
  • len:[in] Number of bytes to read from src
source
VideoIO.libffmpeg.av_muxer_iterateMethod
av_muxer_iterate(opaque)

Iterate over all registered muxers.

Arguments

  • opaque: a pointer where libavformat will store the iteration state. Must point to NULL to start the iteration.

Returns

the next registered muxer or NULL when the iteration is finished

source
VideoIO.libffmpeg.av_nearer_qMethod
av_nearer_q(q::AVRational, q1::AVRational, q2::AVRational)

Find which of the two rationals is closer to another rational.

Arguments

  • q: Rational to be compared against
  • q1: Rational to be tested
  • q2: Rational to be tested

Returns

One of the following values: - 1 if q1 is nearer to q than q2 - -1 if q2 is nearer to q than q1 - 0 if they have the same distance

source
VideoIO.libffmpeg.av_new_packetMethod
av_new_packet(pkt, size::Integer)

Allocate the payload of a packet and initialize its fields with default values.

Arguments

  • pkt: packet
  • size: wanted payload size

Returns

0 if OK, AVERROR_xxx otherwise

source
VideoIO.libffmpeg.av_opt_child_nextMethod
av_opt_child_next(obj, prev)

Iterate over AVOptions-enabled children of obj.

Arguments

  • prev: result of a previous call to this function or NULL

Returns

next AVOptions-enabled child or NULL

source
VideoIO.libffmpeg.av_opt_copyMethod
av_opt_copy(dest, src)

Copy options from src object into dest object.

The underlying AVClass of both src and dest must coincide. The guarantee below does not apply if this is not fulfilled.

Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object. Original memory allocated for such options is freed unless both src and dest options points to the same memory.

Even on error it is guaranteed that allocated options from src and dest no longer alias each other afterwards; in particular calling av_opt_free() on both src and dest is safe afterwards if dest has been memdup'ed from src.

Arguments

  • dest: Object to copy from
  • src: Object to copy into

Returns

0 on success, negative on error

source
VideoIO.libffmpeg.av_opt_eval_flagsMethod
av_opt_eval_flags(obj, o, val, flags_out)

opt_eval_funcs Evaluating option strings

@{ This group of functions can be used to evaluate option strings and get numbers out of them. They do the same thing as av_opt_set(), except the result is written into the caller-supplied pointer.

Arguments

  • obj: a struct whose first element is a pointer to AVClass.
  • o: an option for which the string is to be evaluated.
  • val: string to be evaluated.
  • *_out: value of the string will be written here.

Returns

0 on success, a negative number on failure.

source
VideoIO.libffmpeg.av_opt_findMethod
av_opt_find(obj, name, unit, opt_flags::Integer, search_flags::Integer)

Look for an option in an object. Consider only options which have all the specified flags set.

Note

Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable directly with av_opt_set(). Use special calls which take an options AVDictionary (e.g. avformat_open_input()) to set options found with this flag.

Arguments

  • obj:[in] A pointer to a struct whose first element is a pointer to an AVClass. Alternatively a double pointer to an AVClass, if AV_OPT_SEARCH_FAKE_OBJ search flag is set.
  • name:[in] The name of the option to look for.
  • unit:[in] When searching for named constants, name of the unit it belongs to.
  • opt_flags: Find only options with all the specified flags set (AV_OPT_FLAG).
  • search_flags: A combination of AV_OPT_SEARCH_*.

Returns

A pointer to the option found, or NULL if no option was found.

source
VideoIO.libffmpeg.av_opt_find2Method
av_opt_find2(obj, name, unit, opt_flags::Integer, search_flags::Integer, target_obj)

Look for an option in an object. Consider only options which have all the specified flags set.

Arguments

  • obj:[in] A pointer to a struct whose first element is a pointer to an AVClass. Alternatively a double pointer to an AVClass, if AV_OPT_SEARCH_FAKE_OBJ search flag is set.
  • name:[in] The name of the option to look for.
  • unit:[in] When searching for named constants, name of the unit it belongs to.
  • opt_flags: Find only options with all the specified flags set (AV_OPT_FLAG).
  • search_flags: A combination of AV_OPT_SEARCH_*.
  • target_obj:[out] if non-NULL, an object to which the option belongs will be written here. It may be different from obj if AV_OPT_SEARCH_CHILDREN is present in search_flags. This parameter is ignored if search_flags contain AV_OPT_SEARCH_FAKE_OBJ.

Returns

A pointer to the option found, or NULL if no option was found.

source
VideoIO.libffmpeg.av_opt_flag_is_setMethod
av_opt_flag_is_set(obj, field_name, flag_name)

Check whether a particular flag is set in a flags field.

Arguments

  • field_name: the name of the flag field option
  • flag_name: the name of the flag to check

Returns

non-zero if the flag is set, zero if the flag isn't set, isn't of the right type, or the flags field doesn't exist.

source
VideoIO.libffmpeg.av_opt_getMethod
av_opt_get(obj, name, search_flags::Integer, out_val)

opt_get_funcs Option getting functions

@{ Those functions get a value of the option with the given name from an object.

Note

the returned string will be av_malloc()ed and must be av_free()ed by the caller

Note

if AV_OPT_ALLOW_NULL is set in search_flags in av_opt_get, and the option is of type AV_OPT_TYPE_STRING, AV_OPT_TYPE_BINARY or AV_OPT_TYPE_DICT and is set to NULL, *out_val will be set to NULL instead of an allocated empty string.

Arguments

  • obj:[in] a struct whose first element is a pointer to an AVClass.
  • name:[in] name of the option to get.
  • search_flags:[in] flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN is passed here, then the option may be found in a child of obj.
  • out_val:[out] value of the option will be written here

Returns

=0 on success, a negative error code otherwise

source
VideoIO.libffmpeg.av_opt_get_arrayMethod
av_opt_get_array(obj, name, search_flags::Integer, start_elem::Integer, nb_elems::Integer, out_type::AVOptionType, out_val)

For an array-type option, retrieve the values of one or more array elements.

The array elements produced by this function will will be as if av_opt_getX() was called for each element, where X is specified by out_type. E.g. AV_OPT_TYPE_STRING corresponds to av_opt_get().

Typically this should be the same as the scalarized type of the AVOption being retrieved, but certain conversions are also possible - the same as those done by the corresponding av_opt_get*() function. E.g. any option type can be retrieved as a string, numeric types can be retrieved as int64, double, or rational, etc.

For dynamically allocated types (strings, binary, dicts, etc.), the result is owned and freed by the caller.

Arguments

  • start_elem: index of the first array element to retrieve
  • nb_elems: number of array elements to retrieve; start_elem+nb_elems must not be larger than array size as returned by av_opt_get_array_size()
  • out_type: Option type corresponding to the desired output.
  • out_val: Array with nb_elems members into which the output will be written. The array type must match the underlying C type as documented for out_type, and be zeroed on entry to this function.
source
VideoIO.libffmpeg.av_opt_get_key_valueMethod
av_opt_get_key_value(ropts, key_val_sep, pairs_sep, flags::Integer, rkey, rval)

Extract a key-value pair from the beginning of a string.

Arguments

  • ropts: pointer to the options string, will be updated to point to the rest of the string (one of the pairs_sep or the final NUL)
  • key_val_sep: a 0-terminated list of characters used to separate key from value, for example '='
  • pairs_sep: a 0-terminated list of characters used to separate two pairs from each other, for example ':' or ','
  • flags: flags; see the AV_OPT_FLAG_* values below
  • rkey: parsed key; must be freed using av_free()
  • rval: parsed value; must be freed using av_free()

Returns

=0 for success, or a negative value corresponding to an AVERROR code in case of error; in particular: AVERROR(EINVAL) if no key is present

source
VideoIO.libffmpeg.av_opt_is_set_to_defaultMethod
av_opt_is_set_to_default(obj, o)

Check if given option is set to its default value.

Options o must belong to the obj. This function must not be called to check child's options state.

Arguments

  • obj: AVClass object to check option on
  • o: option to be checked

Returns

0 when option is set to its default, 0 when option is not set its default, <0 on error

See also

av_opt_is_set_to_default_by_name().

source
VideoIO.libffmpeg.av_opt_is_set_to_default_by_nameMethod
av_opt_is_set_to_default_by_name(obj, name, search_flags::Integer)

Check if given option is set to its default value.

Arguments

  • obj: AVClass object to check option on
  • name: option name
  • search_flags: combination of AV_OPT_SEARCH_*

Returns

0 when option is set to its default, 0 when option is not set its default, <0 on error

source
VideoIO.libffmpeg.av_opt_ptrMethod
av_opt_ptr(avclass, obj, name)

Gets a pointer to the requested field in a struct. This function allows accessing a struct even when its fields are moved or renamed since the application making the access has been compiled,

Deprecated

direct access to AVOption-exported fields is not supported

Returns

a pointer to the field, it can be cast to the correct type and read or written to.

source
VideoIO.libffmpeg.av_opt_query_rangesMethod
av_opt_query_ranges(arg1, obj, key, flags::Integer)

Get a list of allowed ranges for the given option.

The returned list may depend on other fields in obj like for example profile.

The result must be freed with av_opt_freep_ranges.

Arguments

Returns

number of components returned on success, a negative error code otherwise

See also

AVOptionRanges

source
VideoIO.libffmpeg.av_opt_query_ranges_defaultMethod
av_opt_query_ranges_default(arg1, obj, key, flags::Integer)

Get a default list of allowed ranges for the given option.

This list is constructed without using the AVClass.query_ranges() callback and can be used as fallback from within the callback.

The result must be freed with av_opt_free_ranges.

Arguments

Returns

number of components returned on success, a negative error code otherwise

See also

AVOptionRanges

source
VideoIO.libffmpeg.av_opt_serializeMethod
av_opt_serialize(obj, opt_flags::Integer, flags::Integer, buffer, key_val_sep::Cchar, pairs_sep::Cchar)

Serialize object's options.

Create a string containing object's serialized options. Such string may be passed back to av_opt_set_from_string() in order to restore option values. A key/value or pairs separator occurring in the serialized value or name string are escaped through the av_escape() function.

Warning

Separators cannot be neither '\' nor '\0'. They also cannot be the same.

Arguments

  • obj:[in] AVClass object to serialize
  • opt_flags:[in] serialize options with all the specified flags set (AV_OPT_FLAG)
  • flags:[in] combination of AV_OPT_SERIALIZE_* flags
  • buffer:[out] Pointer to buffer that will be allocated with string containing serialized options. Buffer must be freed by the caller when is no longer needed.
  • key_val_sep:[in] character used to separate key from value
  • pairs_sep:[in] character used to separate two pairs from each other

Returns

= 0 on success, negative on error

source
VideoIO.libffmpeg.av_opt_setMethod
av_opt_set(obj, name, val, search_flags::Integer)

opt_set_funcs Option setting functions

@{ Those functions set the field of obj with the given name to value.

Arguments

  • obj:[in] A struct whose first element is a pointer to an AVClass.
  • name:[in] the name of the field to set
  • val:[in] The value to set. In case of av_opt_set() if the field is not of a string type, then the given string is parsed. SI postfixes and some named scalars are supported. If the field is of a numeric type, it has to be a numeric or named scalar. Behavior with more than one scalar and +- infix operators is undefined. If the field is of a flags type, it has to be a sequence of numeric scalars or named flags separated by '+' or '-'. Prefixing a flag with '+' causes it to be set without affecting the other flags; similarly, '-' unsets a flag. If the field is of a dictionary type, it has to be a ':' separated list of key=value parameters. Values containing ':' special characters must be escaped.
  • search_flags: flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN is passed here, then the option may be set on a child of obj.

Returns

0 if the value has been set, or an AVERROR code in case of error: AVERROR_OPTION_NOT_FOUND if no matching option exists AVERROR(ERANGE) if the value is out of range AVERROR(EINVAL) if the value is not valid

source
VideoIO.libffmpeg.av_opt_set_arrayMethod
av_opt_set_array(obj, name, search_flags::Integer, start_elem::Integer, nb_elems::Integer, val_type::AVOptionType, val)

Add, replace, or remove elements for an array option. Which of these operations is performed depends on the values of val and search_flags.

The effect of this function will will be as if av_opt_setX() was called for each element, where X is specified by type. E.g. AV_OPT_TYPE_STRING corresponds to av_opt_set().

Typically this should be the same as the scalarized type of the AVOption being set, but certain conversions are also possible - the same as those done by the corresponding av_opt_set*() function. E.g. any option type can be set from a string, numeric types can be set from int64, double, or rational, etc.

When NULL, nb_elems array elements starting at start_elem are removed from the array. Any array elements remaining at the end are shifted by nb_elems towards the first element in order to keep the array contiguous.

Otherwise (val is non-NULL), the type of val must match the underlying C type as documented for val_type.

When AV_OPT_ARRAY_REPLACE is not set in search_flags, the array is enlarged by nb_elems, and the contents of val are inserted at start_elem. Previously existing array elements from start_elem onwards (if present) are shifted by nb_elems away from the first element in order to make space for the new elements.

When AV_OPT_ARRAY_REPLACE is set in search_flags, the contents of val replace existing array elements from start_elem to start_elem+nb_elems (if present). New array size is max(start_elem + nb_elems, old array size).

Arguments

  • start_elem: Index of the first array element to modify; must not be larger than array size as returned by av_opt_get_array_size().
  • nb_elems: number of array elements to modify; when val is NULL, start_elem+nb_elems must not be larger than array size as returned by av_opt_get_array_size()
  • val_type: Option type corresponding to the type of val, ignored when val is NULL.
  • val: Array with nb_elems elements or NULL.
source
VideoIO.libffmpeg.av_opt_set_chlayoutMethod
av_opt_set_chlayout(obj, name, layout, search_flags::Integer)
Note

Any old chlayout present is discarded and replaced with a copy of the new one. The caller still owns layout and is responsible for uninitializing it.

source
VideoIO.libffmpeg.av_opt_set_defaults2Method
av_opt_set_defaults2(s, mask::Integer, flags::Integer)

Set the values of all AVOption fields to their default values. Only these AVOption fields for which (opt->flags & mask) == flags will have their default applied to s.

Arguments

  • s: an AVOption-enabled struct (its first member must be a pointer to AVClass)
  • mask: combination of AV_OPT_FLAG_*
  • flags: combination of AV_OPT_FLAG_*
source
VideoIO.libffmpeg.av_opt_set_dictMethod
av_opt_set_dict(obj, options)

Set all the options from a given dictionary on an object.

Arguments

  • obj: a struct whose first element is a pointer to AVClass
  • options: options to process. This dictionary will be freed and replaced by a new one containing all options not found in obj. Of course this new dictionary needs to be freed by caller with av_dict_free().

Returns

0 on success, a negative AVERROR if some option was found in obj, but could not be set.

See also

av_dict_copy()

source
VideoIO.libffmpeg.av_opt_set_dict2Method
av_opt_set_dict2(obj, options, search_flags::Integer)

Set all the options from a given dictionary on an object.

Arguments

  • obj: a struct whose first element is a pointer to AVClass
  • options: options to process. This dictionary will be freed and replaced by a new one containing all options not found in obj. Of course this new dictionary needs to be freed by caller with av_dict_free().
  • search_flags: A combination of AV_OPT_SEARCH_*.

Returns

0 on success, a negative AVERROR if some option was found in obj, but could not be set.

See also

av_dict_copy()

source
VideoIO.libffmpeg.av_opt_set_dict_valMethod
av_opt_set_dict_val(obj, name, val, search_flags::Integer)
Note

Any old dictionary present is discarded and replaced with a copy of the new one. The caller still owns val is and responsible for freeing it.

source
VideoIO.libffmpeg.av_opt_set_from_stringMethod
av_opt_set_from_string(ctx, opts, shorthand, key_val_sep, pairs_sep)

Parse the key-value pairs list in opts. For each key=value pair found, set the value of the corresponding option in ctx.

Options names must use only the following characters: a-z A-Z 0-9 - . / _ Separators must use characters distinct from option names and from each other.

Arguments

  • ctx: the AVClass object to set options on
  • opts: the options string, key-value pairs separated by a delimiter
  • shorthand: a NULL-terminated array of options names for shorthand notation: if the first field in opts has no key part, the key is taken from the first element of shorthand; then again for the second, etc., until either opts is finished, shorthand is finished or a named option is found; after that, all options must be named
  • key_val_sep: a 0-terminated list of characters used to separate key from value, for example '='
  • pairs_sep: a 0-terminated list of characters used to separate two pairs from each other, for example ':' or ','

Returns

the number of successfully set key=value pairs, or a negative value corresponding to an AVERROR code in case of error: AVERROR(EINVAL) if opts cannot be parsed, the error code issued by av_set_string3() if a key/value pair cannot be set

source
VideoIO.libffmpeg.av_opt_show2Method
av_opt_show2(obj, av_log_obj, req_flags::Integer, rej_flags::Integer)

Show the obj options.

Arguments

  • req_flags: requested flags for the options to show. Show only the options for which it is opt->flags & req_flags.
  • rej_flags: rejected flags for the options to show. Show only the options for which it is !(opt->flags & req_flags).
  • av_log_obj: log context to use for showing the options
source
VideoIO.libffmpeg.av_output_audio_device_nextMethod
av_output_audio_device_next(d)

Audio output devices iterator.

If d is NULL, returns the first registered output audio/video device, if d is non-NULL, returns the next registered output audio/video device after d or NULL if d is the last one.

source
VideoIO.libffmpeg.av_output_video_device_nextMethod
av_output_video_device_next(d)

Video output devices iterator.

If d is NULL, returns the first registered output audio/video device, if d is non-NULL, returns the next registered output audio/video device after d or NULL if d is the last one.

source
VideoIO.libffmpeg.av_packet_add_side_dataMethod
av_packet_add_side_data(pkt, type::AVPacketSideDataType, data, size::Csize_t)

Wrap an existing array as a packet side data.

Arguments

  • pkt: packet
  • type: side information type
  • data: the side data array. It must be allocated with the av_malloc() family of functions. The ownership of the data is transferred to pkt.
  • size: side information size

Returns

a non-negative number on success, a negative AVERROR code on failure. On failure, the packet is unchanged and the data remains owned by the caller.

source
VideoIO.libffmpeg.av_packet_copy_propsMethod
av_packet_copy_props(dst, src)

Copy only "properties" fields from src to dst.

Properties for the purpose of this function are all the fields beside those related to the packet data (buf, data, size)

Arguments

  • dst: Destination packet
  • src: Source packet

Returns

0 on success AVERROR on failure.

source
VideoIO.libffmpeg.av_packet_freeMethod
av_packet_free(pkt)

Free the packet, if the packet is reference counted, it will be unreferenced first.

Note

passing NULL is a no-op.

Arguments

  • pkt: packet to be freed. The pointer will be set to NULL.
source
VideoIO.libffmpeg.av_packet_from_dataMethod
av_packet_from_data(pkt, data, size::Integer)

Initialize a reference-counted packet from av_malloc()ed data.

Arguments

  • pkt: packet to be initialized. This function will set the data, size, and buf fields, all others are left untouched.
  • data: Data allocated by av_malloc() to be used as packet data. If this function returns successfully, the data is owned by the underlying AVBuffer. The caller may not access the data through other means.
  • size: size of data in bytes, without the padding. I.e. the full buffer size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE.

Returns

0 on success, a negative AVERROR on error

source
VideoIO.libffmpeg.av_packet_get_side_dataMethod
av_packet_get_side_data(pkt, type::AVPacketSideDataType, size)

Get side information from packet.

Arguments

  • pkt: packet
  • type: desired side information type
  • size: If supplied, *size will be set to the size of the side data or to zero if the desired side data is not present.

Returns

pointer to data if present or NULL otherwise

source
VideoIO.libffmpeg.av_packet_make_writableMethod
av_packet_make_writable(pkt)

Create a writable reference for the data described by a given packet, avoiding data copy if possible.

Arguments

  • pkt: Packet whose data should be made writable.

Returns

0 on success, a negative AVERROR on failure. On failure, the packet is unchanged.

source
VideoIO.libffmpeg.av_packet_new_side_dataMethod
av_packet_new_side_data(pkt, type::AVPacketSideDataType, size::Csize_t)

Allocate new information of a packet.

Arguments

  • pkt: packet
  • type: side information type
  • size: side information size

Returns

pointer to fresh allocated data or NULL otherwise

source
VideoIO.libffmpeg.av_packet_pack_dictionaryMethod
av_packet_pack_dictionary(dict, size)

Pack a dictionary for use in side_data.

Arguments

  • dict: The dictionary to pack.
  • size: pointer to store the size of the returned data

Returns

pointer to data if successful, NULL otherwise

source
VideoIO.libffmpeg.av_packet_refMethod
av_packet_ref(dst, src)

Setup a new reference to the data described by a given packet

If src is reference-counted, setup dst as a new reference to the buffer in src. Otherwise allocate a new buffer in dst and copy the data from src into it.

All the other fields are copied from src.

Arguments

  • dst: Destination packet. Will be completely overwritten.
  • src: Source packet

Returns

0 on success, a negative AVERROR on error. On error, dst will be blank (as if returned by av_packet_alloc()).

See also

av_packet_unref

source
VideoIO.libffmpeg.av_packet_rescale_tsMethod
av_packet_rescale_ts(pkt, tb_src::AVRational, tb_dst::AVRational)

Convert valid timing fields (timestamps / durations) in a packet from one timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be ignored.

Arguments

  • pkt: packet on which the conversion will be performed
  • tb_src: source timebase, in which the timing fields in pkt are expressed
  • tb_dst: destination timebase, to which the timing fields will be converted
source
VideoIO.libffmpeg.av_packet_shrink_side_dataMethod
av_packet_shrink_side_data(pkt, type::AVPacketSideDataType, size::Csize_t)

Shrink the already allocated side data buffer

Arguments

  • pkt: packet
  • type: side information type
  • size: new side information size

Returns

0 on success, < 0 on failure

source
VideoIO.libffmpeg.av_packet_side_data_addMethod
av_packet_side_data_add(sd, nb_sd, type::AVPacketSideDataType, data, size::Csize_t, flags::Integer)

Wrap existing data as packet side data.

Arguments

  • sd: pointer to an array of side data to which the side data should be added. *sd may be NULL, in which case the array will be initialized
  • nb_sd: pointer to an integer containing the number of entries in the array. The integer value will be increased by 1 on success.
  • type: side data type
  • data: a data array. It must be allocated with the av_malloc() family of functions. The ownership of the data is transferred to the side data array on success
  • size: size of the data array
  • flags: currently unused. Must be zero

Returns

pointer to freshly allocated side data on success, or NULL otherwise On failure, the side data array is unchanged and the data remains owned by the caller.

source
VideoIO.libffmpeg.av_packet_side_data_freeMethod
av_packet_side_data_free(sd, nb_sd)

Convenience function to free all the side data stored in an array, and the array itself.

Arguments

  • sd: pointer to array of side data to free. Will be set to NULL upon return.
  • nb_sd: pointer to an integer containing the number of entries in the array. Will be set to 0 upon return.
source
VideoIO.libffmpeg.av_packet_side_data_getMethod
av_packet_side_data_get(sd, nb_sd::Integer, type::AVPacketSideDataType)

Get side information from a side data array.

Arguments

  • sd: the array from which the side data should be fetched
  • nb_sd: value containing the number of entries in the array.
  • type: desired side information type

Returns

pointer to side data if present or NULL otherwise

source
VideoIO.libffmpeg.av_packet_side_data_newMethod
av_packet_side_data_new(psd, pnb_sd, type::AVPacketSideDataType, size::Csize_t, flags::Integer)

Allocate a new packet side data.

Arguments

  • sd: pointer to an array of side data to which the side data should be added. *sd may be NULL, in which case the array will be initialized.
  • nb_sd: pointer to an integer containing the number of entries in the array. The integer value will be increased by 1 on success.
  • type: side data type
  • size: desired side data size
  • flags: currently unused. Must be zero

Returns

pointer to freshly allocated side data on success, or NULL otherwise.

source
VideoIO.libffmpeg.av_packet_side_data_removeMethod
av_packet_side_data_remove(sd, nb_sd, type::AVPacketSideDataType)

Remove side data of the given type from a side data array.

Arguments

  • sd: the array from which the side data should be removed
  • nb_sd: pointer to an integer containing the number of entries in the array. Will be reduced by the amount of entries removed upon return
  • type: side information type
source
VideoIO.libffmpeg.av_packet_unpack_dictionaryMethod
av_packet_unpack_dictionary(data, size::Csize_t, dict)

Unpack a dictionary from side_data.

Arguments

  • data: data from side_data
  • size: size of the data
  • dict: the metadata storage dictionary

Returns

0 on success, < 0 on failure

source
VideoIO.libffmpeg.av_packet_unrefMethod
av_packet_unref(pkt)

Wipe the packet.

Unreference the buffer referenced by the packet and reset the remaining packet fields to their default values.

Arguments

  • pkt: The packet to be unreferenced.
source
VideoIO.libffmpeg.av_parse_colorMethod
av_parse_color(rgba_color, color_string, slen::Integer, log_ctx)

Put the RGBA values that correspond to color_string in rgba_color.

Arguments

  • rgba_color: 4-elements array of uint8_t values, where the respective red, green, blue and alpha component values are written.
  • color_string: a string specifying a color. It can be the name of a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence, possibly followed by "@" and a string representing the alpha component. The alpha component may be a string composed by "0x" followed by an hexadecimal number or a decimal number between 0.0 and 1.0, which represents the opacity value (0x00/0.0 means completely transparent, 0xff/1.0 completely opaque). If the alpha component is not specified then 0xff is assumed. The string "random" will result in a random color.
  • slen: length of the initial part of color_string containing the color. It can be set to -1 if color_string is a null terminated string containing nothing else than the color.
  • log_ctx: a pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct (used for av_log()). Can be NULL.

Returns

= 0 in case of success, a negative value in case of failure (for example if color_string cannot be parsed).

source
VideoIO.libffmpeg.av_parse_ratioMethod
av_parse_ratio(q, str, max::Integer, log_offset::Integer, log_ctx)

Parse str and store the parsed ratio in q.

Note that a ratio with infinite (1/0) or negative value is considered valid, so you should check on the returned value if you want to exclude those values.

The undefined value can be expressed using the "0:0" string.

Arguments

  • q:[in,out] pointer to the AVRational which will contain the ratio
  • str:[in] the string to parse: it has to be a string in the format num:den, a float number or an expression
  • max:[in] the maximum allowed numerator and denominator
  • log_offset:[in] log level offset which is applied to the log level of log_ctx
  • log_ctx:[in] parent logging context

Returns

= 0 on success, a negative error code otherwise

source
VideoIO.libffmpeg.av_parse_timeMethod
av_parse_time(timeval, timestr, duration::Integer)

Parse timestr and return in *time a corresponding number of microseconds.

 [{YYYY-MM-DD|YYYYMMDD}[T|t| ]]{{HH:MM:SS[.m...]]]}|{HHMMSS[.m...]]]}}[Z]
 now

If the value is "now" it takes the current time. Time is local time unless Z is appended, in which case it is interpreted as UTC. If the year-month-day part is not specified it takes the current year-month-day. - If a duration the syntax is:

 [-][HH:]MM:SS[.m...]
 [-]S+[.m...]

Arguments

  • timeval: puts here the number of microseconds corresponding to the string in timestr. If the string represents a duration, it is the number of microseconds contained in the time interval. If the string is a date, is the number of microseconds since 1st of January, 1970 up to the time of the parsed date. If timestr cannot be successfully parsed, set *time to INT64_MIN.
  • timestr: a string representing a date or a duration. - If a date the syntax is:
  • duration: flag which tells how to interpret timestr, if not zero timestr is interpreted as a duration, otherwise as a date

Returns

= 0 in case of success, a negative value corresponding to an AVERROR code otherwise

source
VideoIO.libffmpeg.av_parse_video_rateMethod
av_parse_video_rate(rate, str)

Parse str and store the detected values in *rate.

Arguments

  • rate:[in,out] pointer to the AVRational which will contain the detected frame rate
  • str:[in] the string to parse: it has to be a string in the format rate_num / rate_den, a float number or a valid video rate abbreviation

Returns

= 0 on success, a negative error code otherwise

source
VideoIO.libffmpeg.av_parse_video_sizeMethod
av_parse_video_size(width_ptr, height_ptr, str)

Parse str and put in width_ptr and height_ptr the detected values.

Arguments

  • width_ptr:[in,out] pointer to the variable which will contain the detected width value
  • height_ptr:[in,out] pointer to the variable which will contain the detected height value
  • str:[in] the string to parse: it has to be a string in the format width x height or a valid video size abbreviation.

Returns

= 0 on success, a negative error code otherwise

source
VideoIO.libffmpeg.av_parser_iterateMethod
av_parser_iterate(opaque)

Iterate over all registered codec parsers.

Arguments

  • opaque: a pointer where libavcodec will store the iteration state. Must point to NULL to start the iteration.

Returns

the next registered codec parser or NULL when the iteration is finished

source
VideoIO.libffmpeg.av_parser_parse2Method
av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size::Integer, pts::Int64, dts::Int64, pos::Int64)

Parse a packet.

Example:

   while(in_len){
       len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
                                        in_data, in_len,
                                        pts, dts, pos);
       in_data += len;
       in_len  -= len;

       if(size)
          decode_frame(data, size);
   }

Arguments

  • s: parser context.
  • avctx: codec context.
  • poutbuf: set to pointer to parsed buffer or NULL if not yet finished.
  • poutbuf_size: set to size of parsed buffer or zero if not yet finished.
  • buf: input buffer.
  • buf_size: buffer size in bytes without the padding. I.e. the full buffer size is assumed to be buf_size + AV_INPUT_BUFFER_PADDING_SIZE. To signal EOF, this should be 0 (so that the last frame can be output).
  • pts: input presentation timestamp.
  • dts: input decoding timestamp.
  • pos: input byte position in stream.

Returns

the number of bytes of the input bitstream used.

source
VideoIO.libffmpeg.av_pix_fmt_desc_nextMethod
av_pix_fmt_desc_next(prev)

Iterate over all pixel format descriptors known to libavutil.

Arguments

  • prev: previous descriptor. NULL to get the first descriptor.

Returns

next descriptor or NULL after the last descriptor

source
VideoIO.libffmpeg.av_pix_fmt_get_chroma_sub_sampleMethod
av_pix_fmt_get_chroma_sub_sample(pix_fmt::AVPixelFormat, h_shift, v_shift)

Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.

Arguments

  • pix_fmt:[in] the pixel format
  • h_shift:[out] store log2_chroma_w (horizontal/width shift)
  • v_shift:[out] store log2_chroma_h (vertical/height shift)

Returns

0 on success, AVERROR(ENOSYS) on invalid or unknown pixel format

source
VideoIO.libffmpeg.av_pix_fmt_swap_endiannessMethod
av_pix_fmt_swap_endianness(pix_fmt::AVPixelFormat)

Utility function to swap the endianness of a pixel format.

Arguments

  • pix_fmt:[in] the pixel format

Returns

pixel format with swapped endianness if it exists, otherwise AV_PIX_FMT_NONE

source
VideoIO.libffmpeg.av_pixelutils_get_sad_fnMethod
av_pixelutils_get_sad_fn(w_bits::Integer, h_bits::Integer, aligned::Integer, log_ctx)

Get a potentially optimized pointer to a Sum-of-absolute-differences function (see the av_pixelutils_sad_fn prototype).

Arguments

  • w_bits: 1<<w_bits is the requested width of the block size
  • h_bits: 1<<h_bits is the requested height of the block size
  • aligned: If set to 2, the returned sad function will assume src1 and src2 addresses are aligned on the block size. If set to 1, the returned sad function will assume src1 is aligned on the block size. If set to 0, the returned sad function assume no particular alignment.
  • log_ctx: context used for logging, can be NULL

Returns

a pointer to the SAD function or NULL in case of error (because of invalid parameters)

source
VideoIO.libffmpeg.av_pkt_dump2Method
av_pkt_dump2(f, pkt, dump_payload::Integer, st)

Send a nice dump of a packet to the specified file stream.

Arguments

  • f: The file stream pointer where the dump should be sent to.
  • pkt: packet to dump
  • dump_payload: True if the payload must be displayed, too.
  • st: AVStream that the packet belongs to
source
VideoIO.libffmpeg.av_pkt_dump_log2Method
av_pkt_dump_log2(avcl, level::Integer, pkt, dump_payload::Integer, st)

Send a nice dump of a packet to the log.

Arguments

  • avcl: A pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct.
  • level: The importance level of the message, lower values signifying higher importance.
  • pkt: packet to dump
  • dump_payload: True if the payload must be displayed, too.
  • st: AVStream that the packet belongs to
source
VideoIO.libffmpeg.av_probe_input_buffer2Method
av_probe_input_buffer2(pb, fmt, url, logctx, offset::Integer, max_probe_size::Integer)

Probe a bytestream to determine the input format. Each time a probe returns with a score that is too low, the probe buffer size is increased and another attempt is made. When the maximum probe size is reached, the input format with the highest score is returned.

Arguments

  • pb: the bytestream to probe
  • fmt: the input format is put here
  • url: the url of the stream
  • logctx: the log context
  • offset: the offset within the bytestream to probe from
  • max_probe_size: the maximum probe buffer size (zero for default)

Returns

the score in case of success, a negative value corresponding to an the maximal score is AVPROBE_SCORE_MAX AVERROR code otherwise

source
VideoIO.libffmpeg.av_probe_input_format2Method
av_probe_input_format2(pd, is_opened::Integer, score_max)

Guess the file format.

Arguments

  • pd: data to be probed
  • is_opened: Whether the file is already opened; determines whether demuxers with or without AVFMT_NOFILE are probed.
  • score_max: A probe score larger that this is required to accept a detection, the variable is set to the actual detection score afterwards. If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended to retry with a larger probe buffer.
source
VideoIO.libffmpeg.av_probe_input_format3Method
av_probe_input_format3(pd, is_opened::Integer, score_ret)

Guess the file format.

Arguments

  • is_opened: Whether the file is already opened; determines whether demuxers with or without AVFMT_NOFILE are probed.
  • score_ret: The score of the best detection.
source
VideoIO.libffmpeg.av_q2intfloatMethod
av_q2intfloat(q::AVRational)

Convert an AVRational to a IEEE 32-bit float expressed in fixed-point format.

Note

The returned value is platform-indepedant.

Arguments

  • q: Rational to be converted

Returns

Equivalent floating-point value, expressed as an unsigned 32-bit integer.

source
VideoIO.libffmpeg.av_random_bytesMethod
av_random_bytes(buf, len::Csize_t)

Generate cryptographically secure random data, i.e. suitable for use as encryption keys and similar.

\retval0 success, len bytes of random data was written into buf

\retval"a negative AVERROR code" random data could not be generated

Arguments

  • buf: buffer into which the random data will be written
  • len: size of buf in bytes
source
VideoIO.libffmpeg.av_rc4_cryptMethod
av_rc4_crypt(d, dst, src, count::Integer, iv, decrypt::Integer)

Encrypts / decrypts using the RC4 algorithm.

Arguments

  • d: pointer to the AVRC4 context
  • count: number of bytes
  • dst: destination array, can be equal to src
  • src: source array, can be equal to dst, may be NULL
  • iv: not (yet) used for RC4, should be NULL
  • decrypt: 0 for encryption, 1 for decryption, not (yet) used
source
VideoIO.libffmpeg.av_rc4_initMethod
av_rc4_init(d, key, key_bits::Integer, decrypt::Integer)

Initializes an AVRC4 context.

Arguments

  • d: pointer to the AVRC4 context
  • key: buffer containing the key
  • key_bits: must be a multiple of 8
  • decrypt: 0 for encryption, 1 for decryption, currently has no effect

Returns

zero on success, negative value otherwise

source
VideoIO.libffmpeg.av_read_frameMethod
av_read_frame(s, pkt)

Return the next frame of a stream. This function returns what is stored in the file, and does not validate that what is there are valid frames for the decoder. It will split what is stored in the file into frames and return one for each call. It will not omit invalid data between valid frames so as to give the decoder the maximum information possible for decoding.

On success, the returned packet is reference-counted (pkt->buf is set) and valid indefinitely. The packet must be freed with av_packet_unref() when it is no longer needed. For video, the packet contains exactly one frame. For audio, it contains an integer number of frames if each frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames have a variable size (e.g. MPEG audio), then it contains one frame.

pkt->pts, pkt->dts and pkt->duration are always set to correct values in AVStream.time_base units (and guessed if the format cannot provide them). pkt->pts can be AV_NOPTS_VALUE if the video format has B-frames, so it is better to rely on pkt->dts if you do not decompress the payload.

Note

pkt will be initialized, so it may be uninitialized, but it must not contain data that needs to be freed.

Returns

0 if OK, < 0 on error or end of file. On error, pkt will be blank (as if it came from av_packet_alloc()).

source
VideoIO.libffmpeg.av_read_image_line2Method
av_read_image_line2(dst, data, linesize, desc, x::Integer, y::Integer, c::Integer, w::Integer, read_pal_component::Integer, dst_element_size::Integer)

Read a line from an image, and write the values of the pixel format component c to dst.

Arguments

  • data: the array containing the pointers to the planes of the image
  • linesize: the array containing the linesizes of the image
  • desc: the pixel format descriptor for the image
  • x: the horizontal coordinate of the first pixel to read
  • y: the vertical coordinate of the first pixel to read
  • w: the width of the line to read, that is the number of values to write to dst
  • read_pal_component: if not zero and the format is a paletted format writes the values corresponding to the palette component c in data[1] to dst, rather than the palette indexes in data[0]. The behavior is undefined if the format is not paletted.
  • dst_element_size: size of elements in dst array (2 or 4 byte)
source
VideoIO.libffmpeg.av_reallocMethod
av_realloc(ptr, size::Csize_t)

Allocate, reallocate, or free a block of memory.

If ptr is NULL and size > 0, allocate a new block. Otherwise, expand or shrink that block of memory according to size.

Warning

Unlike av_malloc(), the returned pointer is not guaranteed to be correctly aligned. The returned pointer must be freed after even if size is zero.

Arguments

  • ptr: Pointer to a memory block already allocated with av_realloc() or NULL
  • size: Size in bytes of the memory block to be allocated or reallocated

Returns

Pointer to a newly-reallocated block or NULL if the block cannot be reallocated

See also

av_fast_realloc(), av_reallocp()

source
VideoIO.libffmpeg.av_realloc_arrayMethod
av_realloc_array(ptr, nmemb::Csize_t, size::Csize_t)

Allocate, reallocate, or free an array.

If ptr is NULL and nmemb > 0, allocate a new block.

Warning

Unlike av_malloc(), the allocated memory is not guaranteed to be correctly aligned. The returned pointer must be freed after even if nmemb is zero.

Arguments

  • ptr: Pointer to a memory block already allocated with av_realloc() or NULL
  • nmemb: Number of elements in the array
  • size: Size of the single element of the array

Returns

Pointer to a newly-reallocated block or NULL if the block cannot be reallocated

See also

av_reallocp_array()

source
VideoIO.libffmpeg.av_realloc_fMethod
av_realloc_f(ptr, nelem::Csize_t, elsize::Csize_t)

Allocate, reallocate, or free a block of memory.

This function does the same thing as av_realloc(), except: - It takes two size arguments and allocates nelem * elsize bytes, after checking the result of the multiplication for integer overflow. - It frees the input block in case of failure, thus avoiding the memory leak with the classic

{.c}
   buf = realloc(buf);
   if (!buf)
       return -1;

pattern.

source
VideoIO.libffmpeg.av_reallocpMethod
av_reallocp(ptr, size::Csize_t)

Allocate, reallocate, or free a block of memory through a pointer to a pointer.

If *ptr is NULL and size > 0, allocate a new block. If size is zero, free the memory block pointed to by *ptr. Otherwise, expand or shrink that block of memory according to size.

Warning

Unlike av_malloc(), the allocated memory is not guaranteed to be correctly aligned.

Arguments

  • ptr:[in,out] Pointer to a pointer to a memory block already allocated with av_realloc(), or a pointer to NULL. The pointer is updated on success, or freed on failure.
  • size:[in] Size in bytes for the memory block to be allocated or reallocated

Returns

Zero on success, an AVERROR error code on failure

source
VideoIO.libffmpeg.av_reallocp_arrayMethod
av_reallocp_array(ptr, nmemb::Csize_t, size::Csize_t)

Allocate, reallocate an array through a pointer to a pointer.

If *ptr is NULL and nmemb > 0, allocate a new block.

Warning

Unlike av_malloc(), the allocated memory is not guaranteed to be correctly aligned. *ptr must be freed after even if nmemb is zero.

Arguments

  • ptr:[in,out] Pointer to a pointer to a memory block already allocated with av_realloc(), or a pointer to NULL. The pointer is updated on success, or freed on failure.
  • nmemb:[in] Number of elements
  • size:[in] Size of the single element

Returns

Zero on success, an AVERROR error code on failure

source
VideoIO.libffmpeg.av_reduceMethod
av_reduce(dst_num, dst_den, num::Int64, den::Int64, max::Int64)

Reduce a fraction.

This is useful for framerate calculations.

Arguments

  • dst_num:[out] Destination numerator
  • dst_den:[out] Destination denominator
  • num:[in] Source numerator
  • den:[in] Source denominator
  • max:[in] Maximum allowed values for dst_num & dst_den

Returns

1 if the operation is exact, 0 otherwise

source
VideoIO.libffmpeg.av_refstruct_alloc_ext_cMethod
av_refstruct_alloc_ext_c(size::Csize_t, flags::Integer, opaque::AVRefStructOpaque, free_cb)

Allocate a refcounted object of usable size size managed via the RefStruct API.

By default (in the absence of flags to the contrary), the returned object is initially zeroed.

Arguments

  • size: Desired usable size of the returned object.
  • flags: A bitwise combination of AV_REFSTRUCT_FLAG_* flags.
  • opaque: A pointer that will be passed to the free_cb callback.
  • free_cb: A callback for freeing this object's content when its reference count reaches zero; it must not free the object itself.

Returns

A pointer to an object of the desired size or NULL on failure.

source
VideoIO.libffmpeg.av_refstruct_exclusiveMethod
av_refstruct_exclusive(obj)

Check whether the reference count of an object managed via this API is 1.

Arguments

  • obj: A pointer to an object managed via this API.

Returns

1 if the reference count of obj is 1; 0 otherwise.

source
VideoIO.libffmpeg.av_refstruct_pool_alloc_ext_cMethod
av_refstruct_pool_alloc_ext_c(size::Csize_t, flags::Integer, opaque::AVRefStructOpaque, init_cb, reset_cb, free_entry_cb, free_cb)

Allocate an AVRefStructPool, potentially using complex callbacks.

Arguments

  • size: size of the entries of the pool
  • flags: a bitwise combination of AV_REFSTRUCT_POOL_FLAG_* flags
  • opaque: A pointer that will be passed to the callbacks below.
  • init: A callback that will be called directly after a new entry has been allocated. obj has already been zeroed unless the AV_REFSTRUCT_POOL_FLAG_NO_ZEROING flag is in use.
  • reset: A callback that will be called after an entry has been returned to the pool and before it is reused.
  • free_entry: A callback that will be called when an entry is freed after the pool has been marked as to be uninitialized.
  • free: A callback that will be called when the pool itself is freed (after the last entry has been returned and freed).
source
VideoIO.libffmpeg.av_refstruct_pool_getMethod
av_refstruct_pool_get(pool)

Get an object from the pool, reusing an old one from the pool when available.

Every call to this function must happen before av_refstruct_pool_uninit(). Otherwise undefined behaviour may occur.

Arguments

  • pool: the pool from which to get the object

Returns

a reference to the object on success, NULL on error.

source
VideoIO.libffmpeg.av_refstruct_pool_uninitMethod
av_refstruct_pool_uninit(poolp)

Mark the pool as being available for freeing. It will actually be freed only once all the allocated buffers associated with the pool are released. Thus it is safe to call this function while some of the allocated buffers are still in use.

It is illegal to try to get a new entry after this function has been called.

Arguments

  • poolp: pointer to a pointer to either NULL or a pool to be freed. *poolp will be set to NULL.
source
VideoIO.libffmpeg.av_refstruct_refMethod
av_refstruct_ref(obj)

Create a new reference to an object managed via this API, i.e. increment the reference count of the underlying object and return obj.

Returns

a pointer equal to obj.

source
VideoIO.libffmpeg.av_refstruct_replaceMethod
av_refstruct_replace(dstp, src)

Ensure *dstp refers to the same object as src.

If *dstp is already equal to src, do nothing. Otherwise unreference *dstp and replace it with a new reference to src in case src != NULL (this involves incrementing the reference count of src's underlying object) or with NULL otherwise.

Arguments

  • dstp: Pointer to a pointer that is either NULL or points to an object managed via this API.
  • src: A pointer to an object managed via this API or NULL.
source
VideoIO.libffmpeg.av_refstruct_unrefMethod
av_refstruct_unref(objp)

Decrement the reference count of the underlying object and automatically free the object if there are no more references to it.

*objp == NULL is legal and a no-op.

Arguments

  • objp: Pointer to a pointer that is either NULL or points to an object managed via this API. *objp is set to NULL on return.
source
VideoIO.libffmpeg.av_rescale_deltaMethod
av_rescale_delta(in_tb::AVRational, in_ts::Int64, fs_tb::AVRational, duration::Integer, last, out_tb::AVRational)

Rescale a timestamp while preserving known durations.

This function is designed to be called per audio packet to scale the input timestamp to a different time base. Compared to a simple av_rescale_q() call, this function is robust against possible inconsistent frame durations.

The last parameter is a state variable that must be preserved for all subsequent calls for the same stream. For the first call, *last should be initialized to #AV_NOPTS_VALUE.

Note

In the context of this function, "duration" is in term of samples, not seconds.

Arguments

  • in_tb:[in] Input time base
  • in_ts:[in] Input timestamp
  • fs_tb:[in] Duration time base; typically this is finer-grained (greater) than in_tb and out_tb
  • duration:[in] Duration till the next call to this function (i.e. duration of the current packet/frame)
  • last:[in,out] Pointer to a timestamp expressed in terms of fs_tb, acting as a state variable
  • out_tb:[in] Output timebase

Returns

Timestamp expressed in terms of out_tb

source
VideoIO.libffmpeg.av_rescale_rndMethod
av_rescale_rnd(a::Int64, b::Int64, c::Int64, rnd::AVRounding)

Rescale a 64-bit integer with specified rounding.

The operation is mathematically equivalent to a * b / c, but writing that directly can overflow, and does not support different rounding methods. If the result is not representable then INT64_MIN is returned.

See also

av_rescale(), av_rescale_q(), av_rescale_q_rnd()

source
VideoIO.libffmpeg.av_ripemd_finalMethod
av_ripemd_final(context, digest)

Finish hashing and output digest value.

Arguments

  • context: hash function context
  • digest: buffer where output digest value is stored
source
VideoIO.libffmpeg.av_ripemd_initMethod
av_ripemd_init(context, bits::Integer)

Initialize RIPEMD hashing.

Arguments

  • context: pointer to the function context (of size av_ripemd_size)
  • bits: number of bits in digest (128, 160, 256 or 320 bits)

Returns

zero if initialization succeeded, -1 otherwise

source
VideoIO.libffmpeg.av_ripemd_updateMethod
av_ripemd_update(context, data, len::Csize_t)

Update hash value.

Arguments

  • context: hash function context
  • data: input data to update hash with
  • len: input data length
source
VideoIO.libffmpeg.av_sample_fmt_is_planarMethod
av_sample_fmt_is_planar(sample_fmt::AVSampleFormat)

Check if the sample format is planar.

Arguments

  • sample_fmt: the sample format to inspect

Returns

1 if the sample format is planar, 0 if it is interleaved

source
VideoIO.libffmpeg.av_samples_allocMethod
av_samples_alloc(audio_data, linesize, nb_channels::Integer, nb_samples::Integer, sample_fmt::AVSampleFormat, align::Integer)

Allocate a samples buffer for nb_samples samples, and fill data pointers and linesize accordingly. The allocated samples buffer can be freed by using av_freep(&audio_data[0]) Allocated data will be initialized to silence.

\todo return the size of the allocated buffer in case of success at the next bump

Arguments

  • audio_data:[out] array to be filled with the pointer for each channel
  • linesize:[out] aligned size for audio buffer(s), may be NULL
  • nb_channels: number of audio channels
  • nb_samples: number of samples per channel
  • sample_fmt: the sample format
  • align: buffer size alignment (0 = default, 1 = no alignment)

Returns

=0 on success or a negative error code on failure

See also

enum AVSampleFormat The documentation for AVSampleFormat describes the data layout., av_samples_fill_arrays(), av_samples_alloc_array_and_samples()

source
VideoIO.libffmpeg.av_samples_copyMethod
av_samples_copy(dst, src, dst_offset::Integer, src_offset::Integer, nb_samples::Integer, nb_channels::Integer, sample_fmt::AVSampleFormat)

Copy samples from src to dst.

Arguments

  • dst: destination array of pointers to data planes
  • src: source array of pointers to data planes
  • dst_offset: offset in samples at which the data will be written to dst
  • src_offset: offset in samples at which the data will be read from src
  • nb_samples: number of samples to be copied
  • nb_channels: number of audio channels
  • sample_fmt: audio sample format
source
VideoIO.libffmpeg.av_samples_fill_arraysMethod
av_samples_fill_arrays(audio_data, linesize, buf, nb_channels::Integer, nb_samples::Integer, sample_fmt::AVSampleFormat, align::Integer)

Fill plane data pointers and linesize for samples with sample format sample_fmt.

The audio_data array is filled with the pointers to the samples data planes: for planar, set the start point of each channel's data within the buffer, for packed, set the start point of the entire buffer only.

The value pointed to by linesize is set to the aligned size of each channel's data buffer for planar layout, or to the aligned size of the buffer for all channels for packed layout.

The buffer in buf must be big enough to contain all the samples (use av_samples_get_buffer_size() to compute its minimum size), otherwise the audio_data pointers will point to invalid data.

Arguments

  • audio_data:[out] array to be filled with the pointer for each channel
  • linesize:[out] calculated linesize, may be NULL
  • buf: the pointer to a buffer containing the samples
  • nb_channels: the number of channels
  • nb_samples: the number of samples in a single channel
  • sample_fmt: the sample format
  • align: buffer size alignment (0 = default, 1 = no alignment)

Returns

minimum size in bytes required for the buffer on success, or a negative error code on failure

See also

enum AVSampleFormat The documentation for AVSampleFormat describes the data layout.

source
VideoIO.libffmpeg.av_samples_get_buffer_sizeMethod
av_samples_get_buffer_size(linesize, nb_channels::Integer, nb_samples::Integer, sample_fmt::AVSampleFormat, align::Integer)

Get the required buffer size for the given audio parameters.

Arguments

  • linesize:[out] calculated linesize, may be NULL
  • nb_channels: the number of channels
  • nb_samples: the number of samples in a single channel
  • sample_fmt: the sample format
  • align: buffer size alignment (0 = default, 1 = no alignment)

Returns

required buffer size, or negative error code on failure

source
VideoIO.libffmpeg.av_samples_set_silenceMethod
av_samples_set_silence(audio_data, offset::Integer, nb_samples::Integer, nb_channels::Integer, sample_fmt::AVSampleFormat)

Fill an audio buffer with silence.

Arguments

  • audio_data: array of pointers to data planes
  • offset: offset in samples at which to start filling
  • nb_samples: number of samples to fill
  • nb_channels: number of audio channels
  • sample_fmt: audio sample format
source
VideoIO.libffmpeg.av_sat_add32_cMethod
av_sat_add32_c(a::Integer, b::Integer)

Add two signed 32-bit values with saturation.

Arguments

  • a: one value
  • b: another value

Returns

sum with signed saturation

source
VideoIO.libffmpeg.av_sat_add64_cMethod
av_sat_add64_c(a::Int64, b::Int64)

Add two signed 64-bit values with saturation.

Arguments

  • a: one value
  • b: another value

Returns

sum with signed saturation

source
VideoIO.libffmpeg.av_sat_dadd32_cMethod
av_sat_dadd32_c(a::Integer, b::Integer)

Add a doubled value to another value with saturation at both stages.

Arguments

  • a: first value
  • b: value doubled and added to a

Returns

sum sat(a + sat(2*b)) with signed saturation

source
VideoIO.libffmpeg.av_sat_dsub32_cMethod
av_sat_dsub32_c(a::Integer, b::Integer)

Subtract a doubled value from another value with saturation at both stages.

Arguments

  • a: first value
  • b: value doubled and subtracted from a

Returns

difference sat(a - sat(2*b)) with signed saturation

source
VideoIO.libffmpeg.av_sat_sub32_cMethod
av_sat_sub32_c(a::Integer, b::Integer)

Subtract two signed 32-bit values with saturation.

Arguments

  • a: one value
  • b: another value

Returns

difference with signed saturation

source
VideoIO.libffmpeg.av_sat_sub64_cMethod
av_sat_sub64_c(a::Int64, b::Int64)

Subtract two signed 64-bit values with saturation.

Arguments

  • a: one value
  • b: another value

Returns

difference with signed saturation

source
VideoIO.libffmpeg.av_sdp_createMethod
av_sdp_create(ac, n_files::Integer, buf, size::Integer)

Generate an SDP for an RTP session.

Note, this overwrites the id values of AVStreams in the muxer contexts for getting unique dynamic payload types.

Arguments

  • ac: array of AVFormatContexts describing the RTP streams. If the array is composed by only one context, such context can contain multiple AVStreams (one AVStream per RTP stream). Otherwise, all the contexts in the array (an AVCodecContext per RTP stream) must contain only one AVStream.
  • n_files: number of AVCodecContexts contained in ac
  • buf: buffer where the SDP will be stored (must be allocated by the caller)
  • size: the size of the buffer

Returns

0 if OK, AVERROR_xxx on error

source
VideoIO.libffmpeg.av_seek_frameMethod
av_seek_frame(s, stream_index::Integer, timestamp::Int64, flags::Integer)

Seek to the keyframe at timestamp. 'timestamp' in 'stream_index'.

Arguments

  • s: media file handle
  • stream_index: If stream_index is (-1), a default stream is selected, and timestamp is automatically converted from AV_TIME_BASE units to the stream specific time_base.
  • timestamp: Timestamp in AVStream.time_base units or, if no stream is specified, in AV_TIME_BASE units.
  • flags: flags which select direction and seeking mode

Returns

= 0 on success

source
VideoIO.libffmpeg.av_set_options_stringMethod
av_set_options_string(ctx, opts, key_val_sep, pairs_sep)

Parse the key/value pairs list in opts. For each key/value pair found, stores the value in the field in ctx that is named like the key. ctx must be an AVClass context, storing is done using AVOptions.

Arguments

  • opts: options string to parse, may be NULL
  • key_val_sep: a 0-terminated list of characters used to separate key from value
  • pairs_sep: a 0-terminated list of characters used to separate two pairs from each other

Returns

the number of successfully set key/value pairs, or a negative value corresponding to an AVERROR code in case of error: AVERROR(EINVAL) if opts cannot be parsed, the error code issued by av_opt_set() if a key/value pair cannot be set

source
VideoIO.libffmpeg.av_sha512_finalMethod
av_sha512_final(context, digest)

Finish hashing and output digest value.

Arguments

  • context: hash function context
  • digest: buffer where output digest value is stored
source
VideoIO.libffmpeg.av_sha512_initMethod
av_sha512_init(context, bits::Integer)

Initialize SHA-2 512 hashing.

Arguments

  • context: pointer to the function context (of size av_sha512_size)
  • bits: number of bits in digest (224, 256, 384 or 512 bits)

Returns

zero if initialization succeeded, -1 otherwise

source
VideoIO.libffmpeg.av_sha512_updateMethod
av_sha512_update(context, data, len::Csize_t)

Update hash value.

Arguments

  • context: hash function context
  • data: input data to update hash with
  • len: input data length
source
VideoIO.libffmpeg.av_sha_finalMethod
av_sha_final(context, digest)

Finish hashing and output digest value.

Arguments

  • context: hash function context
  • digest: buffer where output digest value is stored
source
VideoIO.libffmpeg.av_sha_initMethod
av_sha_init(context, bits::Integer)

Initialize SHA-1 or SHA-2 hashing.

Arguments

  • context: pointer to the function context (of size av_sha_size)
  • bits: number of bits in digest (SHA-1 - 160 bits, SHA-2 224 or 256 bits)

Returns

zero if initialization succeeded, -1 otherwise

source
VideoIO.libffmpeg.av_sha_updateMethod
av_sha_update(ctx, data, len::Csize_t)

Update hash value.

Arguments

  • ctx: hash function context
  • data: input data to update hash with
  • len: input data length
source
VideoIO.libffmpeg.av_size_multMethod
av_size_mult(a::Csize_t, b::Csize_t, r)

Multiply two size_t values checking for overflow.

Arguments

  • a:[in] Operand of multiplication
  • b:[in] Operand of multiplication
  • r:[out] Pointer to the result of the operation

Returns

0 on success, AVERROR(EINVAL) on overflow

source
VideoIO.libffmpeg.av_small_strptimeMethod
av_small_strptime(p, fmt, dt)

Simplified version of strptime

Parse the input string p according to the format string fmt and store its results in the structure dt. This implementation supports only a subset of the formats supported by the standard strptime().

The supported input field descriptors are listed below. - %H: the hour as a decimal number, using a 24-hour clock, in the range '00' through '23' - %J: hours as a decimal number, in the range '0' through INT_MAX - %M: the minute as a decimal number, using a 24-hour clock, in the range '00' through '59' - %S: the second as a decimal number, using a 24-hour clock, in the range '00' through '59' - %Y: the year as a decimal number, using the Gregorian calendar - %m: the month as a decimal number, in the range '1' through '12' - %d: the day of the month as a decimal number, in the range '1' through '31' - %T: alias for %H:%M:%S - %%: a literal %

Returns

a pointer to the first character not processed in this function call. In case the input string contains more characters than required by the format string the return value points right after the last consumed input character. In case the whole input string is consumed the return value points to the null byte at the end of the string. On failure NULL is returned.

source
VideoIO.libffmpeg.av_smpte_291m_anc_8bit_decodeMethod
av_smpte_291m_anc_8bit_decode(out, sample_coding::AVSmpte436mPayloadSampleCoding, sample_count::UInt16, payload, log_ctx)

Decode a AVSmpte436mCodedAnc payload into AVSmpte291mAnc8bit

Arguments

  • sample_coding:[in] the payload sample coding
  • sample_count:[in] the number of samples stored in the payload
  • payload:[in] the bytes storing the payload, the needed size can be obtained from avpriv_smpte_436m_coded_anc_payload_size
  • log_ctx:[in] context pointer for av_log
  • out:[out] The decoded ANC packet.

Returns

returns 0 on success, otherwise < 0.

source
VideoIO.libffmpeg.av_smpte_291m_anc_8bit_encodeMethod
av_smpte_291m_anc_8bit_encode(out, line_number::UInt16, wrapping_type::AVSmpte436mWrappingType, sample_coding::AVSmpte436mPayloadSampleCoding, payload, log_ctx)

Encode a AVSmpte291mAnc8bit into a AVSmpte436mCodedAnc

Arguments

  • line_number:[in] the line number the ANC packet is on
  • wrapping_type:[in] the wrapping type
  • sample_coding:[in] the payload sample coding
  • payload:[in] the ANC packet to encode.
  • log_ctx:[in] context pointer for av_log
  • out:[out] The encoded ANC packet.

Returns

returns 0 on success, otherwise < 0.

source
VideoIO.libffmpeg.av_smpte_291m_anc_8bit_extract_cta_708Method
av_smpte_291m_anc_8bit_extract_cta_708(anc, cc_data, log_ctx)

Try to decode an ANC packet into EIA-608/CTA-708 data (AV_CODEC_ID_EIA_608). This

Arguments

  • anc:[in] The ANC packet.
  • log_ctx:[in] Context pointer for av_log
  • cc_data:[out] the buffer to store the extracted EIA-608/CTA-708 data, you can pass NULL to not store the data. the required size is 3 * cc_count bytes. SMPTE_291M_ANC_PAYLOAD_CAPACITY is always enough size.

Returns

returns cc_count (>= 0) on success, AVERROR(EAGAIN) if it wasn't a CTA-708 ANC packet, < 0 on error.

source
VideoIO.libffmpeg.av_smpte_436m_anc_appendMethod
av_smpte_436m_anc_append(pkt, anc_packet_count::Integer, anc_packets)

Append more ANC packets to a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.

Arguments

  • anc_packet_count:[in] number of ANC packets to encode
  • anc_packets:[in] the ANC packets to encode
  • pkt: the AVPacket to append to. it must either be size 0 or contain valid SMPTE_436M_ANC data.

Returns

0 on success, AVERROR codes otherwise.

source
VideoIO.libffmpeg.av_smpte_436m_anc_encodeMethod
av_smpte_436m_anc_encode(out, size::Integer, anc_packet_count::Integer, anc_packets)

Encode ANC packets into a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.

Arguments

  • anc_packet_count:[in] number of ANC packets to encode
  • anc_packets:[in] the ANC packets to encode
  • size:[in] the size of out. ignored if out is NULL.
  • out:[out] Output bytes. Doesn't write anything if out is NULL.

Returns

the number of bytes written on success, AVERROR codes otherwise. If out is NULL, returns the number of bytes it would have written.

source
VideoIO.libffmpeg.av_smpte_436m_anc_iter_initMethod
av_smpte_436m_anc_iter_init(iter, buf, buf_size::Integer)

Set up iteration over the ANC packets in a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.

Arguments

  • buf:[in] Pointer to the data from a AV_CODEC_ID_SMPTE_436M_ANC AVPacket.
  • buf_size:[in] Size of the data from a AV_CODEC_ID_SMPTE_436M_ANC AVPacket.
  • iter:[out] Pointer to the iterator.

Returns

0 on success, AVERROR codes otherwise.

source
VideoIO.libffmpeg.av_smpte_436m_coded_anc_payload_sizeMethod
av_smpte_436m_coded_anc_payload_size(sample_coding::AVSmpte436mPayloadSampleCoding, sample_count::UInt16)

Get the minimum number of bytes needed to store a AVSmpte436mCodedAnc payload.

Arguments

  • sample_coding: the payload sample coding
  • sample_count: the number of samples stored in the payload

Returns

returns the minimum number of bytes needed, on error returns < 0. always <= SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY

source
VideoIO.libffmpeg.av_spherical_allocMethod
av_spherical_alloc(size)

Allocate a AVSphericalVideo structure and initialize its fields to default values.

Returns

the newly allocated struct or NULL on failure

source
VideoIO.libffmpeg.av_spherical_tile_boundsMethod
av_spherical_tile_bounds(map, width::Csize_t, height::Csize_t, left, top, right, bottom)

Convert the bounding fields from an AVSphericalVideo from 0.32 fixed point to pixels.

Arguments

  • map: The AVSphericalVideo map to read bound values from.
  • width: Width of the current frame or stream.
  • height: Height of the current frame or stream.
  • left: Pixels from the left edge.
  • top: Pixels from the top edge.
  • right: Pixels from the right edge.
  • bottom: Pixels from the bottom edge.
source
VideoIO.libffmpeg.av_stereo3d_primary_eye_nameMethod
av_stereo3d_primary_eye_name(eye::Integer)

Provide a human-readable name of a given stereo3d primary eye.

Arguments

  • type: The input stereo3d primary eye value.

Returns

The name of the stereo3d primary eye value, or "unknown".

source
VideoIO.libffmpeg.av_stereo3d_type_nameMethod
av_stereo3d_type_name(type::Integer)

Provide a human-readable name of a given stereo3d type.

Arguments

  • type: The input stereo3d type value.

Returns

The name of the stereo3d value, or "unknown".

source
VideoIO.libffmpeg.av_stereo3d_view_nameMethod
av_stereo3d_view_name(view::Integer)

Provide a human-readable name of a given stereo3d view.

Arguments

  • type: The input stereo3d view value.

Returns

The name of the stereo3d view value, or "unknown".

source
VideoIO.libffmpeg.av_strdupMethod
av_strdup(s)

Duplicate a string.

Arguments

  • s: String to be duplicated

Returns

Pointer to a newly-allocated string containing a copy of s or NULL if the string cannot be allocated

See also

av_strndup()

source
VideoIO.libffmpeg.av_strerrorMethod
av_strerror(errnum::Integer, errbuf, errbuf_size::Csize_t)

Put a description of the AVERROR code errnum in errbuf. In case of failure the global variable errno is set to indicate the error. Even in case of failure av_strerror() will print a generic error message indicating the errnum provided to errbuf.

Arguments

  • errnum: error code to describe
  • errbuf: buffer to which description is written
  • errbuf_size: the size in bytes of errbuf

Returns

0 on success, a negative value if a description for errnum cannot be found

source
VideoIO.libffmpeg.av_stristartMethod
av_stristart(str, pfx, ptr)

Return non-zero if pfx is a prefix of str independent of case. If it is, *ptr is set to the address of the first character in str after the prefix.

Arguments

  • str: input string
  • pfx: prefix to test
  • ptr: updated if the prefix is matched inside str

Returns

non-zero if the prefix matches, zero otherwise

source
VideoIO.libffmpeg.av_stristrMethod
av_stristr(haystack, needle)

Locate the first case-independent occurrence in the string haystack of the string needle. A zero-length string needle is considered to match at the start of haystack.

This function is a case-insensitive version of the standard strstr().

Arguments

  • haystack: string to search in
  • needle: string to search for

Returns

pointer to the located match within haystack or a null pointer if no match

source
VideoIO.libffmpeg.av_strlcatMethod
av_strlcat(dst, src, size::Csize_t)

Append the string src to the string dst, but to a total length of no more than size - 1 bytes, and null-terminate dst.

This function is similar to BSD strlcat(), but differs when size <= strlen(dst).

Warning

since the return value use the length of src and dst, these absolutely _must_ be a properly 0-terminated strings, otherwise this will read beyond the end of the buffer and possibly crash.

Arguments

  • dst: destination buffer
  • src: source string
  • size: size of destination buffer

Returns

the total length of src and dst

source
VideoIO.libffmpeg.av_strlcpyMethod
av_strlcpy(dst, src, size::Csize_t)

Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.

This function is the same as BSD strlcpy().

Warning

since the return value is the length of src, src absolutely _must_ be a properly 0-terminated string, otherwise this will read beyond the end of the buffer and possibly crash.

Arguments

  • dst: destination buffer
  • src: source string
  • size: size of destination buffer

Returns

the length of src

source
VideoIO.libffmpeg.av_strndupMethod
av_strndup(s, len::Csize_t)

Duplicate a substring of a string.

Arguments

  • s: String to be duplicated
  • len: Maximum length of the resulting string (not counting the terminating byte)

Returns

Pointer to a newly-allocated string containing a substring of s or NULL if the string cannot be allocated

source
VideoIO.libffmpeg.av_strnlenMethod
av_strnlen(s, len::Csize_t)

Get the count of continuous non zero chars starting from the beginning.

Arguments

  • s: the string whose length to count
  • len: maximum number of characters to check in the string, that is the maximum value which is returned by the function
source
VideoIO.libffmpeg.av_strnstrMethod
av_strnstr(haystack, needle, hay_length::Csize_t)

Locate the first occurrence of the string needle in the string haystack where not more than hay_length characters are searched. A zero-length string needle is considered to match at the start of haystack.

This function is a length-limited version of the standard strstr().

Arguments

  • haystack: string to search in
  • needle: string to search for
  • hay_length: length of string to search in

Returns

pointer to the located match within haystack or a null pointer if no match

source
VideoIO.libffmpeg.av_strstartMethod
av_strstart(str, pfx, ptr)

Return non-zero if pfx is a prefix of str. If it is, *ptr is set to the address of the first character in str after the prefix.

Arguments

  • str: input string
  • pfx: prefix to test
  • ptr: updated if the prefix is matched inside str

Returns

non-zero if the prefix matches, zero otherwise

source
VideoIO.libffmpeg.av_strtodMethod
av_strtod(numstr, tail)

Parse the string in numstr and return its value as a double. If the string is empty, contains only whitespaces, or does not contain an initial substring that has the expected syntax for a floating-point number, no conversion is performed. In this case, returns a value of zero and the value returned in tail is the value of numstr.

Arguments

  • numstr: a string representing a number, may contain one of the International System number postfixes, for example 'K', 'M', 'G'. If 'i' is appended after the postfix, powers of 2 are used instead of powers of 10. The 'B' postfix multiplies the value by 8, and can be appended after another postfix or used alone. This allows using for example 'KB', 'MiB', 'G' and 'B' as postfix.
  • tail: if non-NULL puts here the pointer to the char next after the last parsed character
source
VideoIO.libffmpeg.av_strtokMethod
av_strtok(s, delim, saveptr)

Split the string into several tokens which can be accessed by successive calls to av_strtok().

A token is defined as a sequence of characters not belonging to the set specified in delim.

On the first call to av_strtok(), s should point to the string to parse, and the value of saveptr is ignored. In subsequent calls, s should be NULL, and saveptr should be unchanged since the previous call.

This function is similar to strtok_r() defined in POSIX.1.

Arguments

  • s: the string to parse, may be NULL
  • delim: 0-terminated list of token delimiters, must be non-NULL
  • saveptr: user-provided pointer which points to stored information necessary for av_strtok() to continue scanning the same string. saveptr is updated to point to the next character after the first delimiter found, or to NULL if the string was terminated

Returns

the found token, or NULL when no token is found

source
VideoIO.libffmpeg.av_sub_qMethod
av_sub_q(b::AVRational, c::AVRational)

Subtract one rational from another.

Arguments

  • b: First rational
  • c: Second rational

Returns

b-c

source
VideoIO.libffmpeg.av_tea_cryptMethod
av_tea_crypt(ctx, dst, src, count::Integer, iv, decrypt::Integer)

Encrypt or decrypt a buffer using a previously initialized context.

Arguments

  • ctx: an AVTEA context
  • dst: destination array, can be equal to src
  • src: source array, can be equal to dst
  • count: number of 8 byte blocks
  • iv: initialization vector for CBC mode, if NULL then ECB will be used
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_tea_initMethod
av_tea_init(ctx, key, rounds::Integer)

Initialize an AVTEA context.

Arguments

  • ctx: an AVTEA context
  • key: a key of 16 bytes used for encryption/decryption
  • rounds: the number of rounds in TEA (64 is the "standard")
source
VideoIO.libffmpeg.av_thread_message_flushMethod
av_thread_message_flush(mq)

Flush the message queue

This function is mostly equivalent to reading and free-ing every message except that it will be done in a single operation (no lock/unlock between reads).

source
VideoIO.libffmpeg.av_thread_message_queue_allocMethod
av_thread_message_queue_alloc(mq, nelem::Integer, elsize::Integer)

Allocate a new message queue.

Arguments

  • mq: pointer to the message queue
  • nelem: maximum number of elements in the queue
  • elsize: size of each element in the queue

Returns

=0 for success; <0 for error, in particular AVERROR(ENOSYS) if lavu was built without thread support

source
VideoIO.libffmpeg.av_timecode_adjust_ntsc_framenum2Method
av_timecode_adjust_ntsc_framenum2(framenum::Integer, fps::Integer)

Adjust frame number for NTSC drop frame time code.

Warning

adjustment is only valid for multiples of NTSC 29.97

Arguments

  • framenum: frame number to adjust
  • fps: frame per second, multiples of 30

Returns

adjusted frame number

source
VideoIO.libffmpeg.av_timecode_get_smpteMethod
av_timecode_get_smpte(rate::AVRational, drop::Integer, hh::Integer, mm::Integer, ss::Integer, ff::Integer)

Convert sei info to SMPTE 12M binary representation.

Arguments

  • rate: frame rate in rational form
  • drop: drop flag
  • hh: hour
  • mm: minute
  • ss: second
  • ff: frame number

Returns

the SMPTE binary representation

source
VideoIO.libffmpeg.av_timecode_get_smpte_from_framenumMethod
av_timecode_get_smpte_from_framenum(tc, framenum::Integer)

Convert frame number to SMPTE 12M binary representation.

See SMPTE ST 314M-2005 Sec 4.4.2.2.1 "Time code pack (TC)" the format description as follows: bits 0-5: hours, in BCD(6bits) bits 6: BGF1 bits 7: BGF2 (NTSC) or FIELD (PAL) bits 8-14: minutes, in BCD(7bits) bits 15: BGF0 (NTSC) or BGF2 (PAL) bits 16-22: seconds, in BCD(7bits) bits 23: FIELD (NTSC) or BGF0 (PAL) bits 24-29: frames, in BCD(6bits) bits 30: drop frame flag (0: non drop, 1: drop) bits 31: color frame flag (0: unsync mode, 1: sync mode)

Note

BCD numbers (6 or 7 bits): 4 or 5 lower bits for units, 2 higher bits for tens.

Note

Frame number adjustment is automatically done in case of drop timecode, you do NOT have to call av_timecode_adjust_ntsc_framenum2().

Note

The frame number is relative to tc->start.

Note

Color frame (CF) and binary group flags (BGF) bits are set to zero.

Arguments

  • tc: timecode data correctly initialized
  • framenum: frame number

Returns

the SMPTE binary representation

source
VideoIO.libffmpeg.av_timecode_initMethod
av_timecode_init(tc, rate::AVRational, flags::Integer, frame_start::Integer, log_ctx)

Init a timecode struct with the passed parameters.

Arguments

  • tc: pointer to an allocated AVTimecode
  • rate: frame rate in rational form
  • flags: miscellaneous flags such as drop frame, +24 hours, ... (see AVTimecodeFlag)
  • frame_start: the first frame number
  • log_ctx: a pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct (used for av_log)

Returns

0 on success, AVERROR otherwise

source
VideoIO.libffmpeg.av_timecode_init_from_componentsMethod
av_timecode_init_from_components(tc, rate::AVRational, flags::Integer, hh::Integer, mm::Integer, ss::Integer, ff::Integer, log_ctx)

Init a timecode struct from the passed timecode components.

Arguments

  • tc: pointer to an allocated AVTimecode
  • rate: frame rate in rational form
  • flags: miscellaneous flags such as drop frame, +24 hours, ... (see AVTimecodeFlag)
  • hh: hours
  • mm: minutes
  • ss: seconds
  • ff: frames
  • log_ctx: a pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct (used for av_log)

Returns

0 on success, AVERROR otherwise

source
VideoIO.libffmpeg.av_timecode_init_from_stringMethod
av_timecode_init_from_string(tc, rate::AVRational, str, log_ctx)

Parse timecode representation (hh:mm:ss[:;.]ff).

Arguments

  • tc: pointer to an allocated AVTimecode
  • rate: frame rate in rational form
  • str: timecode string which will determine the frame start
  • log_ctx: a pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct (used for av_log).

Returns

0 on success, AVERROR otherwise

source
VideoIO.libffmpeg.av_timecode_make_smpte_tc_stringMethod
av_timecode_make_smpte_tc_string(buf, tcsmpte::Integer, prevent_df::Integer)

Get the timecode string from the SMPTE timecode format.

Arguments

  • buf: destination buffer, must be at least AV_TIMECODE_STR_SIZE long
  • tcsmpte: the 32-bit SMPTE timecode
  • prevent_df: prevent the use of a drop flag when it is known the DF bit is arbitrary

Returns

the buf parameter

source
VideoIO.libffmpeg.av_timecode_make_smpte_tc_string2Method
av_timecode_make_smpte_tc_string2(buf, rate::AVRational, tcsmpte::Integer, prevent_df::Integer, skip_field::Integer)

Get the timecode string from the SMPTE timecode format.

In contrast to av_timecode_make_smpte_tc_string this function supports 50/60 fps timecodes by using the field bit.

Arguments

  • buf: destination buffer, must be at least AV_TIMECODE_STR_SIZE long
  • rate: frame rate of the timecode
  • tcsmpte: the 32-bit SMPTE timecode
  • prevent_df: prevent the use of a drop flag when it is known the DF bit is arbitrary
  • skip_field: prevent the use of a field flag when it is known the field bit is arbitrary (e.g. because it is used as PC flag)

Returns

the buf parameter

source
VideoIO.libffmpeg.av_timecode_make_stringMethod
av_timecode_make_string(tc, buf, framenum::Integer)

Load timecode string in buf.

Note

Timecode representation can be a negative timecode and have more than 24 hours, but will only be honored if the flags are correctly set.

Note

The frame number is relative to tc->start.

Arguments

  • tc: timecode data correctly initialized
  • buf: destination buffer, must be at least AV_TIMECODE_STR_SIZE long
  • framenum: frame number

Returns

the buf parameter

source
VideoIO.libffmpeg.av_tree_enumerateMethod
av_tree_enumerate(t, opaque, cmp, enu)

Apply enu(opaque, &elem) to all the elements in the tree in a given range.

Note

The cmp function should use the same ordering used to construct the tree.

Arguments

  • cmp: a comparison function that returns < 0 for an element below the range, > 0 for an element above the range and == 0 for an element inside the range
source
VideoIO.libffmpeg.av_tree_findMethod
av_tree_find(root, key, cmp, next)

Find an element.

Arguments

  • root: a pointer to the root node of the tree
  • next: If next is not NULL, then next[0] will contain the previous element and next[1] the next element. If either does not exist, then the corresponding entry in next is unchanged.
  • cmp: compare function used to compare elements in the tree, API identical to that of Standard C's qsort It is guaranteed that the first and only the first argument to cmp() will be the key parameter to av_tree_find(), thus it could if the user wants, be a different type (like an opaque context).

Returns

An element with cmp(key, elem) == 0 or NULL if no such element exists in the tree.

source
VideoIO.libffmpeg.av_tree_insertMethod
av_tree_insert(rootp, key, cmp, next)

Insert or remove an element.

If *next is NULL, then the supplied element will be removed if it exists. If *next is non-NULL, then the supplied element will be inserted, unless it already exists in the tree.

             void *tree_insert(struct AVTreeNode **rootp, void *key,
                               int (*cmp)(void *key, const void *b),
                               AVTreeNode **next)
             {
                 if (!*next)
                     *next = av_mallocz(av_tree_node_size);
                 return av_tree_insert(rootp, key, cmp, next);
             }
             void *tree_remove(struct AVTreeNode **rootp, void *key,
                               int (*cmp)(void *key, const void *b, AVTreeNode **next))
             {
                 av_freep(next);
                 return av_tree_insert(rootp, key, cmp, next);
             }

Arguments

  • rootp: A pointer to a pointer to the root node of the tree; note that the root node can change during insertions, this is required to keep the tree balanced.
  • key: pointer to the element key to insert in the tree
  • next: Used to allocate and free AVTreeNodes. For insertion the user must set it to an allocated and zeroed object of at least av_tree_node_size bytes size. av_tree_insert() will set it to NULL if it has been consumed. For deleting elements *next is set to NULL by the user and av_tree_insert() will set it to the AVTreeNode which was used for the removed element. This allows the use of flat arrays, which have lower overhead compared to many malloced elements. You might want to define a function like:
  • cmp: compare function used to compare elements in the tree, API identical to that of Standard C's qsort

Returns

If no insertion happened, the found element; if an insertion or removal happened, then either key or NULL will be returned. Which one it is depends on the tree state and the implementation. You should make no assumptions that it's one or the other in the code.

source
VideoIO.libffmpeg.av_ts_make_time_string2Method
av_ts_make_time_string2(buf, ts::Int64, tb::AVRational)

Fill the provided buffer with a string containing a timestamp time representation.

Arguments

  • buf: a buffer with size in bytes of at least AV_TS_MAX_STRING_SIZE
  • ts: the timestamp to represent
  • tb: the timebase of the timestamp

Returns

the buffer in input

source
VideoIO.libffmpeg.av_twofish_cryptMethod
av_twofish_crypt(ctx, dst, src, count::Integer, iv, decrypt::Integer)

Encrypt or decrypt a buffer using a previously initialized context

Arguments

  • ctx: an AVTWOFISH context
  • dst: destination array, can be equal to src
  • src: source array, can be equal to dst
  • count: number of 16 byte blocks
  • iv: initialization vector for CBC mode, NULL for ECB mode
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_twofish_initMethod
av_twofish_init(ctx, key, key_bits::Integer)

Initialize an AVTWOFISH context.

Arguments

  • ctx: an AVTWOFISH context
  • key: a key of size ranging from 1 to 32 bytes used for encryption/decryption
  • key_bits: number of keybits: 128, 192, 256 If less than the required, padded with zeroes to nearest valid value; return value is 0 if key_bits is 128/192/256, -1 if less than 0, 1 otherwise
source
VideoIO.libffmpeg.av_tx_initMethod
av_tx_init(ctx, tx, type::AVTXType, inv::Integer, len::Integer, scale, flags::UInt64)

Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently not supported.

Arguments

  • ctx: the context to allocate, will be NULL on error
  • tx: pointer to the transform function pointer to set
  • type: type the type of transform
  • inv: whether to do an inverse or a forward transform
  • len: the size of the transform in samples
  • scale: pointer to the value to scale the output if supported by type
  • flags: a bitmask of AVTXFlags or 0

Returns

0 on success, negative error code on failure

source
VideoIO.libffmpeg.av_url_splitMethod
av_url_split(proto, proto_size::Integer, authorization, authorization_size::Integer, hostname, hostname_size::Integer, port_ptr, path, path_size::Integer, url)

Split a URL string into components.

The pointers to buffers for storing individual components may be null, in order to ignore that component. Buffers for components not found are set to empty strings. If the port is not found, it is set to a negative value.

Arguments

  • proto: the buffer for the protocol
  • proto_size: the size of the proto buffer
  • authorization: the buffer for the authorization
  • authorization_size: the size of the authorization buffer
  • hostname: the buffer for the host name
  • hostname_size: the size of the hostname buffer
  • port_ptr: a pointer to store the port number in
  • path: the buffer for the path
  • path_size: the size of the path buffer
  • url: the URL to split
source
VideoIO.libffmpeg.av_usleepMethod
av_usleep(usec::Integer)

Sleep for a period of time. Although the duration is expressed in microseconds, the actual delay may be rounded to the precision of the system timer.

Arguments

  • usec: Number of microseconds to sleep.

Returns

zero on success or (negative) error code.

source
VideoIO.libffmpeg.av_utf8_decodeMethod
av_utf8_decode(codep, bufp, buf_end, flags::Integer)

Read and decode a single UTF-8 code point (character) from the buffer in *buf, and update *buf to point to the next byte to decode.

In case of an invalid byte sequence, the pointer will be updated to the next byte after the invalid sequence and the function will return an error code.

Depending on the specified flags, the function will also fail in case the decoded code point does not belong to a valid range.

Note

For speed-relevant code a carefully implemented use of GET_UTF8() may be preferred.

Arguments

  • codep: pointer used to return the parsed code in case of success. The value in *codep is set even in case the range check fails.
  • bufp: pointer to the address the first byte of the sequence to decode, updated by the function to point to the byte next after the decoded sequence
  • buf_end: pointer to the end of the buffer, points to the next byte past the last in the buffer. This is used to avoid buffer overreads (in case of an unfinished UTF-8 sequence towards the end of the buffer).
  • flags: a collection of AV_UTF8_FLAG_* flags

Returns

= 0 in case a sequence was successfully read, a negative value in case of invalid sequence

source
VideoIO.libffmpeg.av_uuid_nilMethod
av_uuid_nil(uu)

Sets a UUID to the nil UUID, i.e. a UUID with have all its 128 bits set to zero.

Arguments

  • uu:[in,out] UUID to be set to the nil UUID
source
VideoIO.libffmpeg.av_uuid_parseMethod
av_uuid_parse(in, uu)

Parses a string representation of a UUID formatted according to IETF RFC 4122 into an AVUUID. The parsing is case-insensitive. The string must be 37 characters long, including the terminating NUL character.

Example string representation: "2fceebd0-7017-433d-bafb-d073a7116696"

Arguments

  • in:[in] String representation of a UUID, e.g. 2fceebd0-7017-433d-bafb-d073a7116696
  • uu:[out] AVUUID

Returns

A non-zero value in case of an error.

source
VideoIO.libffmpeg.av_uuid_parse_rangeMethod
av_uuid_parse_range(in_start, in_end, uu)

Parses a string representation of a UUID formatted according to IETF RFC 4122 into an AVUUID. The parsing is case-insensitive.

Arguments

  • in_start:[in] Pointer to the first character of the string representation
  • in_end:[in] Pointer to the character after the last character of the string representation. That memory location is never accessed. It is an error if in\_end - in\_start != 36.
  • uu:[out] AVUUID

Returns

A non-zero value in case of an error.

source
VideoIO.libffmpeg.av_uuid_unparseMethod
av_uuid_unparse(uu, out)

Serializes a AVUUID into a string representation according to IETF RFC 4122. The string is lowercase and always 37 characters long, including the terminating NUL character.

Arguments

  • uu:[in] AVUUID
  • out:[out] Pointer to an array of no less than 37 characters.
source
VideoIO.libffmpeg.av_uuid_urn_parseMethod
av_uuid_urn_parse(in, uu)

Parses a URN representation of a UUID, as specified at IETF RFC 4122, into an AVUUID. The parsing is case-insensitive. The string must be 46 characters long, including the terminating NUL character.

Example string representation: "urn:uuid:2fceebd0-7017-433d-bafb-d073a7116696"

Arguments

  • in:[in] URN UUID
  • uu:[out] AVUUID

Returns

A non-zero value in case of an error.

source
VideoIO.libffmpeg.av_vdpau_bind_contextMethod
av_vdpau_bind_context(avctx, device::VdpDevice, get_proc_address, flags::Integer)

Associate a VDPAU device with a codec context for hardware acceleration. This function is meant to be called from the get_format() codec callback, or earlier. It can also be called after avcodec_flush_buffers() to change the underlying VDPAU device mid-stream (e.g. to recover from non-transparent display preemption).

Note

get_format() must return AV_PIX_FMT_VDPAU if this function completes successfully.

Arguments

  • avctx: decoding context whose get_format() callback is invoked
  • device: VDPAU device handle to use for hardware acceleration
  • get_proc_address: VDPAU device driver
  • flags: zero of more OR'd AV_HWACCEL_FLAG_* flags

Returns

0 on success, an AVERROR code on failure.

source
VideoIO.libffmpeg.av_vdpau_get_surface_parametersMethod
av_vdpau_get_surface_parameters(avctx, type, width, height)

Gets the parameters to create an adequate VDPAU video surface for the codec context using VDPAU hardware decoding acceleration.

Note

Behavior is undefined if the context was not successfully bound to a VDPAU device using av_vdpau_bind_context().

Arguments

  • avctx: the codec context being used for decoding the stream
  • type: storage space for the VDPAU video surface chroma type (or NULL to ignore)
  • width: storage space for the VDPAU video surface pixel width (or NULL to ignore)
  • height: storage space for the VDPAU video surface pixel height (or NULL to ignore)

Returns

0 on success, a negative AVERROR code on failure.

source
VideoIO.libffmpeg.av_version_infoMethod
av_version_info()

Return an informative version string. This usually is the actual release version number or a git commit description. This string has no fixed format and can change any time. It should never be parsed by code.

source
VideoIO.libffmpeg.av_video_enc_params_allocMethod
av_video_enc_params_alloc(type::AVVideoEncParamsType, nb_blocks::Integer, out_size)

Allocates memory for AVVideoEncParams of the given type, plus an array of {

 nb_blocks} AVVideoBlockParams and initializes the variables. Can be
 freed with a normal av_free() call.

 @param out_size if non-NULL, the size in bytes of the resulting data array is
 written here.
 
source
VideoIO.libffmpeg.av_video_enc_params_create_side_dataMethod
av_video_enc_params_create_side_data(frame, type::AVVideoEncParamsType, nb_blocks::Integer)

Allocates memory for AVEncodeInfoFrame plus an array of {

 nb_blocks} AVEncodeInfoBlock in the given AVFrame {@code frame}
 as AVFrameSideData of type AV_FRAME_DATA_VIDEO_ENC_PARAMS
 and initializes the variables.
 
source
VideoIO.libffmpeg.av_video_hint_allocMethod
av_video_hint_alloc(nb_rects::Csize_t, out_size)

Allocate memory for the AVVideoHint struct along with an nb_rects-sized arrays of AVVideoRect.

The side data contains a list of rectangles for the portions of the frame which changed from the last encoded one (and the remainder are assumed to be changed), or, alternately (depending on the type parameter) the unchanged ones (and the remaining ones are those which changed). Macroblocks will thus be hinted either to be P_SKIP-ped or go through the regular encoding procedure.

It's responsibility of the caller to fill the AVRects accordingly, and to set the proper AVVideoHintType field.

Arguments

  • out_size: if non-NULL, the size in bytes of the resulting data array is written here

Returns

newly allocated AVVideoHint struct (must be freed by the caller using av_free()) on success, NULL on memory allocation failure

source
VideoIO.libffmpeg.av_vorbis_parse_frameMethod
av_vorbis_parse_frame(s, buf, buf_size::Integer)

Get the duration for a Vorbis packet.

Arguments

  • s: Vorbis parser context
  • buf: buffer containing a Vorbis frame
  • buf_size: size of the buffer
source
VideoIO.libffmpeg.av_vorbis_parse_frame_flagsMethod
av_vorbis_parse_frame_flags(s, buf, buf_size::Integer, flags)

Get the duration for a Vorbis packet.

If flags is NULL, special frames are considered invalid.

Arguments

  • s: Vorbis parser context
  • buf: buffer containing a Vorbis frame
  • buf_size: size of the buffer
  • flags: flags for special frames
source
VideoIO.libffmpeg.av_write_frameMethod
av_write_frame(s, pkt)

Write a packet to an output media file.

This function passes the packet directly to the muxer, without any buffering or reordering. The caller is responsible for correctly interleaving the packets if the format requires it. Callers that want libavformat to handle the interleaving should call av_interleaved_write_frame() instead of this function.

Arguments

  • s: media file handle
  • pkt: The packet containing the data to be written. Note that unlike av_interleaved_write_frame(), this function does not take ownership of the packet passed to it (though some muxers may make an internal reference to the input packet). <br> This parameter can be NULL (at any time, not just at the end), in order to immediately flush data buffered within the muxer, for muxers that buffer up data internally before writing it to the output. <br> Packet's AVPacket.streamindex "stream\index" field must be set to the index of the corresponding stream in AVFormatContext.streams "s->streams". <br> The timestamps (AVPacket.pts "pts", AVPacket.dts "dts") must be set to correct values in the stream's timebase (unless the output format is flagged with the AVFMT_NOTIMESTAMPS flag, then they can be set to AV_NOPTS_VALUE). The dts for subsequent packets passed to this function must be strictly increasing when compared in their respective timebases (unless the output format is flagged with the AVFMT_TS_NONSTRICT, then they merely have to be nondecreasing). AVPacket.duration "duration") should also be set if known.

Returns

< 0 on error, = 0 if OK, 1 if flushed and there is no more data to flush

See also

av_interleaved_write_frame()

source
VideoIO.libffmpeg.av_write_image_line2Method
av_write_image_line2(src, data, linesize, desc, x::Integer, y::Integer, c::Integer, w::Integer, src_element_size::Integer)

Write the values from src to the pixel format component c of an image line.

Arguments

  • src: array containing the values to write
  • data: the array containing the pointers to the planes of the image to write into. It is supposed to be zeroed.
  • linesize: the array containing the linesizes of the image
  • desc: the pixel format descriptor for the image
  • x: the horizontal coordinate of the first pixel to write
  • y: the vertical coordinate of the first pixel to write
  • w: the width of the line to write, that is the number of values to write to the image line
  • src_element_size: size of elements in src array (2 or 4 byte)
source
VideoIO.libffmpeg.av_xiphlacingMethod
av_xiphlacing(s, v::Integer)

Encode extradata length to a buffer. Used by xiph codecs.

Arguments

  • s: buffer to write to; must be at least (v/255+1) bytes long
  • v: size of extradata in bytes

Returns

number of bytes written to the buffer.

source
VideoIO.libffmpeg.av_xtea_cryptMethod
av_xtea_crypt(ctx, dst, src, count::Integer, iv, decrypt::Integer)

Encrypt or decrypt a buffer using a previously initialized context, in big endian format.

Arguments

  • ctx: an AVXTEA context
  • dst: destination array, can be equal to src
  • src: source array, can be equal to dst
  • count: number of 8 byte blocks
  • iv: initialization vector for CBC mode, if NULL then ECB will be used
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_xtea_le_cryptMethod
av_xtea_le_crypt(ctx, dst, src, count::Integer, iv, decrypt::Integer)

Encrypt or decrypt a buffer using a previously initialized context, in little endian format.

Arguments

  • ctx: an AVXTEA context
  • dst: destination array, can be equal to src
  • src: source array, can be equal to dst
  • count: number of 8 byte blocks
  • iv: initialization vector for CBC mode, if NULL then ECB will be used
  • decrypt: 0 for encryption, 1 for decryption
source
VideoIO.libffmpeg.av_zero_extend_cMethod
av_zero_extend_c(a::Integer, p::Integer)

Clear high bits from an unsigned integer starting with specific bit position

Arguments

  • a: value to clip
  • p: bit position to clip at. Must be between 0 and 31.

Returns

clipped value

source
VideoIO.libffmpeg.avcodec_align_dimensions2Method
avcodec_align_dimensions2(s, width, height, linesize_align)

Modify width and height values so that they will result in a memory buffer that is acceptable for the codec if you also ensure that all line sizes are a multiple of the respective linesize_align[i].

May only be used if a codec with AV_CODEC_CAP_DR1 has been opened.

source
VideoIO.libffmpeg.avcodec_alloc_context3Method
avcodec_alloc_context3(codec)

Allocate an AVCodecContext and set its fields to default values. The resulting struct should be freed with avcodec_free_context().

Arguments

  • codec: if non-NULL, allocate private data and initialize defaults for the given codec. It is illegal to then call avcodec_open2() with a different codec. If NULL, then the codec-specific defaults won't be initialized, which may result in suboptimal default settings (this is important mainly for encoders, e.g. libx264).

Returns

An AVCodecContext filled with default values or NULL on failure.

source
VideoIO.libffmpeg.avcodec_decode_subtitle2Method
avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, avpkt)

Decode a subtitle message. Return a negative value on error, otherwise return the number of bytes used. If no subtitle could be decompressed, got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. Note that AV_CODEC_CAP_DR1 is not available for subtitle codecs. This is for simplicity, because the performance difference is expected to be negligible and reusing a get_buffer written for video codecs would probably perform badly due to a potentially very different allocation pattern.

Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input and output. This means that for some packets they will not immediately produce decoded output and need to be flushed at the end of decoding to get all the decoded data. Flushing is done by calling this function with packets with avpkt->data set to NULL and avpkt->size set to 0 until it stops returning subtitles. It is safe to flush even those decoders that are not marked with AV_CODEC_CAP_DELAY, then no subtitles will be returned.

Note

The AVCodecContext MUST have been opened with avcodec_open2() before packets may be fed to the decoder.

Arguments

  • avctx: the codec context
  • sub:[out] The preallocated AVSubtitle in which the decoded subtitle will be stored, must be freed with avsubtitle_free if *got_sub_ptr is set.
  • got_sub_ptr:[in,out] Zero if no subtitle could be decompressed, otherwise, it is nonzero.
  • avpkt:[in] The input AVPacket containing the input buffer.
source
VideoIO.libffmpeg.avcodec_descriptor_nextMethod
avcodec_descriptor_next(prev)

Iterate over all codec descriptors known to libavcodec.

Arguments

  • prev: previous descriptor. NULL to get the first descriptor.

Returns

next descriptor or NULL after the last descriptor

source
VideoIO.libffmpeg.avcodec_fill_audio_frameMethod
avcodec_fill_audio_frame(frame, nb_channels::Integer, sample_fmt::AVSampleFormat, buf, buf_size::Integer, align::Integer)

Fill AVFrame audio data and linesize pointers.

The buffer buf must be a preallocated buffer with a size big enough to contain the specified samples amount. The filled AVFrame data pointers will point to this buffer.

AVFrame extended_data channel pointers are allocated if necessary for planar audio.

\todo return the size in bytes required to store the samples in case of success, at the next libavutil bump

Arguments

  • frame: the AVFrame frame->nb_samples must be set prior to calling the function. This function fills in frame->data, frame->extended_data, frame->linesize[0].
  • nb_channels: channel count
  • sample_fmt: sample format
  • buf: buffer to use for frame data
  • buf_size: size of buffer
  • align: plane size sample alignment (0 = default)

Returns

=0 on success, negative error code on failure

source
VideoIO.libffmpeg.avcodec_find_best_pix_fmt_of_listMethod
avcodec_find_best_pix_fmt_of_list(pix_fmt_list, src_pix_fmt::AVPixelFormat, has_alpha::Integer, loss_ptr)

Find the best pixel format to convert to given a certain source pixel format. When converting from one pixel format to another, information loss may occur. For example, when converting from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when converting from some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of the given pixel formats should be used to suffer the least amount of loss. The pixel formats from which it chooses one, are determined by the pix_fmt_list parameter.

Arguments

  • pix_fmt_list:[in] AV_PIX_FMT_NONE terminated array of pixel formats to choose from
  • src_pix_fmt:[in] source pixel format
  • has_alpha:[in] Whether the source pixel format alpha channel is used.
  • loss_ptr:[out] Combination of flags informing you what kind of losses will occur.

Returns

The best pixel format to convert to or -1 if none was found.

source
VideoIO.libffmpeg.avcodec_flush_buffersMethod
avcodec_flush_buffers(avctx)

Reset the internal codec state / flush internal buffers. Should be called e.g. when seeking or when switching to a different stream.

Note

for decoders, this function just releases any references the decoder might keep internally, but the caller's references remain valid.

Note

for encoders, this function will only do something if the encoder declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder will drain any remaining packets, and can then be reused for a different stream (as opposed to sending a null frame which will leave the encoder in a permanent EOF state after draining). This can be desirable if the cost of tearing down and replacing the encoder instance is high.

source
VideoIO.libffmpeg.avcodec_get_hw_configMethod
avcodec_get_hw_config(codec, index::Integer)

Retrieve supported hardware configurations for a codec.

Values of index from zero to some maximum return the indexed configuration descriptor; all other values return NULL. If the codec does not support any hardware configurations then it will always return NULL.

source
VideoIO.libffmpeg.avcodec_get_hw_frames_parametersMethod
avcodec_get_hw_frames_parameters(avctx, device_ref, hw_pix_fmt::AVPixelFormat, out_frames_ref)

Create and return a AVHWFramesContext with values adequate for hardware decoding. This is meant to get called from the get_format callback, and is a helper for preparing a AVHWFramesContext for AVCodecContext.hw_frames_ctx. This API is for decoding with certain hardware acceleration modes/APIs only.

The returned AVHWFramesContext is not initialized. The caller must do this with av_hwframe_ctx_init().

Calling this function is not a requirement, but makes it simpler to avoid codec or hardware API specific details when manually allocating frames.

Alternatively to this, an API user can set AVCodecContext.hw_device_ctx, which sets up AVCodecContext.hw_frames_ctx fully automatically, and makes it unnecessary to call this function or having to care about AVHWFramesContext initialization at all.

There are a number of requirements for calling this function:

  • It must be called from get_format with the same avctx parameter that was passed to get_format. Calling it outside of get_format is not allowed, and can trigger undefined behavior. - The function is not always supported (see description of return values). Even if this function returns successfully, hwaccel initialization could fail later. (The degree to which implementations check whether the stream is actually supported varies. Some do this check only after the user's get_format callback returns.) - The hw_pix_fmt must be one of the choices suggested by get_format. If the user decides to use a AVHWFramesContext prepared with this API function, the user must return the same hw_pix_fmt from get_format. - The device_ref passed to this function must support the given hw_pix_fmt. - After calling this API function, it is the user's responsibility to initialize the AVHWFramesContext (returned by the out_frames_ref parameter), and to set AVCodecContext.hw_frames_ctx to it. If done, this must be done before returning from get_format (this is implied by the normal AVCodecContext.hw_frames_ctx API rules). - The AVHWFramesContext parameters may change every time time get_format is called. Also, AVCodecContext.hw_frames_ctx is reset before get_format. So you are inherently required to go through this process again on every get_format call. - It is perfectly possible to call this function without actually using the resulting AVHWFramesContext. One use-case might be trying to reuse a previously initialized AVHWFramesContext, and calling this API function only to test whether the required frame parameters have changed. - Fields that use dynamically allocated values of any kind must not be set by the user unless setting them is explicitly allowed by the documentation. If the user sets AVHWFramesContext.free and AVHWFramesContext.user_opaque, the new free callback must call the potentially set previous free callback. This API call may set any dynamically allocated fields, including the free callback.

The function will set at least the following fields on AVHWFramesContext (potentially more, depending on hwaccel API):

  • All fields set by av_hwframe_ctx_alloc(). - Set the format field to hw_pix_fmt. - Set the sw_format field to the most suited and most versatile format. (An implication is that this will prefer generic formats over opaque formats with arbitrary restrictions, if possible.) - Set the width/height fields to the coded frame size, rounded up to the API-specific minimum alignment. - Only _if_ the hwaccel requires a pre-allocated pool: set the initial_pool_size field to the number of maximum reference surfaces possible with the codec, plus 1 surface for the user to work (meaning the user can safely reference at most 1 decoded surface at a time), plus additional buffering introduced by frame threading. If the hwaccel does not require pre-allocation, the field is left to 0, and the decoder will allocate new surfaces on demand during decoding. - Possibly AVHWFramesContext.hwctx fields, depending on the underlying hardware API.

Essentially, out_frames_ref returns the same as av_hwframe_ctx_alloc(), but with basic frame parameters set.

The function is stateless, and does not change the AVCodecContext or the device_ref AVHWDeviceContext.

Arguments

  • avctx: The context which is currently calling get_format, and which implicitly contains all state needed for filling the returned AVHWFramesContext properly.
  • device_ref: A reference to the AVHWDeviceContext describing the device which will be used by the hardware decoder.
  • hw_pix_fmt: The hwaccel format you are going to return from get_format.
  • out_frames_ref: On success, set to a reference to an _uninitialized_ AVHWFramesContext, created from the given device_ref. Fields will be set to values required for decoding. Not changed if an error is returned.

Returns

zero on success, a negative value on error. The following error codes have special semantics: AVERROR(ENOENT): the decoder does not support this functionality. Setup is always manual, or it is a decoder which does not support setting AVCodecContext.hw_frames_ctx at all, or it is a software format. AVERROR(EINVAL): it is known that hardware decoding is not supported for this configuration, or the device_ref is not supported for the hwaccel referenced by hw_pix_fmt.

source
VideoIO.libffmpeg.avcodec_get_supported_configMethod
avcodec_get_supported_config(avctx, codec, config::AVCodecConfig, flags::Integer, out_configs, out_num_configs)

Retrieve a list of all supported values for a given configuration type.

Arguments

  • avctx: An optional context to use. Values such as strict_std_compliance may affect the result. If NULL, default values are used.
  • codec: The codec to query, or NULL to use avctx->codec.
  • config: The configuration to query.
  • flags: Currently unused; should be set to zero.
  • out_configs: On success, set to a list of configurations, terminated by a config-specific terminator, or NULL if all possible values are supported.
  • out_num_configs: On success, set to the number of elements inout_configs, excluding the terminator. Optional.
source
VideoIO.libffmpeg.avcodec_open2Method
avcodec_open2(avctx, codec, options)

Initialize the AVCodecContext to use the given AVCodec. Prior to using this function the context has to be allocated with avcodec_alloc_context3().

The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for retrieving a codec.

Depending on the codec, you might need to set options in the codec context also for decoding (e.g. width, height, or the pixel or audio sample format in the case the information is not available in the bitstream, as when decoding raw audio or video).

Options in the codec context can be set either by setting them in the options AVDictionary, or by setting the values in the context itself, directly or by using the av_opt_set() API before calling this function.

Example:

 av_dict_set(&opts, "b", "2.5M", 0);
 codec = avcodec_find_decoder(AV_CODEC_ID_H264);
 if (!codec)
     exit(1);

 context = avcodec_alloc_context3(codec);

 if (avcodec_open2(context, codec, opts) < 0)
     exit(1);

In the case AVCodecParameters are available (e.g. when demuxing a stream using libavformat, and accessing the AVStream contained in the demuxer), the codec parameters can be copied to the codec context using avcodec_parameters_to_context(), as in the following example:

 AVStream *stream = ...;
 context = avcodec_alloc_context3(codec);
 if (avcodec_parameters_to_context(context, stream->codecpar) < 0)
     exit(1);
 if (avcodec_open2(context, codec, NULL) < 0)
     exit(1);
Note

Always call this function before using decoding routines (such as avcodecreceiveframe()).

Arguments

  • avctx: The context to initialize.
  • codec: The codec to open this context for. If a non-NULL codec has been previously passed to avcodec_alloc_context3() or for this context, then this parameter MUST be either NULL or equal to the previously passed codec.
  • options: A dictionary filled with AVCodecContext and codec-private options, which are set on top of the options already set in avctx, can be NULL. On return this object will be filled with options that were not found in the avctx codec context.

Returns

zero on success, a negative value on error

See also

avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(), av_dict_set(), av_opt_set(), av_opt_find(), avcodec_parameters_to_context()

source
VideoIO.libffmpeg.avcodec_parameters_copyMethod
avcodec_parameters_copy(dst, src)

Copy the contents of src to dst. Any allocated fields in dst are freed and replaced with newly allocated duplicates of the corresponding fields in src.

Returns

= 0 on success, a negative AVERROR code on failure.

source
VideoIO.libffmpeg.avcodec_parameters_from_contextMethod
avcodec_parameters_from_context(par, codec)

Fill the parameters struct based on the values from the supplied codec context. Any allocated fields in par are freed and replaced with duplicates of the corresponding fields in codec.

Returns

= 0 on success, a negative AVERROR code on failure

source
VideoIO.libffmpeg.avcodec_parameters_to_contextMethod
avcodec_parameters_to_context(codec, par)

Fill the codec context based on the values from the supplied codec parameters. Any allocated fields in codec that have a corresponding field in par are freed and replaced with duplicates of the corresponding field in par. Fields in codec that do not have a counterpart in par are not touched.

Returns

= 0 on success, a negative AVERROR code on failure.

source
VideoIO.libffmpeg.avcodec_profile_nameMethod
avcodec_profile_name(codec_id::AVCodecID, profile::Integer)

Return a name for the specified profile, if available.

Note

unlike av_get_profile_name(), which searches a list of profiles supported by a specific decoder or encoder implementation, this function searches the list of profiles from the AVCodecDescriptor

Arguments

  • codec_id: the ID of the codec to which the requested profile belongs
  • profile: the profile value for which a name is requested

Returns

A name for the profile if found, NULL otherwise.

source
VideoIO.libffmpeg.avcodec_receive_frameMethod
avcodec_receive_frame(avctx, frame)

Return decoded output data from a decoder or encoder (when the AVCODECFLAGRECONFRAME flag is used).

\retval0 success, a frame was returned

\retvalAVERROR(EAGAIN) output is not available in this state - user must try to send new input

\retvalAVERROR_EOF the codec has been fully flushed, and there will be no more output frames

\retvalAVERROR(EINVAL) codec not opened, or it is an encoder without the AVCODECFLAGRECONFRAME flag enabled

\retval"other negative error code" legitimate decoding errors

Arguments

  • avctx: codec context
  • frame: This will be set to a reference-counted video or audio frame (depending on the decoder type) allocated by the codec. Note that the function will always call av_frame_unref(frame) before doing anything else.
source
VideoIO.libffmpeg.avcodec_receive_packetMethod
avcodec_receive_packet(avctx, avpkt)

Read encoded data from the encoder.

\retval0 success

\retvalAVERROR(EAGAIN) output is not available in the current state - user must try to send input

\retvalAVERROR_EOF the encoder has been fully flushed, and there will be no more output packets

\retvalAVERROR(EINVAL) codec not opened, or it is a decoder

\retval"another negative error code" legitimate encoding errors

Arguments

  • avctx: codec context
  • avpkt: This will be set to a reference-counted packet allocated by the encoder. Note that the function will always call av_packet_unref(avpkt) before doing anything else.
source
VideoIO.libffmpeg.avcodec_send_frameMethod
avcodec_send_frame(avctx, frame)

Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet() to retrieve buffered output packets.

For audio: If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame can have any number of samples. If it is not set, frame->nb_samples must be equal to avctx->frame_size for all frames except the last. The final frame may be smaller than avctx->frame_size.

\retval0 success

\retvalAVERROR(EAGAIN) input is not accepted in the current state - user must read output with avcodec_receive_packet() (once all output is read, the packet should be resent, and the call will not fail with EAGAIN).

\retvalAVERROR_EOF the encoder has been flushed, and no new frames can be sent to it

\retvalAVERROR(EINVAL) codec not opened, it is a decoder, or requires flush

\retvalAVERROR(ENOMEM) failed to add packet to internal queue, or similar

\retval"another negative error code" legitimate encoding errors

Arguments

  • avctx: codec context
  • frame:[in] AVFrame containing the raw audio or video frame to be encoded. Ownership of the frame remains with the caller, and the encoder will not write to the frame. The encoder may create a reference to the frame data (or copy it if the frame is not reference-counted). It can be NULL, in which case it is considered a flush packet. This signals the end of the stream. If the encoder still has packets buffered, it will return them after this call. Once flushing mode has been entered, additional flush packets are ignored, and sending frames will return AVERROR_EOF.
source
VideoIO.libffmpeg.avcodec_send_packetMethod
avcodec_send_packet(avctx, avpkt)

Supply raw packet data as input to a decoder.

Internally, this call will copy relevant AVCodecContext fields, which can influence decoding per-packet, and apply them when the packet is actually decoded. (For example AVCodecContext.skip_frame, which might direct the decoder to drop the frame contained by the packet sent with this function.)

Warning

The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE larger than the actual read bytes because some optimized bitstream readers read 32 or 64 bits at once and could read over the end.

Note

The AVCodecContext MUST have been opened with avcodec_open2() before packets may be fed to the decoder.

\retval0 success

\retvalAVERROR(EAGAIN) input is not accepted in the current state - user must read output with avcodec_receive_frame() (once all output is read, the packet should be resent, and the call will not fail with EAGAIN).

\retvalAVERROR_EOF the decoder has been flushed, and no new packets can be sent to it (also returned if more than 1 flush packet is sent)

\retvalAVERROR(EINVAL) codec not opened, it is an encoder, or requires flush

\retvalAVERROR(ENOMEM) failed to add packet to internal queue, or similar

\retval"another negative error code" legitimate decoding errors

Arguments

  • avctx: codec context
  • avpkt:[in] The input AVPacket. Usually, this will be a single video frame, or several complete audio frames. Ownership of the packet remains with the caller, and the decoder will not write to the packet. The decoder may create a reference to the packet data (or copy it if the packet is not reference-counted). Unlike with older APIs, the packet is always fully consumed, and if it contains multiple frames (e.g. some audio codecs), will require you to call avcodec_receive_frame() multiple times afterwards before you can send a new packet. It can be NULL (or an AVPacket with data set to NULL and size set to 0); in this case, it is considered a flush packet, which signals the end of the stream. Sending the first flush packet will return success. Subsequent ones are unnecessary and will return AVERROR_EOF. If the decoder still has frames buffered, it will return them after sending a flush packet.
source
VideoIO.libffmpeg.avdevice_app_to_dev_control_messageMethod
avdevice_app_to_dev_control_message(s, type::AVAppToDevMessageType, data, data_size::Csize_t)

Send control message from application to device.

Arguments

  • s: device context.
  • type: message type.
  • data: message data. Exact type depends on message type.
  • data_size: size of message data.

Returns

= 0 on success, negative on error. AVERROR(ENOSYS) when device doesn't implement handler of the message.

source
VideoIO.libffmpeg.avdevice_dev_to_app_control_messageMethod
avdevice_dev_to_app_control_message(s, type::AVDevToAppMessageType, data, data_size::Csize_t)

Send control message from device to application.

Arguments

  • s: device context.
  • type: message type.
  • data: message data. Can be NULL.
  • data_size: size of message data.

Returns

= 0 on success, negative on error. AVERROR(ENOSYS) when application doesn't implement handler of the message.

source
VideoIO.libffmpeg.avdevice_list_devicesMethod
avdevice_list_devices(s, device_list)

List devices.

Returns available device names and their parameters.

Note

: Some devices may accept system-dependent device names that cannot be autodetected. The list returned by this function cannot be assumed to be always completed.

Arguments

  • s: device context.
  • device_list:[out] list of autodetected devices.

Returns

count of autodetected devices, negative on error.

source
VideoIO.libffmpeg.avdevice_list_input_sourcesMethod
avdevice_list_input_sources(device, device_name, device_options, device_list)

List devices.

Returns available device names and their parameters. These are convenient wrappers for avdevice_list_devices(). Device context is allocated and deallocated internally.

Note

device argument takes precedence over device_name when both are set.

Arguments

  • device: device format. May be NULL if device name is set.
  • device_name: device name. May be NULL if device format is set.
  • device_options: An AVDictionary filled with device-private options. May be NULL. The same options must be passed later to avformat_write_header() for output devices or avformat_open_input() for input devices, or at any other place that affects device-private options.
  • device_list:[out] list of autodetected devices

Returns

count of autodetected devices, negative on error.

source
VideoIO.libffmpeg.avfilter_freeMethod
avfilter_free(filter)

Free a filter context. This will also remove the filter from its filtergraph's list of filters.

Arguments

  • filter: the filter to free
source
VideoIO.libffmpeg.avfilter_get_by_nameMethod
avfilter_get_by_name(name)

Get a filter definition matching the given name.

Arguments

  • name: the filter name to find

Returns

the filter definition, if any matching one is registered. NULL if none found.

source
VideoIO.libffmpeg.avfilter_graph_alloc_filterMethod
avfilter_graph_alloc_filter(graph, filter, name)

Create a new filter instance in a filter graph.

Arguments

  • graph: graph in which the new filter will be used
  • filter: the filter to create an instance of
  • name: Name to give to the new instance (will be copied to AVFilterContext.name). This may be used by the caller to identify different filters, libavfilter itself assigns no semantics to this parameter. May be NULL.

Returns

the context of the newly created filter instance (note that it is also retrievable directly through AVFilterGraph.filters or with avfilter_graph_get_filter()) on success or NULL on failure.

source
VideoIO.libffmpeg.avfilter_graph_configMethod
avfilter_graph_config(graphctx, log_ctx)

Check validity and configure all the links and formats in the graph.

Arguments

  • graphctx: the filter graph
  • log_ctx: context used for logging

Returns

= 0 in case of success, a negative AVERROR code otherwise

source
VideoIO.libffmpeg.avfilter_graph_create_filterMethod
avfilter_graph_create_filter(filt_ctx, filt, name, args, opaque, graph_ctx)

A convenience wrapper that allocates and initializes a filter in a single step. The filter instance is created from the filter filt and inited with the parameter args. opaque is currently ignored.

In case of success put in *filt_ctx the pointer to the created filter instance, otherwise set *filt_ctx to NULL.

Warning

Since the filter is initialized after this function successfully returns, you MUST NOT set any further options on it. If you need to do that, call ::avfilter_graph_alloc_filter(), followed by setting the options, followed by ::avfilter_init_dict() instead of this function.

Arguments

  • name: the instance name to give to the created filter instance
  • graph_ctx: the filter graph

Returns

a negative AVERROR error code in case of failure, a non negative value otherwise

source
VideoIO.libffmpeg.avfilter_graph_dumpMethod
avfilter_graph_dump(graph, options)

Dump a graph into a human-readable string representation.

Arguments

  • graph: the graph to dump
  • options: formatting options; currently ignored

Returns

a string, or NULL in case of memory allocation failure; the string must be freed using av_free

source
VideoIO.libffmpeg.avfilter_graph_get_filterMethod
avfilter_graph_get_filter(graph, name)

Get a filter instance identified by instance name from graph.

Arguments

  • graph: filter graph to search through.
  • name: filter instance name (should be unique in the graph).

Returns

the pointer to the found filter instance or NULL if it cannot be found.

source
VideoIO.libffmpeg.avfilter_graph_parseMethod
avfilter_graph_parse(graph, filters, inputs, outputs, log_ctx)

Add a graph described by a string to a graph.

Note

The caller must provide the lists of inputs and outputs, which therefore must be known before calling the function.

Note

The inputs parameter describes inputs of the already existing part of the graph; i.e. from the point of view of the newly created part, they are outputs. Similarly the outputs parameter describes outputs of the already existing filters, which are provided as inputs to the parsed filters.

Arguments

  • graph: the filter graph where to link the parsed graph context
  • filters: string to be parsed
  • inputs: linked list to the inputs of the graph
  • outputs: linked list to the outputs of the graph

Returns

zero on success, a negative AVERROR code on error

source
VideoIO.libffmpeg.avfilter_graph_parse2Method
avfilter_graph_parse2(graph, filters, inputs, outputs)

Add a graph described by a string to a graph.

Note

This function returns the inputs and outputs that are left unlinked after parsing the graph and the caller then deals with them.

Note

This function makes no reference whatsoever to already existing parts of the graph and the inputs parameter will on return contain inputs of the newly parsed part of the graph. Analogously the outputs parameter will contain outputs of the newly created filters.

Arguments

  • graph:[in] the filter graph where to link the parsed graph context
  • filters:[in] string to be parsed
  • inputs:[out] a linked list of all free (unlinked) inputs of the parsed graph will be returned here. It is to be freed by the caller using avfilter_inout_free().
  • outputs:[out] a linked list of all free (unlinked) outputs of the parsed graph will be returned here. It is to be freed by the caller using avfilter_inout_free().

Returns

zero on success, a negative AVERROR code on error

source
VideoIO.libffmpeg.avfilter_graph_parse_ptrMethod
avfilter_graph_parse_ptr(graph, filters, inputs, outputs, log_ctx)

Add a graph described by a string to a graph.

In the graph filters description, if the input label of the first filter is not specified, "in" is assumed; if the output label of the last filter is not specified, "out" is assumed.

Arguments

  • graph: the filter graph where to link the parsed graph context
  • filters: string to be parsed
  • inputs: pointer to a linked list to the inputs of the graph, may be NULL. If non-NULL, *inputs is updated to contain the list of open inputs after the parsing, should be freed with avfilter_inout_free().
  • outputs: pointer to a linked list to the outputs of the graph, may be NULL. If non-NULL, *outputs is updated to contain the list of open outputs after the parsing, should be freed with avfilter_inout_free().

Returns

non negative on success, a negative AVERROR code on error

source
VideoIO.libffmpeg.avfilter_graph_queue_commandMethod
avfilter_graph_queue_command(graph, target, cmd, arg, flags::Integer, ts::Cdouble)

Queue a command for one or more filter instances.

Note

As this executes commands after this function returns, no return code from the filter is provided, also AVFILTER_CMD_FLAG_ONE is not supported.

Arguments

  • graph: the filter graph
  • target: the filter(s) to which the command should be sent "all" sends to all filters otherwise it can be a filter or filter instance name which will send the command to all matching filters.
  • cmd: the command to sent, for handling simplicity all commands must be alphanumeric only
  • arg: the argument for the command
  • ts: time at which the command should be sent to the filter
source
VideoIO.libffmpeg.avfilter_graph_request_oldestMethod
avfilter_graph_request_oldest(graph)

Request a frame on the oldest sink link.

If the request returns AVERROR_EOF, try the next.

Note that this function is not meant to be the sole scheduling mechanism of a filtergraph, only a convenience function to help drain a filtergraph in a balanced way under normal circumstances.

Also note that AVERROR_EOF does not mean that frames did not arrive on some of the sinks during the process. When there are multiple sink links, in case the requested link returns an EOF, this may cause a filter to flush pending frames which are sent to another sink link, although unrequested.

Returns

the return value of ff_request_frame(), or AVERROR_EOF if all links returned AVERROR_EOF

source
VideoIO.libffmpeg.avfilter_graph_segment_applyMethod
avfilter_graph_segment_apply(seg, flags::Integer, inputs, outputs)

Apply all filter/link descriptions from a graph segment to the associated filtergraph.

This functions is currently equivalent to calling the following in sequence: - avfilter_graph_segment_create_filters(); - avfilter_graph_segment_apply_opts(); - avfilter_graph_segment_init(); - avfilter_graph_segment_link(); failing if any of them fails. This list may be extended in the future.

Since the above functions are idempotent, the caller may call some of them manually, then do some custom processing on the filtergraph, then call this function to do the rest.

\retval"non-negative number" success

\retval"negative error code" failure

Note

Calling this function multiple times is safe, as it is idempotent.

Arguments

source
VideoIO.libffmpeg.avfilter_graph_segment_apply_optsMethod
avfilter_graph_segment_apply_opts(seg, flags::Integer)

Apply parsed options to filter instances in a graph segment.

Walk through all filter instances in the graph segment that have option dictionaries associated with them and apply those options with av_opt_set_dict2(..., AV_OPT_SEARCH_CHILDREN). AVFilterParams.opts is replaced by the dictionary output by av_opt_set_dict2(), which should be empty (NULL) if all options were successfully applied.

If any options could not be found, this function will continue processing all other filters and finally return AVERROR_OPTION_NOT_FOUND (unless another error happens). The calling program may then deal with unapplied options as it wishes.

Any creation-pending filters (see avfilter_graph_segment_create_filters()) present in the segment will cause this function to fail. AVFilterParams with no associated filter context are simply skipped.

\retval"non-negative number" Success, all options were successfully applied.

\retvalAVERROROPTIONNOT_FOUND some options were not found in a filter

\retval"another negative error code" other failures

Note

Calling this function multiple times is safe, as it is idempotent.

Arguments

  • seg: the filtergraph segment to process
  • flags: reserved for future use, caller must set to 0 for now
source
VideoIO.libffmpeg.avfilter_graph_segment_create_filtersMethod
avfilter_graph_segment_create_filters(seg, flags::Integer)

Create filters specified in a graph segment.

Walk through the creation-pending AVFilterParams in the segment and create new filter instances for them. Creation-pending params are those where AVFilterParams.filter_name is non-NULL (and hence AVFilterParams.filter is NULL). All other AVFilterParams instances are ignored.

For any filter created by this function, the corresponding AVFilterParams.filter is set to the newly-created filter context, AVFilterParams.filter_name and AVFilterParams.instance_name are freed and set to NULL.

\retval"non-negative number" Success, all creation-pending filters were successfully created

\retvalAVERRORFILTERNOT_FOUND some filter's name did not correspond to a known filter

\retval"another negative error code" other failures

Note

Calling this function multiple times is safe, as it is idempotent.

Arguments

  • seg: the filtergraph segment to process
  • flags: reserved for future use, caller must set to 0 for now
source
VideoIO.libffmpeg.avfilter_graph_segment_initMethod
avfilter_graph_segment_init(seg, flags::Integer)

Initialize all filter instances in a graph segment.

Walk through all filter instances in the graph segment and call avfilter_init_dict(..., NULL) on those that have not been initialized yet.

Any creation-pending filters (see avfilter_graph_segment_create_filters()) present in the segment will cause this function to fail. AVFilterParams with no associated filter context or whose filter context is already initialized, are simply skipped.

\retval"non-negative number" Success, all filter instances were successfully initialized

\retval"negative error code" failure

Note

Calling this function multiple times is safe, as it is idempotent.

Arguments

  • seg: the filtergraph segment to process
  • flags: reserved for future use, caller must set to 0 for now
source
VideoIO.libffmpeg.avfilter_graph_segment_linkMethod
avfilter_graph_segment_link(seg, flags::Integer, inputs, outputs)

Link filters in a graph segment.

Walk through all filter instances in the graph segment and try to link all unlinked input and output pads. Any creation-pending filters (see avfilter_graph_segment_create_filters()) present in the segment will cause this function to fail. Disabled filters and already linked pads are skipped.

Every filter output pad that has a corresponding AVFilterPadParams with a non-NULL label is - linked to the input with the matching label, if one exists; - exported in the outputs linked list otherwise, with the label preserved. Unlabeled outputs are - linked to the first unlinked unlabeled input in the next non-disabled filter in the chain, if one exists - exported in the outputs linked list otherwise, with NULL label

Similarly, unlinked input pads are exported in the inputs linked list.

\retval"non-negative number" success

\retval"negative error code" failure

Note

Calling this function multiple times is safe, as it is idempotent.

Arguments

  • seg: the filtergraph segment to process
  • flags: reserved for future use, caller must set to 0 for now
  • inputs:[out] a linked list of all free (unlinked) inputs of the filters in this graph segment will be returned here. It is to be freed by the caller using avfilter_inout_free().
  • outputs:[out] a linked list of all free (unlinked) outputs of the filters in this graph segment will be returned here. It is to be freed by the caller using avfilter_inout_free().
source
VideoIO.libffmpeg.avfilter_graph_segment_parseMethod
avfilter_graph_segment_parse(graph, graph_str, flags::Integer, seg)

Parse a textual filtergraph description into an intermediate form.

This intermediate representation is intended to be modified by the caller as described in the documentation of AVFilterGraphSegment and its children, and then applied to the graph either manually or with other avfilter_graph_segment_*() functions. See the documentation for avfilter_graph_segment_apply() for the canonical way to apply AVFilterGraphSegment.

\retval"non-negative number" success

\retval"negative error code" failure

Arguments

  • graph: Filter graph the parsed segment is associated with. Will only be used for logging and similar auxiliary purposes. The graph will not be actually modified by this function - the parsing results are instead stored in seg for further processing.
  • graph_str: a string describing the filtergraph segment
  • flags: reserved for future use, caller must set to 0 for now
  • seg: A pointer to the newly-created AVFilterGraphSegment is written here on success. The graph segment is owned by the caller and must be freed with avfilter_graph_segment_free() before graph itself is freed.
source
VideoIO.libffmpeg.avfilter_graph_send_commandMethod
avfilter_graph_send_command(graph, target, cmd, arg, res, res_len::Integer, flags::Integer)

Send a command to one or more filter instances.

Arguments

  • graph: the filter graph
  • target: the filter(s) to which the command should be sent "all" sends to all filters otherwise it can be a filter or filter instance name which will send the command to all matching filters.
  • cmd: the command to send, for handling simplicity all commands must be alphanumeric only
  • arg: the argument for the command
  • res: a buffer with size res_size where the filter(s) can return a response.

Returns

=0 on success otherwise an error code. AVERROR(ENOSYS) on unsupported commands

source
VideoIO.libffmpeg.avfilter_graph_set_auto_convertMethod
avfilter_graph_set_auto_convert(graph, flags::Integer)

Enable or disable automatic format conversion inside the graph.

Note that format conversion can still happen inside explicitly inserted scale and aresample filters.

Arguments

  • flags: any of the AVFILTER_AUTO_CONVERT_* constants
source
VideoIO.libffmpeg.avfilter_init_dictMethod
avfilter_init_dict(ctx, options)

Initialize a filter with the supplied dictionary of options.

Note

This function and avfilter_init_str() do essentially the same thing, the difference is in manner in which the options are passed. It is up to the calling code to choose whichever is more preferable. The two functions also behave differently when some of the provided options are not declared as supported by the filter. In such a case, avfilter_init_str() will fail, but this function will leave those extra options in the options AVDictionary and continue as usual.

Arguments

  • ctx: uninitialized filter context to initialize
  • options: An AVDictionary filled with options for this filter. On return this parameter will be destroyed and replaced with a dict containing options that were not found. This dictionary must be freed by the caller. May be NULL, then this function is equivalent to avfilter_init_str() with the second parameter set to NULL.

Returns

0 on success, a negative AVERROR on failure

source
VideoIO.libffmpeg.avfilter_init_strMethod
avfilter_init_str(ctx, args)

Initialize a filter with the supplied parameters.

Arguments

  • ctx: uninitialized filter context to initialize
  • args: Options to initialize the filter with. This must be a ':'-separated list of options in the 'key=value' form. May be NULL if the options have been set directly using the AVOptions API or there are no options that need to be set.

Returns

0 on success, a negative AVERROR on failure

source
VideoIO.libffmpeg.avfilter_insert_filterMethod
avfilter_insert_filter(link, filt, filt_srcpad_idx::Integer, filt_dstpad_idx::Integer)

Insert a filter in the middle of an existing link.

Arguments

  • link: the link into which the filter should be inserted
  • filt: the filter to be inserted
  • filt_srcpad_idx: the input pad on the filter to connect
  • filt_dstpad_idx: the output pad on the filter to connect

Returns

zero on success

source
VideoIO.libffmpeg.avfilter_linkMethod
avfilter_link(src, srcpad::Integer, dst, dstpad::Integer)

Link two filters together.

Arguments

  • src: the source filter
  • srcpad: index of the output pad on the source filter
  • dst: the destination filter
  • dstpad: index of the input pad on the destination filter

Returns

zero on success

source
VideoIO.libffmpeg.avfilter_pad_get_nameMethod
avfilter_pad_get_name(pads, pad_idx::Integer)

Get the name of an AVFilterPad.

Arguments

  • pads: an array of AVFilterPads
  • pad_idx: index of the pad in the array; it is the caller's responsibility to ensure the index is valid

Returns

name of the pad_idx'th pad in pads

source
VideoIO.libffmpeg.avfilter_pad_get_typeMethod
avfilter_pad_get_type(pads, pad_idx::Integer)

Get the type of an AVFilterPad.

Arguments

  • pads: an array of AVFilterPads
  • pad_idx: index of the pad in the array; it is the caller's responsibility to ensure the index is valid

Returns

type of the pad_idx'th pad in pads

source
VideoIO.libffmpeg.avformat_alloc_output_context2Method
avformat_alloc_output_context2(ctx, oformat, format_name, filename)

Allocate an AVFormatContext for an output format. avformat_free_context() can be used to free the context and everything allocated by the framework within it.

Arguments

  • ctx: pointee is set to the created format context, or to NULL in case of failure
  • oformat: format to use for allocating the context, if NULL format_name and filename are used instead
  • format_name: the name of output format to use for allocating the context, if NULL filename is used instead
  • filename: the name of the filename to use for allocating the context, may be NULL

Returns

= 0 in case of success, a negative AVERROR code in case of failure

source
VideoIO.libffmpeg.avformat_find_stream_infoMethod
avformat_find_stream_info(ic, options)

Read packets of a media file to get stream information. This is useful for file formats with no headers such as MPEG. This function also computes the real framerate in case of MPEG-2 repeat frame mode. The logical file position is not changed by this function; examined packets may be buffered for later processing.

Note

this function isn't guaranteed to open all the codecs, so options being non-empty at return is a perfectly normal behavior.

\todo Let the user decide somehow what information is needed so that we do not waste time getting stuff the user does not need.

Arguments

  • ic: media file handle
  • options: If non-NULL, an ic.nb_streams long array of pointers to dictionaries, where i-th member contains options for codec corresponding to i-th stream. On return each dictionary will be filled with options that were not found.

Returns

=0 if OK, AVERROR_xxx on error

source
VideoIO.libffmpeg.avformat_flushMethod
avformat_flush(s)

Discard all internally buffered data. This can be useful when dealing with discontinuities in the byte stream. Generally works only with formats that can resync. This includes headerless formats like MPEG-TS/TS but should also work with NUT, Ogg and in a limited way AVI for example.

The set of streams, the detected duration, stream parameters and codecs do not change when calling this function. If you want a complete reset, it's better to open a new AVFormatContext.

This does not flush the AVIOContext (s->pb). If necessary, call avio_flush(s->pb) before calling this function.

Arguments

  • s: media file handle

Returns

=0 on success, error code otherwise

source
VideoIO.libffmpeg.avformat_get_riff_video_tagsMethod
avformat_get_riff_video_tags()

riff_fourcc RIFF FourCCs

@{ Get the tables mapping RIFF FourCCs to libavcodec AVCodecIDs. The tables are meant to be passed to av_codec_get_id()/av_codec_get_tag() as in the following code:

 uint32_t tag = MKTAG('H', '2', '6', '4');
 const struct AVCodecTag *table[] = { avformat_get_riff_video_tags(), 0 };
 enum AVCodecID id = av_codec_get_id(table, tag);

Returns

the table mapping RIFF FourCCs for video to libavcodec AVCodecID.

source
VideoIO.libffmpeg.avformat_index_get_entry_from_timestampMethod
avformat_index_get_entry_from_timestamp(st, wanted_timestamp::Int64, flags::Integer)

Get the AVIndexEntry corresponding to the given timestamp.

Note

The pointer returned by this function is only guaranteed to be valid until any function that takes the stream or the parent AVFormatContext as input argument is called.

Arguments

  • st: Stream containing the requested AVIndexEntry.
  • wanted_timestamp: Timestamp to retrieve the index entry for.
  • flags: If AVSEEK_FLAG_BACKWARD then the returned entry will correspond to the timestamp which is <= the requested one, if backward is 0, then it will be >= if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise.

Returns

A pointer to the requested AVIndexEntry if it exists, NULL otherwise.

source
VideoIO.libffmpeg.avformat_init_outputMethod
avformat_init_output(s, options)

Allocate the stream private data and initialize the codec, but do not write the header. May optionally be used before avformat_write_header() to initialize stream parameters before actually writing the header. If using this function, do not pass the same options to avformat_write_header().

\retvalAVSTREAMINITINWRITEHEADER On success, if the codec requires avformat_write_header to fully initialize.

\retvalAVSTREAMINITININITOUTPUT On success, if the codec has been fully initialized.

\retvalAVERROR Anegative AVERROR on failure.

Arguments

  • s: Media file handle, must be allocated with avformat_alloc_context(). Its AVFormatContext.oformat "oformat" field must be set to the desired output format; Its AVFormatContext.pb "pb" field must be set to an already opened ::AVIOContext.
  • options: An ::AVDictionary filled with AVFormatContext and muxer-private options. On return this parameter will be destroyed and replaced with a dict containing options that were not found. May be NULL.

See also

av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_write_header.

source
VideoIO.libffmpeg.avformat_match_stream_specifierMethod
avformat_match_stream_specifier(s, st, spec)

Check if the stream st contained in s is matched by the stream specifier spec.

See the "stream specifiers" chapter in the documentation for the syntax of spec.

Note

A stream specifier can match several streams in the format.

Returns

0 if st is matched by spec; 0 if st is not matched by spec; AVERROR code if spec is invalid

source
VideoIO.libffmpeg.avformat_network_initMethod
avformat_network_init()

Do global initialization of network libraries. This is optional, and not recommended anymore.

This functions only exists to work around thread-safety issues with older GnuTLS or OpenSSL libraries. If libavformat is linked to newer versions of those libraries, or if you do not use them, calling this function is unnecessary. Otherwise, you need to call this function before any other threads using them are started.

This function will be deprecated once support for older GnuTLS and OpenSSL libraries is removed, and this function has no purpose anymore.

source
VideoIO.libffmpeg.avformat_new_streamMethod
avformat_new_stream(s, c)

Add a new stream to a media file.

When demuxing, it is called by the demuxer in read_header(). If the flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also be called in read_packet().

When muxing, should be called by the user before avformat_write_header().

User is required to call avformat_free_context() to clean up the allocation by avformat_new_stream().

Arguments

  • s: media file handle
  • c: unused, does nothing

Returns

newly created stream or NULL on error.

source
VideoIO.libffmpeg.avformat_open_inputMethod
avformat_open_input(ps, url, fmt, options)

Open an input stream and read the header. The codecs are not opened. The stream must be closed with avformat_close_input().

Note

If you want to use custom IO, preallocate the format context and set its pb field.

Arguments

  • ps: Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context). May be a pointer to NULL, in which case an AVFormatContext is allocated by this function and written into ps. Note that a user-supplied AVFormatContext will be freed on failure and its pointer set to NULL.
  • url: URL of the stream to open.
  • fmt: If non-NULL, this parameter forces a specific input format. Otherwise the format is autodetected.
  • options: A dictionary filled with AVFormatContext and demuxer-private options. On return this parameter will be destroyed and replaced with a dict containing options that were not found. May be NULL.

Returns

0 on success; on failure: frees ps, sets its pointer to NULL, and returns a negative AVERROR.

source
VideoIO.libffmpeg.avformat_query_codecMethod
avformat_query_codec(ofmt, codec_id::AVCodecID, std_compliance::Integer)

Test if the given container can store a codec.

Arguments

  • ofmt: container to check for compatibility
  • codec_id: codec to potentially store in container
  • std_compliance: standards compliance level, one of FF_COMPLIANCE_*

Returns

1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot. A negative number if this information is not available.

source
VideoIO.libffmpeg.avformat_seek_fileMethod
avformat_seek_file(s, stream_index::Integer, min_ts::Int64, ts::Int64, max_ts::Int64, flags::Integer)

Seek to timestamp ts. Seeking will be done so that the point from which all active streams can be presented successfully will be closest to ts and within min/max_ts. Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.

If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and are the file position (this may not be supported by all demuxers). If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames in the stream with stream_index (this may not be supported by all demuxers). Otherwise all timestamps are in units of the stream selected by stream_index or if stream_index is -1, in AV_TIME_BASE units. If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as keyframes (this may not be supported by all demuxers). If flags contain AVSEEK_FLAG_BACKWARD, it is ignored.

Note

This is part of the new seek API which is still under construction.

Arguments

  • s: media file handle
  • stream_index: index of the stream which is used as time base reference
  • min_ts: smallest acceptable timestamp
  • ts: target timestamp
  • max_ts: largest acceptable timestamp
  • flags: flags

Returns

=0 on success, error code otherwise

source
VideoIO.libffmpeg.avformat_stream_group_add_streamMethod
avformat_stream_group_add_stream(stg, st)

Add an already allocated stream to a stream group.

When demuxing, it may be called by the demuxer in read_header(). If the flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also be called in read_packet().

When muxing, may be called by the user before avformat_write_header() after having allocated a new group with avformat_stream_group_create() and stream with avformat_new_stream().

User is required to call avformat_free_context() to clean up the allocation by avformat_stream_group_add_stream().

\retval0 success

\retvalAVERROR(EEXIST) the stream was already in the group

\retval"another negative error code" legitimate errors

Arguments

  • stg: stream group belonging to a media file.
  • st: stream in the media file to add to the group.

See also

avformat_new_stream, avformat_stream_group_create.

source
VideoIO.libffmpeg.avformat_stream_group_createMethod
avformat_stream_group_create(s, type::AVStreamGroupParamsType, options)

Add a new empty stream group to a media file.

When demuxing, it may be called by the demuxer in read_header(). If the flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also be called in read_packet().

When muxing, may be called by the user before avformat_write_header().

User is required to call avformat_free_context() to clean up the allocation by avformat_stream_group_create().

New streams can be added to the group with avformat_stream_group_add_stream().

Arguments

  • s: media file handle

Returns

newly created group or NULL on error.

See also

avformat_new_stream, avformat_stream_group_add_stream.

source
VideoIO.libffmpeg.avformat_write_headerMethod
avformat_write_header(s, options)

Allocate the stream private data and write the stream header to an output media file.

\retvalAVSTREAMINITINWRITEHEADER On success, if the codec had not already been fully initialized in avformat_init_output().

\retvalAVSTREAMINITININITOUTPUT On success, if the codec had already been fully initialized in avformat_init_output().

\retvalAVERROR A negative AVERROR on failure.

Arguments

  • s: Media file handle, must be allocated with avformat_alloc_context(). Its AVFormatContext.oformat "oformat" field must be set to the desired output format; Its AVFormatContext.pb "pb" field must be set to an already opened ::AVIOContext.
  • options: An ::AVDictionary filled with AVFormatContext and muxer-private options. On return this parameter will be destroyed and replaced with a dict containing options that were not found. May be NULL.

See also

av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_init_output.

source
VideoIO.libffmpeg.avio_acceptMethod
avio_accept(s, c)

Accept and allocate a client context on a server context.

Arguments

  • s: the server context
  • c: the client context, must be unallocated

Returns

= 0 on success or a negative value corresponding to an AVERROR on failure

source
VideoIO.libffmpeg.avio_alloc_contextMethod
avio_alloc_context(buffer, buffer_size::Integer, write_flag::Integer, opaque, read_packet, write_packet, seek)

Allocate and initialize an AVIOContext for buffered I/O. It must be later freed with avio_context_free().

Arguments

  • buffer: Memory block for input/output operations via AVIOContext. The buffer must be allocated with av_malloc() and friends. It may be freed and replaced with a new buffer by libavformat. AVIOContext.buffer holds the buffer currently in use, which must be later freed with av_free().
  • buffer_size: The buffer size is very important for performance. For protocols with fixed blocksize it should be set to this blocksize. For others a typical size is a cache page, e.g. 4kb.
  • write_flag: Set to 1 if the buffer should be writable, 0 otherwise.
  • opaque: An opaque pointer to user-specific data.
  • read_packet: A function for refilling the buffer, may be NULL. For stream protocols, must never return 0 but rather a proper AVERROR code.
  • write_packet: A function for writing the buffer contents, may be NULL. The function may not change the input buffers content.
  • seek: A function for seeking to specified byte position, may be NULL.

Returns

Allocated AVIOContext or NULL on failure.

source
VideoIO.libffmpeg.avio_checkMethod
avio_check(url, flags::Integer)

Return AVIO_FLAG_* access flags corresponding to the access permissions of the resource in url, or a negative value corresponding to an AVERROR code in case of failure. The returned access flags are masked by the value in flags.

Note

This function is intrinsically unsafe, in the sense that the checked resource may change its existence or permission status from one call to another. Thus you should not trust the returned value, unless you are sure that no other processes are accessing the checked resource.

source
VideoIO.libffmpeg.avio_closepMethod
avio_closep(s)

Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL. This function can only be used if s was opened by avio_open().

The internal buffer is automatically flushed before closing the resource.

Returns

0 on success, an AVERROR < 0 on error.

See also

avio_close

source
VideoIO.libffmpeg.avio_context_freeMethod
avio_context_free(s)

Free the supplied IO context and everything associated with it.

Arguments

  • s: Double pointer to the IO context. This function will write NULL into s.
source
VideoIO.libffmpeg.avio_enum_protocolsMethod
avio_enum_protocols(opaque, output::Integer)

Iterate through names of available protocols.

Arguments

  • opaque: A private pointer representing current protocol. It must be a pointer to NULL on first iteration and will be updated by successive calls to avio_enum_protocols.
  • output: If set to 1, iterate over output protocols, otherwise over input protocols.

Returns

A static string containing the name of current protocol or NULL

source
VideoIO.libffmpeg.avio_feofMethod
avio_feof(s)

Similar to feof() but also returns nonzero on read errors.

Returns

non zero if and only if at end of file or a read error happened when reading.

source
VideoIO.libffmpeg.avio_find_protocol_nameMethod
avio_find_protocol_name(url)

Return the name of the protocol that will handle the passed URL.

NULL is returned if no protocol could be found for the given URL.

Returns

Name of the protocol or NULL.

source
VideoIO.libffmpeg.avio_flushMethod
avio_flush(s)

Force flushing of buffered data.

For write streams, force the buffered data to be immediately written to the output, without to wait to fill the internal buffer.

For read streams, discard all currently buffered data, and advance the reported file position to that of the underlying stream. This does not read new data, and does not perform any seeks.

source
VideoIO.libffmpeg.avio_get_dyn_bufMethod
avio_get_dyn_buf(s, pbuffer)

Return the written size and a pointer to the buffer. The AVIOContext stream is left intact. The buffer must NOT be freed. No padding is added to the buffer.

Arguments

  • s: IO context
  • pbuffer: pointer to a byte buffer

Returns

the length of the byte buffer

source
VideoIO.libffmpeg.avio_get_strMethod
avio_get_str(pb, maxlen::Integer, buf, buflen::Integer)

Read a string from pb into buf. The reading will terminate when either a NULL character was encountered, maxlen bytes have been read, or nothing more can be read from pb. The result is guaranteed to be NULL-terminated, it will be truncated if buf is too small. Note that the string is not interpreted or validated in any way, it might get truncated in the middle of a sequence for multi-byte encodings.

Returns

number of bytes read (is always <= maxlen). If reading ends on EOF or error, the return value will be one more than bytes actually read.

source
VideoIO.libffmpeg.avio_get_str16leMethod
avio_get_str16le(pb, maxlen::Integer, buf, buflen::Integer)

Read a UTF-16 string from pb and convert it to UTF-8. The reading will terminate when either a null or invalid character was encountered or maxlen bytes have been read.

Returns

number of bytes read (is always <= maxlen)

source
VideoIO.libffmpeg.avio_handshakeMethod
avio_handshake(c)

Perform one step of the protocol handshake to accept a new client. This function must be called on a client returned by avio_accept() before using it as a read/write context. It is separate from avio_accept() because it may block. A step of the handshake is defined by places where the application may decide to change the proceedings. For example, on a protocol with a request header and a reply header, each one can constitute a step because the application may use the parameters from the request to change parameters in the reply; or each individual chunk of the request can constitute a step. If the handshake is already finished, avio_handshake() does nothing and returns 0 immediately.

Arguments

  • c: the client context to perform the handshake on

Returns

0 on a complete and successful handshake > 0 if the handshake progressed, but is not complete < 0 for an AVERROR code

source
VideoIO.libffmpeg.avio_openMethod
avio_open(s, url, flags::Integer)

Create and initialize a AVIOContext for accessing the resource indicated by url.

Note

When the resource indicated by url has been opened in read+write mode, the AVIOContext can be used only for writing.

Arguments

  • s: Used to return the pointer to the created AVIOContext. In case of failure the pointed to value is set to NULL.
  • url: resource to access
  • flags: flags which control how the resource indicated by url is to be opened

Returns

= 0 in case of success, a negative value corresponding to an AVERROR code in case of failure

source
VideoIO.libffmpeg.avio_open2Method
avio_open2(s, url, flags::Integer, int_cb, options)

Create and initialize a AVIOContext for accessing the resource indicated by url.

Note

When the resource indicated by url has been opened in read+write mode, the AVIOContext can be used only for writing.

Arguments

  • s: Used to return the pointer to the created AVIOContext. In case of failure the pointed to value is set to NULL.
  • url: resource to access
  • flags: flags which control how the resource indicated by url is to be opened
  • int_cb: an interrupt callback to be used at the protocols level
  • options: A dictionary filled with protocol-private options. On return this parameter will be destroyed and replaced with a dict containing options that were not found. May be NULL.

Returns

= 0 in case of success, a negative value corresponding to an AVERROR code in case of failure

source
VideoIO.libffmpeg.avio_open_dirMethod
avio_open_dir(s, url, options)

Open directory for reading.

Arguments

  • s: directory read context. Pointer to a NULL pointer must be passed.
  • url: directory to be listed.
  • options: A dictionary filled with protocol-private options. On return this parameter will be destroyed and replaced with a dictionary containing options that were not found. May be NULL.

Returns

=0 on success or negative on error.

source
VideoIO.libffmpeg.avio_pauseMethod
avio_pause(h, pause::Integer)

Pause and resume playing - only meaningful if using a network streaming protocol (e.g. MMS).

Arguments

  • h: IO context from which to call the read_pause function pointer
  • pause: 1 for pause, 0 for resume
source
VideoIO.libffmpeg.avio_r8Method
avio_r8(s)

Functions for reading from AVIOContext

@{

Note

return 0 if EOF, so you cannot use it if EOF handling is necessary

source
VideoIO.libffmpeg.avio_read_partialMethod
avio_read_partial(s, buf, size::Integer)

Read size bytes from AVIOContext into buf. Unlike avio_read(), this is allowed to read fewer bytes than requested. The missing bytes can be read in the next call. This always tries to read at least 1 byte. Useful to reduce latency in certain cases.

Returns

number of bytes read or AVERROR

source
VideoIO.libffmpeg.avio_read_to_bprintMethod
avio_read_to_bprint(h, pb, max_size::Csize_t)

Read contents of h into print buffer, up to max_size bytes, or up to EOF.

Returns

0 for success (max_size bytes read or EOF reached), negative error code otherwise

source
VideoIO.libffmpeg.avio_seek_timeMethod
avio_seek_time(h, stream_index::Integer, timestamp::Int64, flags::Integer)

Seek to a given timestamp relative to some component stream. Only meaningful if using a network streaming protocol (e.g. MMS.).

Arguments

  • h: IO context from which to call the seek function pointers
  • stream_index: The stream index that the timestamp is relative to. If stream_index is (-1) the timestamp should be in AV_TIME_BASE units from the beginning of the presentation. If a stream_index >= 0 is used and the protocol does not support seeking based on component streams, the call will fail.
  • timestamp: timestamp in AVStream.time_base units or if there is no stream specified then in AV_TIME_BASE units.
  • flags: Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE and AVSEEK_FLAG_ANY. The protocol may silently ignore AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will fail if used and not supported.

Returns

= 0 on success

See also

AVInputFormat::read_seek

source
VideoIO.libffmpeg.avio_write_markerMethod
avio_write_marker(s, time::Int64, type::AVIODataMarkerType)

Mark the written bytestream as a specific type.

Zero-length ranges are omitted from the output.

Arguments

  • s: the AVIOContext
  • time: the stream time the current bytestream pos corresponds to (in AV_TIME_BASE units), or AV_NOPTS_VALUE if unknown or not applicable
  • type: the kind of data written starting at the current pos
source
VideoIO.libffmpeg.sws_convertPalette8ToPacked24Method
sws_convertPalette8ToPacked24(src, dst, num_pixels::Integer, palette)

Convert an 8-bit paletted frame into a frame with a color depth of 24 bits.

With the palette format "ABCD", the destination frame ends up with the format "ABC".

Arguments

  • src: source frame buffer
  • dst: destination frame buffer
  • num_pixels: number of pixels to convert
  • palette: array with [256] entries, which must match color arrangement (RGB or BGR) of src
source
VideoIO.libffmpeg.sws_convertPalette8ToPacked32Method
sws_convertPalette8ToPacked32(src, dst, num_pixels::Integer, palette)

Convert an 8-bit paletted frame into a frame with a color depth of 32 bits.

The output frame will have the same packed format as the palette.

Arguments

  • src: source frame buffer
  • dst: destination frame buffer
  • num_pixels: number of pixels to convert
  • palette: array with [256] entries, which must match color arrangement (RGB or BGR) of src
source
VideoIO.libffmpeg.sws_frame_setupMethod
sws_frame_setup(ctx, dst, src)

Like sws_scale_frame, but without actually scaling. It will instead merely initialize internal state that would be required to perform the operation, as well as returning the correct error code for unsupported frame combinations.

Arguments

  • ctx: The scaling context.
  • dst: The destination frame to consider.
  • src: The source frame to consider.

Returns

0 on success, a negative AVERROR code on failure.

source
VideoIO.libffmpeg.sws_frame_startMethod
sws_frame_start(c, dst, src)

Initialize the scaling process for a given pair of source/destination frames. Must be called before any calls to sws_send_slice() and sws_receive_slice(). Requires a context that has been previously been initialized with sws_init_context().

This function will retain references to src and dst, so they must both use refcounted buffers (if allocated by the caller, in case of dst).

The data buffers may either be already allocated by the caller or left clear, in which case they will be allocated by the scaler. The latter may have performance advantages - e.g. in certain cases some output planes may be references to input planes, rather than copies.

Output data will be written into this frame in successful sws_receive_slice() calls.

Arguments

  • c: The scaling context
  • dst: The destination frame.
  • src: The source frame. The data buffers must be allocated, but the frame data does not have to be ready at this point. Data availability is then signalled by sws_send_slice().

Returns

0 on success, a negative AVERROR code on failure

See also

sws_frame_end()

source
VideoIO.libffmpeg.sws_getCachedContextMethod
sws_getCachedContext(context, srcW::Integer, srcH::Integer, srcFormat::AVPixelFormat, dstW::Integer, dstH::Integer, dstFormat::AVPixelFormat, flags::Integer, srcFilter, dstFilter, param)

Check if context can be reused, otherwise reallocate a new one.

If context is NULL, just calls sws_getContext() to get a new context. Otherwise, checks if the parameters are the ones already saved in context. If that is the case, returns the current context. Otherwise, frees context and gets a new context with the new parameters.

Be warned that srcFilter and dstFilter are not checked, they are assumed to remain the same.

source
VideoIO.libffmpeg.sws_getColorspaceDetailsMethod
sws_getColorspaceDetails(c, inv_table, srcRange, table, dstRange, brightness, contrast, saturation)

Returns

A negative error code on error, non negative otherwise. If [LIBSWSCALEVERSIONMAJOR](@ref) < 7, returns -1 if not supported.

source
VideoIO.libffmpeg.sws_getContextMethod
sws_getContext(srcW::Integer, srcH::Integer, srcFormat::AVPixelFormat, dstW::Integer, dstH::Integer, dstFormat::AVPixelFormat, flags::Integer, srcFilter, dstFilter, param)

Allocate and return an SwsContext. You need it to perform scaling/conversion operations using sws_scale().

Note

this function is to be removed after a saner alternative is written

Arguments

  • srcW: the width of the source image
  • srcH: the height of the source image
  • srcFormat: the source image format
  • dstW: the width of the destination image
  • dstH: the height of the destination image
  • dstFormat: the destination image format
  • flags: specify which algorithm and options to use for rescaling
  • param: extra parameters to tune the used scaler For SWS_BICUBIC param[0] and [1] tune the shape of the basis function, param[0] tunes f(1) and param[1] f´(1) For SWS_GAUSS param[0] tunes the exponent and thus cutoff frequency For SWS_LANCZOS param[0] tunes the width of the window function

Returns

a pointer to an allocated context, or NULL in case of error

source
VideoIO.libffmpeg.sws_getGaussianVecMethod
sws_getGaussianVec(variance::Cdouble, quality::Cdouble)

Return a normalized Gaussian curve used to filter stuff quality = 3 is high quality, lower is lower quality.

source
VideoIO.libffmpeg.sws_init_contextMethod
sws_init_context(sws_context, srcFilter, dstFilter)

Initialize the swscaler context sws_context.

This function is considered deprecated, and provided only for backwards compatibility with sws_scale() and sws_start_frame(). The preferred way to use libswscale is to set all frame properties correctly and call sws_scale_frame() directly, without explicitly initializing the context.

Returns

zero or positive value on success, a negative value on error

source
VideoIO.libffmpeg.sws_is_noopMethod
sws_is_noop(dst, src)

Check if a given conversion is a noop. Returns a positive integer if no operation needs to be performed, 0 otherwise.

source
VideoIO.libffmpeg.sws_receive_sliceMethod
sws_receive_slice(c, slice_start::Integer, slice_height::Integer)

Request a horizontal slice of the output data to be written into the frame previously provided to sws_frame_start().

Arguments

  • c: The scaling context
  • slice_start: first row of the slice; must be a multiple of sws_receive_slice_alignment()
  • slice_height: number of rows in the slice; must be a multiple of sws_receive_slice_alignment(), except for the last slice (i.e. when slice_start+slice_height is equal to output frame height)

Returns

a non-negative number if the data was successfully written into the output AVERROR(EAGAIN) if more input data needs to be provided before the output can be produced another negative AVERROR code on other kinds of scaling failure

source
VideoIO.libffmpeg.sws_scaleMethod
sws_scale(c, srcSlice, srcStride, srcSliceY::Integer, srcSliceH::Integer, dst, dstStride)

Scale the image slice in srcSlice and put the resulting scaled slice in the image in dst. A slice is a sequence of consecutive rows in an image. Requires a context that has been previously been initialized with sws_init_context().

Slices have to be provided in sequential order, either in top-bottom or bottom-top order. If slices are provided in non-sequential order the behavior of the function is undefined.

Arguments

  • c: the scaling context previously created with sws_getContext()
  • srcSlice: the array containing the pointers to the planes of the source slice
  • srcStride: the array containing the strides for each plane of the source image
  • srcSliceY: the position in the source image of the slice to process, that is the number (counted starting from zero) in the image of the first row of the slice
  • srcSliceH: the height of the source slice, that is the number of rows in the slice
  • dst: the array containing the pointers to the planes of the destination image
  • dstStride: the array containing the strides for each plane of the destination image

Returns

the height of the output slice

source
VideoIO.libffmpeg.sws_scale_frameMethod
sws_scale_frame(c, dst, src)

Scale source data from src and write the output to dst.

This function can be used directly on an allocated context, without setting up any frame properties or calling [swsinitcontext](@ref)(). Such usage is fully dynamic and does not require reallocation if the frame properties change.

Alternatively, this function can be called on a context that has been explicitly initialized. However, this is provided only for backwards compatibility. In this usage mode, all frame properties must be correctly set at init time, and may no longer change after initialization.

Arguments

  • ctx: The scaling context.
  • dst: The destination frame. The data buffers may either be already allocated by the caller or left clear, in which case they will be allocated by the scaler. The latter may have performance advantages - e.g. in certain cases some (or all) output planes may be references to input planes, rather than copies.
  • src: The source frame. If the data buffers are set to NULL, then this function behaves identically to sws_frame_setup.

Returns

= 0 on success, a negative AVERROR code on failure.

source
VideoIO.libffmpeg.sws_send_sliceMethod
sws_send_slice(c, slice_start::Integer, slice_height::Integer)

Indicate that a horizontal slice of input data is available in the source frame previously provided to sws_frame_start(). The slices may be provided in any order, but may not overlap. For vertically subsampled pixel formats, the slices must be aligned according to subsampling.

Arguments

  • c: The scaling context
  • slice_start: first row of the slice
  • slice_height: number of rows in the slice

Returns

a non-negative number on success, a negative AVERROR code on failure.

source
VideoIO.libffmpeg.sws_setColorspaceDetailsMethod
sws_setColorspaceDetails(c, inv_table, srcRange::Integer, table, dstRange::Integer, brightness::Integer, contrast::Integer, saturation::Integer)

Arguments

  • c: the scaling context
  • dstRange: flag indicating the while-black range of the output (1=jpeg / 0=mpeg)
  • srcRange: flag indicating the while-black range of the input (1=jpeg / 0=mpeg)
  • table: the yuv2rgb coefficients describing the output yuv space, normally ff_yuv2rgb_coeffs[x]
  • inv_table: the yuv2rgb coefficients describing the input yuv space, normally ff_yuv2rgb_coeffs[x]
  • brightness: 16.16 fixed point brightness correction
  • contrast: 16.16 fixed point contrast correction
  • saturation: 16.16 fixed point saturation correction

Returns

A negative error code on error, non negative otherwise. If [LIBSWSCALEVERSIONMAJOR](@ref) < 7, returns -1 if not supported.

source
VideoIO.libffmpeg.sws_test_colorspaceMethod
sws_test_colorspace(colorspace::AVColorSpace, output::Integer)

Test if a given color space is supported.

Arguments

  • output: If 0, test if compatible with the source/input frame; otherwise, with the destination/output frame.
  • colorspace: The colorspace to check.

Returns

A positive integer if supported, 0 otherwise.

source
VideoIO.libffmpeg.sws_test_formatMethod
sws_test_format(format::AVPixelFormat, output::Integer)

Test if a given pixel format is supported.

Arguments

  • output: If 0, test if compatible with the source/input frame; otherwise, with the destination/output frame.
  • format: The format to check.

Returns

A positive integer if supported, 0 otherwise.

source
VideoIO.libffmpeg.sws_test_frameMethod
sws_test_frame(frame, output::Integer)

Helper function to run all sws_test_* against a frame, as well as testing the basic frame properties for sanity. Ignores irrelevant properties - for example, AVColorSpace is not checked for RGB frames.

source
VideoIO.libffmpeg.sws_test_primariesMethod
sws_test_primaries(primaries::AVColorPrimaries, output::Integer)

Test if a given set of color primaries is supported.

Arguments

  • output: If 0, test if compatible with the source/input frame; otherwise, with the destination/output frame.
  • primaries: The color primaries to check.

Returns

A positive integer if supported, 0 otherwise.

source
VideoIO.libffmpeg.sws_test_transferMethod
sws_test_transfer(trc::AVColorTransferCharacteristic, output::Integer)

Test if a given color transfer function is supported.

Arguments

  • output: If 0, test if compatible with the source/input frame; otherwise, with the destination/output frame.
  • trc: The color transfer function to check.

Returns

A positive integer if supported, 0 otherwise.

source

Types

VideoIO.libffmpeg.AV3DReferenceDisplaysInfoType
AV3DReferenceDisplaysInfo

This structure describes information about the reference display width(s) and reference viewing distance(s) as well as information about the corresponding reference stereo pair(s). See section G.14.3.2.3 of ITU-T H.265 for more information.

Note

The struct must be allocated with av_tdrdi_alloc() and its size is not a part of the public ABI.

source
VideoIO.libffmpeg.AVBPrintType
AVBPrint

Buffer to print data progressively

The string buffer grows as necessary and is always 0-terminated. The content of the string is never accessed, and thus is encoding-agnostic and can even hold binary data.

Small buffers are kept in the structure itself, and thus require no memory allocation at all (unless the contents of the buffer is needed after the structure goes out of scope). This is almost as lightweight as declaring a local char buf[512].

The length of the string can go beyond the allocated size: the buffer is then truncated, but the functions still keep account of the actual total length.

In other words, AVBPrint.len can be greater than AVBPrint.size and records the total length of what would have been to the buffer if there had been enough memory.

Append operations do not need to be tested for failure: if a memory allocation fails, data stop being appended to the buffer, but the length is still updated. This situation can be tested with av_bprint_is_complete().

The AVBPrint.size_max field determines several possible behaviours: - size\_max = -1 (= UINT_MAX) or any large value will let the buffer be reallocated as necessary, with an amortized linear cost. - size\_max = 0 prevents writing anything to the buffer: only the total length is computed. The write operations can then possibly be repeated in a buffer with exactly the necessary size (using size\_init = size\_max = len + 1). - size\_max = 1 is automatically replaced by the exact size available in the structure itself, thus ensuring no dynamic memory allocation. The internal buffer is large enough to hold a reasonable paragraph of text, such as the current paragraph.

source
VideoIO.libffmpeg.AVBSFContextType
AVBSFContext

The bitstream filter state.

This struct must be allocated with av_bsf_alloc() and freed with av_bsf_free().

The fields in the struct will only be changed (by the caller or by the filter) as described in their documentation, and are to be considered immutable otherwise.

source
VideoIO.libffmpeg.AVBufferRefType
AVBufferRef

A reference to a data buffer.

The size of this struct is not a part of the public ABI and it is not meant to be allocated directly.

source
VideoIO.libffmpeg.AVCPBPropertiesType
AVCPBProperties

This structure describes the bitrate properties of an encoded bitstream. It roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD parameters for H.264/HEVC.

source
VideoIO.libffmpeg.AVCRCType

lavu_crc32 CRC

lavu_hash

CRC (Cyclic Redundancy Check) hash function implementation.

This module supports numerous CRC polynomials, in addition to the most widely used CRC-32-IEEE. See AVCRCId for a list of available polynomials.

@{

source
VideoIO.libffmpeg.AVChannelLayoutType
AVChannelLayout

An AVChannelLayout holds information about the channel layout of audio data.

A channel layout here is defined as a set of channels ordered in a specific way (unless the channel order is AV_CHANNEL_ORDER_UNSPEC, in which case an AVChannelLayout carries only the channel count). All orders may be treated as if they were AV_CHANNEL_ORDER_UNSPEC by ignoring everything but the channel count, as long as av_channel_layout_check() considers they are valid.

Unlike most structures in FFmpeg, sizeof(AVChannelLayout) is a part of the public ABI and may be used by the caller. E.g. it may be allocated on stack or embedded in caller-defined structs.

AVChannelLayout can be initialized as follows: - default initialization with {0}, followed by setting all used fields correctly; - by assigning one of the predefined AV_CHANNEL_LAYOUT_* initializers; - with a constructor function, such as av_channel_layout_default(), av_channel_layout_from_mask() or av_channel_layout_from_string().

The channel layout must be uninitialized with av_channel_layout_uninit()

Copying an AVChannelLayout via assigning is forbidden, av_channel_layout_copy() must be used instead (and its return value should be checked)

No new fields may be added to it without a major version bump, except for new elements of the union fitting in sizeof(uint64_t).

source
VideoIO.libffmpeg.AVChromaLocationType
AVChromaLocation

Location of chroma samples.

Illustration showing the location of the first (top left) chroma sample of the image, the left shows only luma, the right shows the location of the chroma sample, the 2 could be imagined to overlay each other but are drawn separately due to limitations of ASCII

1st 2nd 1st 2nd horizontal luma sample positions v v v v ______ ______1st luma line > |X X ... |3 4 X ... X are luma samples, | |1 2 1-6 are possible chroma positions2nd luma line > |X X ... |5 6 X ... 0 is undefined/unknown position

source
VideoIO.libffmpeg.AVCodecContextType
AVCodecContext

main external API structure. New fields can be added to the end with minor version bumps. Removal, reordering and changes to existing fields require a major version bump. You can use AVOptions (av_opt* / av_set/get()) to access these fields from user applications. The name string for AVOptions options matches the associated command line parameter name and can be found in libavcodec/options_table.h The AVOption/command line parameter names differ in some cases from the C structure field names for historic reasons or brevity. sizeof(AVCodecContext) must not be used outside libav.

source
VideoIO.libffmpeg.AVCodecIDType
AVCodecID

Identify the syntax and semantics of the bitstream. The principle is roughly: Two decoders with the same ID can decode the same streams. Two encoders with the same ID can encode compatible streams. There may be slight deviations from the principle due to implementation details.

If you add a codec ID to this list, add it so that 1. no value of an existing codec ID changes (that would break ABI), 2. it is as close as possible to similar codecs

After adding new codec IDs, do not forget to add an entry to the codec descriptor list and bump libavcodec minor version.

source
VideoIO.libffmpeg.AVColorPrimariesType
AVColorPrimaries

Chromaticity coordinates of the source primaries. These values match the ones defined by ISO/IEC 23091-2_2019 subclause 8.1 and ITU-T H.273.

source
VideoIO.libffmpeg.AVColorRangeType
AVColorRange

Visual content value range.

These values are based on definitions that can be found in multiple specifications, such as ITU-T BT.709 (3.4 - Quantization of RGB, luminance and colour-difference signals), ITU-T BT.2020 (Table 5 - Digital Representation) as well as ITU-T BT.2100 (Table 9 - Digital 10- and 12-bit integer representation). At the time of writing, the BT.2100 one is recommended, as it also defines the full range representation.

Common definitions: - For RGB and luma planes such as Y in YCbCr and I in ICtCp, 'E' is the original value in range of 0.0 to 1.0. - For chroma planes such as Cb,Cr and Ct,Cp, 'E' is the original value in range of -0.5 to 0.5. - 'n' is the output bit depth. - For additional definitions such as rounding and clipping to valid n bit unsigned integer range, please refer to BT.2100 (Table 9).

source
VideoIO.libffmpeg.AVDOVIDmDataType
AVDOVIDmData

Dolby Vision metadata extension block. Dynamic extension blocks may change from frame to frame, while static blocks are constant throughout the entire sequence.

Note

sizeof(AVDOVIDmData) is not part of the public API.

source
VideoIO.libffmpeg.AVDRMFrameDescriptorType
AVDRMFrameDescriptor

DRM frame descriptor.

This is used as the data pointer for AV_PIX_FMT_DRM_PRIME frames. It is also used by user-allocated frame pools - allocating in AVHWFramesContext.pool must return AVBufferRefs which contain an object of this type.

The fields of this structure should be set such it can be imported directly by EGL using the EGL_EXT_image_dma_buf_import and EGL_EXT_image_dma_buf_import_modifiers extensions. (Note that the exact layout of a particular format may vary between platforms - we only specify that the same platform should be able to import it.)

The total number of planes must not exceed AV_DRM_MAX_PLANES, and the order of the planes by increasing layer index followed by increasing plane index must be the same as the order which would be used for the data pointers in the equivalent software format.

source
VideoIO.libffmpeg.AVDownmixInfoType
AVDownmixInfo

This structure describes optional metadata relevant to a downmix procedure.

All fields are set by the decoder to the value indicated in the audio bitstream (if present), or to a "sane" default otherwise.

source
VideoIO.libffmpeg.AVEncryptionInfoType
AVEncryptionInfo

This describes encryption info for a packet. This contains frame-specific info for how to decrypt the packet before passing it to the decoder.

The size of this struct is not part of the public ABI.

source
VideoIO.libffmpeg.AVFifoCBType

Callback for writing or reading from a FIFO, passed to (and invoked from) the av_fifo__cb() functions. It may be invoked multiple times from a single av_fifo__cb() call and may process less data than the maximum size indicated by nb_elems.

Arguments

  • opaque: the opaque pointer provided to the av_fifo_*_cb() function
  • buf: the buffer for reading or writing the data, depending on which av_fifo_*_cb function is called
  • nb_elems: On entry contains the maximum number of elements that can be read from / written into buf. On success, the callback should update it to contain the number of elements actually written.

Returns

0 on success, a negative error code on failure (will be returned from the invoking av_fifo_*_cb() function)

source
VideoIO.libffmpeg.AVFilmGrainParamsType
AVFilmGrainParams

This structure describes how to handle film grain synthesis in video for specific codecs. Must be present on every frame where film grain is meant to be synthesised for correct presentation.

Note

The struct must be allocated with av_film_grain_params_alloc() and its size is not a part of the public ABI.

source
VideoIO.libffmpeg.AVFilterType
AVFilter

Filter definition. This defines the pads a filter contains, and all the callback functions used to interact with the filter.

source
VideoIO.libffmpeg.AVFilterFormatsConfigType
AVFilterFormatsConfig

Lists of formats / etc. supported by an end of a link.

This structure is directly part of AVFilterLink, in two copies: one for the source filter, one for the destination filter.

These lists are used for negotiating the format to actually be used, which will be loaded into the format and channel_layout members of AVFilterLink, when chosen.

source
VideoIO.libffmpeg.AVFilterInOutType
AVFilterInOut

A linked-list of the inputs/outputs of the filter chain.

This is mainly useful for avfilter_graph_parse() / avfilter_graph_parse2(), where it is used to communicate open (unlinked) inputs and outputs from and to the caller. This struct specifies, per each not connected pad contained in the graph, the filter context and the pad index required for establishing a link.

source
VideoIO.libffmpeg.AVFilterLinkType
AVFilterLink

A link between two filters. This contains pointers to the source and destination filters between which this link exists, and the indexes of the pads involved. In addition, this link also contains the parameters which have been negotiated and agreed upon between the filter, such as image dimensions, format, etc.

Applications must not normally access the link structure directly. Use the buffersrc and buffersink API instead. In the future, access to the header may be reserved for filters implementation.

source
VideoIO.libffmpeg.AVFormatContextType
AVFormatContext

Format I/O context. New fields can be added to the end with minor version bumps. Removal, reordering and changes to existing fields require a major version bump. sizeof(AVFormatContext) must not be used outside libav*, use avformat_alloc_context() to create an AVFormatContext.

Fields can be accessed through AVOptions (av_opt*), the name string used matches the associated command line parameter name and can be found in libavformat/options_table.h. The AVOption/command line parameter names differ in some cases from the C structure field names for historic reasons or brevity.

source
VideoIO.libffmpeg.AVFrameType
AVFrame

This structure describes decoded (raw) audio or video data.

AVFrame must be allocated using av_frame_alloc(). Note that this only allocates the AVFrame itself, the buffers for the data must be managed through other means (see below). AVFrame must be freed with av_frame_free().

AVFrame is typically allocated once and then reused multiple times to hold different data (e.g. a single AVFrame to hold frames received from a decoder). In such a case, av_frame_unref() will free any references held by the frame and reset it to its original clean state before it is reused again.

The data described by an AVFrame is usually reference counted through the AVBuffer API. The underlying buffer references are stored in AVFrame.buf / AVFrame.extended_buf. An AVFrame is considered to be reference counted if at least one reference is set, i.e. if AVFrame.buf[0] != NULL. In such a case, every single data plane must be contained in one of the buffers in AVFrame.buf or AVFrame.extended_buf. There may be a single buffer for all the data, or one separate buffer for each plane, or anything in between.

sizeof(AVFrame) is not a part of the public ABI, so new fields may be added to the end with a minor bump.

Fields can be accessed through AVOptions, the name string used, matches the C structure field name for fields accessible through AVOptions.

source
VideoIO.libffmpeg.AVHWAccelType
AVHWAccel

lavc_hwaccel AVHWAccel

Note

Nothing in this structure should be accessed by the user. At some point in future it will not be externally visible at all.

@{

source
VideoIO.libffmpeg.AVHWDeviceContextType
AVHWDeviceContext

This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e. state that is not tied to a concrete processing configuration. E.g., in an API that supports hardware-accelerated encoding and decoding, this struct will (if possible) wrap the state that is common to both encoding and decoding and from which specific instances of encoders or decoders can be derived.

This struct is reference-counted with the AVBuffer mechanism. The av_hwdevice_ctx_alloc() constructor yields a reference, whose data field points to the actual AVHWDeviceContext. Further objects derived from AVHWDeviceContext (such as AVHWFramesContext, describing a frame pool with specific properties) will hold an internal reference to it. After all the references are released, the AVHWDeviceContext itself will be freed, optionally invoking a user-specified callback for uninitializing the hardware state.

source
VideoIO.libffmpeg.AVHWFramesContextType
AVHWFramesContext

This struct describes a set or pool of "hardware" frames (i.e. those with data not located in normal system memory). All the frames in the pool are assumed to be allocated in the same way and interchangeable.

This struct is reference-counted with the AVBuffer mechanism and tied to a given AVHWDeviceContext instance. The av_hwframe_ctx_alloc() constructor yields a reference, whose data field points to the actual AVHWFramesContext struct.

source
VideoIO.libffmpeg.AVHashContextType

ffhash.c

This example is a simple command line application that takes one or more arguments. It demonstrates a typical use of the hashing API with allocation, initialization, updating, and finalizing.

source
VideoIO.libffmpeg.AVIAMFAnimationTypeType
AVIAMFAnimationType

lavu_iamf Immersive Audio Model and Formats

lavu_audio

Immersive Audio Model and Formats related functions and defines

lavu_iamf_params Parameter Definition

lavu_iamf

@{ Parameters as defined in section 3.6.1 and 3.8 of IAMF. @}

lavu_iamf_audio Audio Element

lavu_iamf

@{ Audio Elements as defined in section 3.6 of IAMF. @}

lavu_iamf_mix Mix Presentation

lavu_iamf

@{ Mix Presentations as defined in section 3.7 of IAMF. @}

lavu_iamf_params

@{

source
VideoIO.libffmpeg.AVIAMFLayerType
AVIAMFLayer

A layer defining a Channel Layout in the Audio Element.

When AVIAMFAudioElement.audioelementtype "the parent's Audio Element type" is AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL, this corresponds to an Scalable Channel Layout layer as defined in section 3.6.2 of IAMF. For AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE, it is an Ambisonics channel layout as defined in section 3.6.3 of IAMF.

Note

The struct should be allocated with av_iamf_audio_element_add_layer() and its size is not a part of the public ABI.

source
VideoIO.libffmpeg.AVIAMFParamDefinitionType
AVIAMFParamDefinition

Parameters as defined in section 3.6.1 of IAMF.

The struct is allocated by av_iamf_param_definition_alloc() along with an array of subblocks, its type depending on the value of type. This array is placed subblocks_offset bytes after the start of this struct.

Note

This struct's size is not a part of the public ABI.

source
VideoIO.libffmpeg.AVIOContextType
AVIOContext

Bytestream IO Context. New public fields can be added with minor version bumps. Removal, reordering and changes to existing public fields require a major version bump. sizeof(AVIOContext) must not be used outside libav*.

Note

None of the function pointers in AVIOContext should be called directly, they should only be set by the client application when implementing custom I/O. Normally these are set to the function pointers specified in avio_alloc_context()

source
VideoIO.libffmpeg.AVIODirEntryType
AVIODirEntry

Describes single entry of the directory.

Only name and type fields are guaranteed be set. Rest of fields are protocol or/and platform dependent and might be unknown.

source
VideoIO.libffmpeg.AVIOInterruptCBType
AVIOInterruptCB

Callback for checking whether to abort blocking functions. AVERROR_EXIT is returned in this case by the interrupted function. During blocking operations, callback is called with opaque as parameter. If the callback returns 1, the blocking operation will be aborted.

No members can be added to this struct without a major bump, if new elements have been added after this struct in AVFormatContext or AVIOContext.

source
VideoIO.libffmpeg.AVLFGType
AVLFG

Context structure for the Lagged Fibonacci PRNG. The exact layout, types and content of this struct may change and should not be accessed directly. Only its sizeof() is guaranteed to stay the same to allow easy instantiation.

source
VideoIO.libffmpeg.AVOptionTypeType
AVOptionType

An option type determines: - for native access, the underlying C type of the field that an AVOption refers to; - for foreign access, the semantics of accessing the option through this API, e.g. which av_opt_get_() and av_opt_set_() functions can be called, or what format will av_opt_get()/av_opt_set() expect/produce.

source
VideoIO.libffmpeg.AVPacketType
AVPacket

This structure stores compressed data. It is typically exported by demuxers and then passed as input to decoders, or received as output from encoders and then passed to muxers.

For video, it should typically contain one compressed frame. For audio it may contain several compressed frames. Encoders are allowed to output empty packets, with no compressed data, containing only side data (e.g. to update some stream parameters at the end of encoding).

The semantics of data ownership depends on the buf field. If it is set, the packet data is dynamically allocated and is valid indefinitely until a call to av_packet_unref() reduces the reference count to 0.

If the buf field is not set av_packet_ref() would make a copy instead of increasing the reference count.

The side data is always allocated with av_malloc(), copied by av_packet_ref() and freed by av_packet_unref().

sizeof(AVPacket) being a part of the public ABI is deprecated. once av_init_packet() is removed, new packets will only be able to be allocated with av_packet_alloc(), and new fields may be added to the end of the struct with a minor bump.

See also

av_packet_alloc, av_packet_ref, av_packet_unref

source
VideoIO.libffmpeg.AVPacketSideDataType
AVPacketSideData

This structure stores auxiliary information for decoding, presenting, or otherwise processing the coded stream. It is typically exported by demuxers and encoders and can be fed to decoders and muxers either in a per packet basis, or as global side data (applying to the entire coded stream).

Global side data is handled as follows: - During demuxing, it may be exported through AVCodecParameters.codedsidedata "AVStream's codec parameters", which can then be passed as input to decoders through the AVCodecContext.codedsidedata "decoder context's side data", for initialization. - For muxing, it can be fed through AVCodecParameters.codedsidedata "AVStream's codec parameters", typically the output of encoders through the AVCodecContext.codedsidedata "encoder context's side data", for initialization.

Packet specific side data is handled as follows: - During demuxing, it may be exported through AVPacket.sidedata "AVPacket's side data", which can then be passed as input to decoders. - For muxing, it can be fed through AVPacket.sidedata "AVPacket's side data", typically the output of encoders.

Different modules may accept or export different types of side data depending on media type and codec. Refer to AVPacketSideDataType for a list of defined types and where they may be found or used.

source
VideoIO.libffmpeg.AVPanScanType
AVPanScan

Pan Scan area. This specifies the area which should be displayed. Note there may be multiple such areas for one frame.

source
VideoIO.libffmpeg.AVPixFmtDescriptorType
AVPixFmtDescriptor

Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes of an image. It also stores the subsampling factors and number of components.

Note

This is separate of the colorspace (RGB, YCbCr, YPbPr, JPEG-style YUV and all the YUV variants) AVPixFmtDescriptor just stores how values are stored not what these values represent.

source
VideoIO.libffmpeg.AVPixelFormatType
AVPixelFormat

Pixel format.

Note

AV_PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA color is put together as: (A << 24) | (R << 16) | (G << 8) | B This is stored as BGRA on little-endian CPU architectures and ARGB on big-endian CPUs.

Note

If the resolution is not a multiple of the chroma subsampling factor then the chroma plane resolution must be rounded up.

\par When the pixel format is palettized RGB32 (AV_PIX_FMT_PAL8), the palettized image data is stored in AVFrame.data[0]. The palette is transported in AVFrame.data[1], is 1024 bytes long (256 4-byte entries) and is formatted the same as in AV_PIX_FMT_RGB32 described above (i.e., it is also endian-specific). Note also that the individual RGB32 palette components stored in AVFrame.data[1] should be in the range 0..255. This is important as many custom PAL8 video codecs that were designed to run on the IBM VGA graphics adapter use 6-bit palette components.

\par For all the 8 bits per pixel formats, an RGB32 palette is in data[1] like for pal8. This palette is filled in automatically by the function allocating the picture.

source
VideoIO.libffmpeg.AVProducerReferenceTimeType
AVProducerReferenceTime

This structure supplies correlation between a packet timestamp and a wall clock production time. The definition follows the Producer Reference Time ('prft') as defined in ISO/IEC 14496-12

source
VideoIO.libffmpeg.AVProgramType
AVProgram

New fields can be added to the end with minor version bumps. Removal, reordering and changes to existing fields require a major version bump. sizeof(AVProgram) must not be used outside libav*.

source
VideoIO.libffmpeg.AVRefStructOpaqueType
AVRefStructOpaque

This union is used for all opaque parameters in this API to spare the user to cast const away in case the opaque to use is const-qualified.

The functions provided by this API with an AVRefStructOpaque come in pairs named foo_c and foo. The foo function accepts void* as opaque and is just a wrapper around the foo_c function; "_c" means "(potentially) const".

source
VideoIO.libffmpeg.AVRegionOfInterestType
AVRegionOfInterest

Structure describing a single Region Of Interest.

When multiple regions are defined in a single side-data block, they should be ordered from most to least important - some encoders are only capable of supporting a limited number of distinct regions, so will have to truncate the list.

When overlapping regions are defined, the first region containing a given area of the frame applies.

source
VideoIO.libffmpeg.AVReplayGainType
AVReplayGain

ReplayGain information (see http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification). The size of this struct is a part of the public ABI.

source
VideoIO.libffmpeg.AVSampleFormatType
AVSampleFormat

Audio sample formats

  • The data described by the sample format is always in native-endian order. Sample values can be expressed by native C types, hence the lack of a signed 24-bit sample format even though it is a common raw audio data format.

  • The floating-point formats are based on full volume being in the range [-1.0, 1.0]. Any values outside this range are beyond full volume level.

  • The data layout as used in av_samples_fill_arrays() and elsewhere in FFmpeg (such as AVFrame in libavcodec) is as follows:

\par For planar sample formats, each audio channel is in a separate data plane, and linesize is the buffer size, in bytes, for a single plane. All data planes must be the same size. For packed sample formats, only the first data plane is used, and samples for each channel are interleaved. In this case, linesize is the buffer size, in bytes, for the 1 plane.

source
VideoIO.libffmpeg.AVSphericalMappingType
AVSphericalMapping

This structure describes how to handle spherical videos, outlining information about projection, initial layout, and any other view modifier.

Note

The struct must be allocated with av_spherical_alloc() and its size is not a part of the public ABI.

source
VideoIO.libffmpeg.AVStereo3DType
AVStereo3D

Stereo 3D type: this structure describes how two videos are packed within a single video surface, with additional information as needed.

Note

The struct must be allocated with av_stereo3d_alloc() and its size is not a part of the public ABI.

source
VideoIO.libffmpeg.AVStreamType
AVStream

Stream structure. New fields can be added to the end with minor version bumps. Removal, reordering and changes to existing fields require a major version bump. sizeof(AVStream) must not be used outside libav*.

source
VideoIO.libffmpeg.AVStreamGroupLCEVCType
AVStreamGroupLCEVC

AVStreamGroupLCEVC is meant to define the relation between video streams and a data stream containing LCEVC enhancement layer NALUs.

No more than one stream of AVCodecParameters.codectype "codec\type" AVMEDIA_TYPE_DATA shall be present, and it must be of AVCodecParameters.codecid "codec\id" AV_CODEC_ID_LCEVC.

source
VideoIO.libffmpeg.AVStreamGroupTileGridType
AVStreamGroupTileGrid

AVStreamGroupTileGrid holds information on how to combine several independent images on a single canvas for presentation.

The output should be a AVStreamGroupTileGrid.background "background" colored AVStreamGroupTileGrid.codedwidth "coded\width" x AVStreamGroupTileGrid.codedheight "coded\height" canvas where a AVStreamGroupTileGrid.nbtiles "nb\tiles" amount of tiles are placed in the order they appear in the AVStreamGroupTileGrid.offsets "offsets" array, at the exact offset described for them. In particular, if two or more tiles overlap, the image with higher index in the AVStreamGroupTileGrid.offsets "offsets" array takes priority. Note that a single image may be used multiple times, i.e. multiple entries in AVStreamGroupTileGrid.offsets "offsets" may have the same value of idx.

The following is an example of a simple grid with 3 rows and 4 columns:

+–-+–-+–-+–-+ | 0 | 1 | 2 | 3 | +–-+–-+–-+–-+ | 4 | 5 | 6 | 7 | +–-+–-+–-+–-+ | 8 | 9 |10 |11 | +–-+–-+–-+–-+

Assuming all tiles have a dimension of 512x512, the AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of the first AVStreamGroup.streams "stream" in the group is "0,0", the AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of the second AVStreamGroup.streams "stream" in the group is "512,0", the AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of the fifth AVStreamGroup.streams "stream" in the group is "0,512", the AVStreamGroupTileGrid.offsets "offset", of the topleft pixel of the sixth AVStreamGroup.streams "stream" in the group is "512,512", etc.

The following is an example of a canvas with overlapping tiles:

+–––––-+ | %%%%% | |***%3%%@@| |**0%%%%2@| |***##1@@@| | ##### | +–––––-+

Assuming a canvas with size 1024x1024 and all tiles with a dimension of 512x512, a possible AVStreamGroupTileGrid.offsets "offset" for the topleft pixel of the first AVStreamGroup.streams "stream" in the group would be 0x256, the AVStreamGroupTileGrid.offsets "offset" for the topleft pixel of the second AVStreamGroup.streams "stream" in the group would be 256x512, the AVStreamGroupTileGrid.offsets "offset" for the topleft pixel of the third AVStreamGroup.streams "stream" in the group would be 512x256, and the AVStreamGroupTileGrid.offsets "offset" for the topleft pixel of the fourth AVStreamGroup.streams "stream" in the group would be 256x0.

sizeof(AVStreamGroupTileGrid) is not a part of the ABI and may only be allocated by avformat_stream_group_create().

source
VideoIO.libffmpeg.AVTreeNodeType

lavu_tree AVTree

lavu_data

Low-complexity tree container

Insertion, removal, finding equal, largest which is smaller than and smallest which is larger than, all have O(log n) worst-case complexity. @{

source
VideoIO.libffmpeg.AVVDPAUContextType
AVVDPAUContext

This structure is used to share data between the libavcodec library and the client video application. This structure will be allocated and stored in AVCodecContext.hwaccel_context by av_vdpau_bind_context(). Members can be set by the user once during initialization or through each AVCodecContext.get_buffer() function call. In any case, they must be valid prior to calling decoding functions.

The size of this structure is not a part of the public ABI and must not be used outside of libavcodec.

source
VideoIO.libffmpeg.AVVTFramesContextType
AVVTFramesContext

``

An API-specific header for AV_HWDEVICE_TYPE_VIDEOTOOLBOX.

This API supports frame allocation using a native CVPixelBufferPool instead of an AVBufferPool.

If the API user sets a custom pool, AVHWFramesContext.pool must return AVBufferRefs whose data pointer is a CVImageBufferRef or CVPixelBufferRef. Note that the underlying CVPixelBuffer could be retained by OS frameworks depending on application usage, so it is preferable to let CoreVideo manage the pool using the default implementation.

Currently AVHWDeviceContext.hwctx are always NULL.

source
VideoIO.libffmpeg.SwsContextType
SwsContext

Main external API structure. New fields can be added to the end with minor version bumps. Removal, reordering and changes to existing fields require a major version bump. sizeof(SwsContext) is not part of the ABI.

source
VideoIO.libffmpeg.__JL_Ctag_68Type
__JL_Ctag_68

``

API-specific header for AV_HWDEVICE_TYPE_DRM.

Internal frame allocation is not currently supported - all frames must be allocated by the user. Thus AVHWFramesContext is always NULL, though this may change if support for frame allocation is added in future.

source
VideoIO.libffmpeg.__JL_Ctag_71Type
__JL_Ctag_71

``

API-specific header for AV_HWDEVICE_TYPE_VAAPI.

Dynamic frame pools are supported, but note that any pool used as a render target is required to be of fixed size in order to be be usable as an argument to vaCreateContext().

For user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs with the data pointer set to a VASurfaceID.

source
VideoIO.libffmpeg.__JL_Ctag_93Type
__JL_Ctag_93

Details about which channels are present in this layout. For AV_CHANNEL_ORDER_UNSPEC, this field is undefined and must not be used.

source
VideoIO.libffmpeg.__JL_Ctag_94Type
__JL_Ctag_94

An nbtiles sized array of offsets in pixels from the topleft edge of the canvas, indicating where each stream should be placed. It must be allocated with the [`avmalloc`](@ref)() family of functions.

  • demuxing: set by libavformat, must not be modified by the caller. - muxing: set by the caller before avformat_write_header().

Freed by libavformat in avformat_free_context().

source
VideoIO.libffmpeg.__JL_Ctag_96Type
__JL_Ctag_96

Additional fields may be added both here and in any structure included. If a codec's film grain structure differs slightly over another codec's, fields within may change meaning depending on the type.

source
VideoIO.libffmpeg.av_csp_eotf_functionType

Function pointer representing an ITU EOTF transfer for a given reference display configuration.

Arguments

  • Lw: The white point luminance of the display, in nits (cd/m^2).
  • Lb: The black point luminance of the display, in nits (cd/m^2).
source
VideoIO.libffmpeg.av_csp_trc_functionType

Function pointer representing a double -> double transfer function that performs either an OETF transfer function, or alternatively an inverse EOTF function (in particular, for SMPTE ST 2084 / PQ). This function inputs linear light, and outputs gamma encoded light.

See ITU-T H.273 for more information.

source
VideoIO.libffmpeg.av_tx_fnType

Function pointer to a function to perform the transform.

Note

Using a different context than the one allocated during av_tx_init() is not allowed.

The out and in arrays must be aligned to the maximum required by the CPU architecture unless the AV_TX_UNALIGNED flag was set in av_tx_init(). The stride must follow the constraints the transform type has specified.

Arguments

  • s: the transform context
  • out: the output array
  • in: the input array
  • stride: the input or output stride in bytes
source
VideoIO.libffmpeg.avfilter_action_funcType

A function pointer passed to the AVFilterGraph.execute callback to be executed multiple times, possibly in parallel.

Arguments

  • ctx: the filter context the job belongs to
  • arg: an opaque parameter passed through from AVFilterGraph.execute
  • jobnr: the index of the job being executed
  • nb_jobs: the total number of jobs

Returns

0 on success, a negative AVERROR on error

source
VideoIO.libffmpeg.avfilter_execute_funcType

A function executing multiple jobs, possibly in parallel.

Arguments

  • ctx: the filter context to which the jobs belong
  • func: the function to be called multiple times
  • arg: the argument to be passed to func
  • ret: a nb_jobs-sized array to be filled with return values from each invocation of func
  • nb_jobs: the number of jobs to execute

Returns

0 on success, a negative AVERROR on error

source
VideoIO.libffmpeg.ff_pad_helper_AVBPrintType
ff_pad_helper_AVBPrint

Buffer to print data progressively

The string buffer grows as necessary and is always 0-terminated. The content of the string is never accessed, and thus is encoding-agnostic and can even hold binary data.

Small buffers are kept in the structure itself, and thus require no memory allocation at all (unless the contents of the buffer is needed after the structure goes out of scope). This is almost as lightweight as declaring a local char buf[512].

The length of the string can go beyond the allocated size: the buffer is then truncated, but the functions still keep account of the actual total length.

In other words, AVBPrint.len can be greater than AVBPrint.size and records the total length of what would have been to the buffer if there had been enough memory.

Append operations do not need to be tested for failure: if a memory allocation fails, data stop being appended to the buffer, but the length is still updated. This situation can be tested with av_bprint_is_complete().

The AVBPrint.size_max field determines several possible behaviours: - size\_max = -1 (= UINT_MAX) or any large value will let the buffer be reallocated as necessary, with an amortized linear cost. - size\_max = 0 prevents writing anything to the buffer: only the total length is computed. The write operations can then possibly be repeated in a buffer with exactly the necessary size (using size\_init = size\_max = len + 1). - size\_max = 1 is automatically replaced by the exact size available in the structure itself, thus ensuring no dynamic memory allocation. The internal buffer is large enough to hold a reasonable paragraph of text, such as the current paragraph.

source

Constants

See Also