FFmpeg
Modules | Functions
Setting and modifying option values

Modules

 Option setting functions
 Those functions set the field of obj with the given name to value.
 

Functions

int av_set_options_string (void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
 Parse the key/value pairs list in opts. More...
 
int av_opt_set_from_string (void *ctx, const char *opts, const char *const *shorthand, const char *key_val_sep, const char *pairs_sep)
 Parse the key-value pairs list in opts. More...
 
int av_opt_set_dict (void *obj, struct AVDictionary **options)
 Set all the options from a given dictionary on an object. More...
 
int av_opt_set_dict2 (void *obj, struct AVDictionary **options, int search_flags)
 Set all the options from a given dictionary on an object. More...
 
int av_opt_copy (void *dest, const void *src)
 Copy options from src object into dest object. More...
 

Detailed Description

Function Documentation

◆ av_set_options_string()

int av_set_options_string ( void *  ctx,
const char *  opts,
const char *  key_val_sep,
const char *  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.

Parameters
optsoptions string to parse, may be NULL
key_val_sepa 0-terminated list of characters used to separate key from value
pairs_sepa 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

Definition at line 1776 of file opt.c.

Referenced by avfilter_graph_segment_create_filters(), command(), ff_stream_add_bitstream_filter(), and main().

◆ av_opt_set_from_string()

int av_opt_set_from_string ( void *  ctx,
const char *  opts,
const char *const *  shorthand,
const char *  key_val_sep,
const char *  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.

Parameters
ctxthe AVClass object to set options on
optsthe options string, key-value pairs separated by a delimiter
shorthanda 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_sepa 0-terminated list of characters used to separate key from value, for example '='
pairs_sepa 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

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.

Definition at line 1856 of file opt.c.

Referenced by bsf_list_append_internal(), dnn_load_model_tf(), dnn_load_model_th(), get_output_ov(), and main().

◆ av_opt_set_dict()

int av_opt_set_dict ( void *  obj,
struct AVDictionary **  options 
)

Set all the options from a given dictionary on an object.

Parameters
obja struct whose first element is a pointer to AVClass
optionsoptions 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()

Definition at line 1945 of file opt.c.

Referenced by avcodec_open2(), avformat_open_input(), avio_open_dir(), dynamic_set_parameter(), ff_http_do_new_request2(), ffurl_open_whitelist(), init_muxer(), of_parse_iamf_audio_element_layers(), of_parse_iamf_submixes(), and streamcopy_init().

◆ av_opt_set_dict2()

int av_opt_set_dict2 ( void *  obj,
struct AVDictionary **  options,
int  search_flags 
)

Set all the options from a given dictionary on an object.

Parameters
obja struct whose first element is a pointer to AVClass
optionsoptions 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_flagsA 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()

Definition at line 1921 of file opt.c.

Referenced by av_opt_set_dict(), avfilter_graph_segment_apply_opts(), avfilter_init_dict(), avformat_stream_group_create(), bsf_list_append_internal(), init_muxer(), list_devices_for_context(), and of_parse_iamf_submixes().

◆ av_opt_copy()

int av_opt_copy ( void *  dest,
const void *  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.

Parameters
destObject to copy from
srcObject to copy into
Returns
0 on success, negative on error

Definition at line 2105 of file opt.c.

Referenced by command(), config_props(), context_init_threaded(), ff_frame_thread_encoder_init(), ffurl_open_whitelist(), and init_thread().