Package com.avpkit.core
AVPKit is a library that wraps the FFMPEG C library with a slightly simpler interface designed to be used safely from within Java (and eventually any garbage-collected. language).
Goals
The library's goals are:- Ease of Use: Provide the power of FFMPEG with an easier learning curve for Java developers.
- Safety: Run natively inside a Java Virtual Machine process, and minimize the odds of incorrect coding of native FFMPEG code causing crashes
- Portability: Write portable code that should run most places where FFMPEG can run
Features
And so we set out to do that with this package. As a result you'll find the following major features:| Goal | Feature | Description |
|---|---|---|
| Ease of Use | Simplied Interface | AVPKit introduces an object-oriented interface that is based on the FFMPEG interfaces, but with more self-documenting methods and full documentation. |
| Java Memory Management | AVPKit lets you pass objects to and from native code, but removes the need for you to worry about allocating and freeing memory. Instead, we let the Java Virtual machine do that*. | |
| Allow FFMPEG to read data from Java objects | Through the com.avpkit.core.io package you can extend
AVPKit to read raw bytes to, and write raw bytes to, any Java object
you want. That way you can directly integrate with anything, be in
Red5, Wowza, Adobe FMS... you name it. |
|
| Safety | Crash Protection | Our goal is to get to a stage where it is next to impossible for a developer using AVPKit to crash the JVM through incorrect use of FFMPEG native code. To that end, we do lots of error checking of calls to make sure you don't accidentally do something to make FFMPEG mad. |
| Full Test Suite | We developed AVPKit with a Test-Driven methodology, so in version one we come with over 200 different tests programs and hundreds more assertions. | |
| Memory Leak and Error Testing | We also developed AVPKit with a full fledged memory leaking framework (sorry, runs on Linux only). | |
| Automated Building | And to keep us honest, all of our tests are run on every checkin, and memory tests are done at least once per day. | |
| Portability | Linux 32 and 64 bit support | We're tested 32-bit but the code should work for 64-bit as well |
| Mac OS X Support. | If you're using 1.6 though you need to make sure you build a 64-bit version of AVPKit. We've tested 1.6 with a 64-bit AVPKit | |
| Windows 32 and 64 bit support | We're tested 32-bit but the code should work for 64-bit as well |
Creating AVPKit Objects
In general very few AVPKit Interfaces provide pure Java constructors (i.e. you can't create one using the Java "new" operator). Instead, they will provide a "make" method that you can use For example:IContainer.make()
How To Learn More
There's a lot to this library, and we hope to add more tutorials. But if you're itching to get started, see the source code forConverter for an example program that reads
files in one media format and converts to a new format, and the source code for
FileProtocolHandler for an example of an example Java object
that allows AVPKit (and FFMPEG) to read data to and from
arbitrary data sources.
Or, check out the contents of the com.avpkit.core.demos package
for some cool demos that show the AVPKit in action.
What if AVPKit Crashes the Virtual Machine?
We try really hard to make it hard for you to crash the Java virtual machine using AVPKit, but it can happen.If for some reason you are able to crash the JVM, we want to hear about it (even if it's your error). Send us mail: bugs (at) core.com
In general, when we have time to work on open source projects, fixing bugs that crash the JVM will take priority.
Java Memory Management
Even though you are actually accessing native objects from Java code, you can use these objects just like you would Java objects. The garbage collector will clean up for you.
That said, we do advise you to use close() methods if provided
(for example IContainer.close()). These
methods can free up resources (like file handles) for other
parts of the system.
In general, treat AVPKit objects like you would Hibernate data-base connections... use them, but close them when you don't need them.
Java Memory Management For Those Who Can't Mind Their Own Business
This section is for people who can't just take our word for something, and instead start to poke around and notice that everything derives fromRefCounted.
For those people, let's just say that you should effectively ignore that, and just use the objects like you would any other Java object.
Really. We mean that.
-
Interface Summary Interface Description AVPKitConstants Internal Only.IConfigurable Methods that implement this interface can be configuring using setProperty and getProperty methods, and exposeIPropertymeta data about their properties.ISimpleMediaFile This class contains meta-information about simple media files. -
Class Summary Class Description AVPKit Internal Only.AVPKitJNI Configuration A global configuration class for AVPKit.Converter An example class that shows how to use the AVPKit library to open, decode, re-sample, encode and write media files.GetSupportedCodecs Prints information about which codecs can be inserted into a container format.GetSuppportedCodecs Prints information about which codecs can be inserted into a container format.Global A collection of static functions that refer to the entire package (like version getters).IAudioResampler Used to resample {IAudioSamples} to different sample rates or number of channels.IAudioSamples A set of raw (decoded) samples, plus a timestamp for when to play those
samples relative to other items in a given {IContainer}.
The timestamp value in decoded data is always in Microseonds.IBufferSink IBufferSource ICodec A "key" to an {IStreamCoder} that tells it how to encode or decode data.
Use these objects to tell a IStreamCoder you want to use MP3 or NellyMoser
for example.IContainer A file (or network data source) that contains one or more {IStream}
objects of
audio and video data.IContainerFormat Specifies format information than can be used to configure
an {IContainer} for input or output.IError Maps from int return codes to defined Error values.IFilterChain IIndexEntry An index entry for a {IStream}.IMediaData The parent class of all media objects than can be gotten from an {IStream}.IMediaDataWrapper This class wraps an IMediaData object, but then allows you to set
new TimeStamps and TimeBases.
The underlying wrapped object's time stamps and time bases do not change.IMediaFilter IMetaData Get MetaData about a {IContainer} or {IStream}.IPacket Represents an encoded piece of data that can be placed in an {IContainer}
for a given {IStream} of data.IPixelFormat Information about how video data is formatted in an {IVideoPicture} object.
This specifies the color space and how many bits pixel data takes.IProperty Represents settable properties that effect how AVPKit objects
operate.IRational This class wraps represents a Rational number for the AVPKit.IStream Represents a stream of similar data (eg video) in a {IContainer}.IStreamCoder The work horse of the AVPKit: Takes {IPacket} data from an {IContainer}
(representing an {IStream}) and an {ICodec} and allows you to decode or encode
that data.ITimeValue Deprecated. .IVideoPicture Represents one raw (undecoded) picture in a video stream, plus a timestamp
for when to display that video picture relative to other items in a {IContainer}.IVideoResampler Converts {IVideoPicture} objects of a given width, height and format to a new
width, height or format.SimpleMediaFile An implementation ofISimpleMediaFile.TestAudioSamplesGenerator This class generates fake audio data that is an A-note (a sine-wave at 440hz).Utils A collection of useful utilities for creating blankIVideoPictureobjects and managing audio time stamp to sample conversions.Version Contains the version numbers for this library. -
Enum Summary Enum Description IAudioSamples.ChannelLayout IAudioSamples.Format The format we use to represent audio.ICodec.Capabilities Capability flagsICodec.ID These are the codecs this library currently supports.
These are based on FFMPEG Git versions with this HEAD:
6a97ba521558ce131fe839eed2d51ff745280e1dICodec.Type The different types of Codecs that can exist in the system.IContainer.Flags IContainer.Type The different types of Containers AVPKit supports.IContainerFormat.Flags IError.Type A set of errors that AVPKit knows about.IMetaData.Flags Different types of flags that can be passed to {IMetaData#getValue}IPixelFormat.Type Pixel format.IPixelFormat.YUVColorComponent IProperty.Flags IProperty.Search How to search options when looking for different values.IProperty.Type The different type of options that are supported by AVPKit.
Well, actually by FFMPEG, but you get the idea.IRational.Rounding IStream.Direction The direction this stream is going (based on the container).
If the container Container is opened in Container::READ mode
then this will be INBOUND.IStream.ParseType What types of parsing can we do on a call to
{IContainer#readNextPacket(IPacket)}IStreamCoder.CodecStandardsCompliance An enumeration of how strictly Codecs may follow the spec.
Not all settings follow these requirements, but some
experimental codecs require this flag to be set to use.
IStreamCoder.Direction The Direction in which this StreamCoder will work.IStreamCoder.Flags AVPKIT Flags that can be passed to the setFlag(Flags, bool) methodITimeValue.Unit IVideoPicture.FrameDataType IVideoPicture.PictType The different types of images that we can set.IVideoResampler.Feature Features that the VideoResampler may optionally support.