Home

avformatcloseinput

avformat_close_input is a function from FFmpeg’s libavformat library used to close an input format context that was previously opened with avformat_open_input or related calls. Its canonical name is avformat_close_input and its signature is void avformat_close_input(AVFormatContext **ps). The function takes the address of a pointer to an AVFormatContext and is responsible for freeing all resources associated with that input and for setting the pointer to NULL.

When invoked, avformat_close_input closes the underlying input (including any network or file IO), frees internal data

Usage generally follows opening the input, performing demuxing or stream analysis, and then cleaning up. A typical

Notes: avformat_close_input handles null and already-closed pointers gracefully; if ps or *ps is NULL, the function

structures
such
as
streams
and
metadata,
and
releases
the
AVFormatContext
itself.
It
ensures
that
resources
allocated
for
demuxing,
buffering,
and
format-specific
state
are
correctly
released,
preventing
memory
leaks
in
applications
that
process
media
files
or
streams.
pattern
is
to
declare
an
AVFormatContext
pointer,
call
avformat_open_input
to
initialize
it,
and
later
call
avformat_close_input
to
free
resources
and
reset
the
pointer
to
NULL.
After
the
call,
the
original
pointer
should
be
considered
invalid
until
reinitialized.
simply
returns.
This
function
is
the
recommended
cleanup
routine
for
input
contexts
created
with
FFmpeg’s
demuxing
APIs,
ensuring
that
all
associated
resources
are
released
in
a
safe
and
centralized
manner.