Libav libavformat HOWTO: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
: ''This page will hold information on how libavformat is structured an how to add demuxer and protocols to it'' | |||
: ''please make this page more complete if you can, thanks'' | : ''please make this page more complete if you can, thanks'' | ||
Revision as of 19:34, 15 November 2011
- This page will hold information on how libavformat is structured an how to add demuxer and protocols to it
- please make this page more complete if you can, thanks
Demuxer structure
Protocol structure
Introducing a new demuxer or a new protocol
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, a protocol provides an I/O abstraction to network or system storage.
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
Demuxer specific
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.
Protocol specific
The convention regarding the file structure is to use use directly the protocol name, so for a protocol named name, name.c. If the protocol is tightly bound to a specific demuxer or could be mismatched is advised to use nameproto.c (e.g. rtmpproto.c)
Add
OBJS-$(CONFIG_NAME_PROTOCOL) += nameproto.o
to the Makefile in order to build.
libavformat/allformats.c
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 .
Demuxer specific
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 add ff_name_demuxer or/and ff_name_muxer to the available formats.
Protocol specific
In order to add a protoco:
REGISTER_PROTOCOL(NAME, name)
The macro will add ff_name_protocol to the available protocols.
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