Difference between revisions of "Libav libavformat HOWTO"

From MultimediaWiki
Jump to navigation Jump to search
(Introducing a new demuxer)
Line 3: Line 3:
 
== Introducing a new demuxer ==
 
== Introducing a new demuxer ==
  
In order to make available the new demuxer you have to edit libavformat/allformats.c and libavformat/Makefile.
+
A demuxer let the application access the codec data and metadata stored within a container, a muxer let you store codec data and metadata using the container format chosen.
 +
 
 +
In order to make available the new demuxer you have to edit '''libavformat/allformats.c''' and '''libavformat/Makefile'''.
 
The former holds a list of available demuxers and protocol and is parsed by configure to generate build system
 
The former holds a list of available demuxers and protocol and is parsed by configure to generate build system
 
variables for it, the latter keeps the actual build directives.
 
variables for it, the latter keeps the actual build directives.

Revision as of 20:26, 14 November 2011

please make this page more complete if you can, thanks

Introducing a new demuxer

A demuxer let the application access the codec data and metadata stored within a container, a muxer let you store codec data and metadata using the container format chosen.

In order to make available the new demuxer you have to edit libavformat/allformats.c and libavformat/Makefile. The former holds a list of available demuxers and protocol and is parsed by configure to generate build system variables for it, the latter keeps the actual build directives.

libavformat/Makefile

The convention regarding the file structure is to use, for a format named name, nameenc.c for muxer code and namedec.c for demuxer code, common code should go in name.c

Add

OBJS-$(CONFIG_NAME_MUXER)      += nameenc.o name.o
OBJS-$(CONFIG_NAME_DEMUXER)    += namedec.o name.o

to the Makefile in order to build the additional code.

libavformat/allformats.c

In order to add a demuxer:

REGISTER_DEMUXER(NAME, name)

In order to add a muxer:

REGISTER_MUXER(NAME, name)

In order to add muxer and demuxer in a single line:

REGISTER_MUXDEMU(NAME, name)

The macro will register ff_name_demuxer or/and ff_name_muxer to the available formats.

Modifying allformats.c will trigger a build system warning:

Run configure in the top level directory and make clean, as config.h will be automatically modified.

It is advised to run:

make clean
make configure
make

In order to build the new code. Make sure you properly edited Makefile and allformats.c .

Introducing a new protocol

Protocols let you access container formats through any kind of storage or delivery system, being that a filesystem access (e.g. pipe, file), a low level network protocol (tcp, udp) or a application level protocol (rtmp, http, tls)

libavformat/Makefile

libavformat/allformats.c

Example code

This section is merely an overview; please look at an actual demuxer for a more in depth and up to date example. libavformat/avformat.h shows the different structure of a muxer (AVOutputFormat) and a demuxer (AVInputFormat)

WIP