Class IContainerFormat
- java.lang.Object
-
- com.avpkit.ferry.RefCounted
-
- com.avpkit.core.IContainerFormat
-
public class IContainerFormat extends RefCounted
Specifies format information than can be used to configure
an {IContainer} for input or output.
Often times AVPKIT can guess the correct formats to put into
a given IContainer object, but sometimes it needs help. You
can allocate an IContainerFormat object and specify information about
input or output containers, and then pass this to IContainer.open(...)
to help us guess.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIContainerFormat.Flags
-
Field Summary
-
Fields inherited from class com.avpkit.ferry.RefCounted
swigCMemOwn
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIContainerFormat(long cPtr, boolean cMemoryOwn)Internal Only.protectedIContainerFormat(long cPtr, boolean cMemoryOwn, java.util.concurrent.atomic.AtomicLong ref)Internal Only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IContainerFormatcopyReference()Create a new IContainerFormat object that is actually referring to the exact same underlying native object.booleanequals(java.lang.Object obj)Compares two values, returning true if the underlying objects in native code are the same object.ICodec.IDestablishOutputCodecId(ICodec inputCodec)For a given input codec guess an ID supported by this IContainerFormat that might be good for encoding.ICodec.IDestablishOutputCodecId(ICodec.ID inputCodecId)For a given input codec id guess an ID supported by this IContainerFormat that might be good for encoding.ICodec.IDestablishOutputCodecId(ICodec.Type type)For a given output codec type guess the best codec for encoding into this container.ICodec.IDestablishOutputCodecId(ICodec.Type type, ICodec.ID inputCodecId)For a given input codec guess an ID supported by this IContainerFormat that might be good for encoding.static longgetCPtr(IContainerFormat obj)Internal Only.booleangetInputFlag(IContainerFormat.Flags flag)Get the input setting for the specified flag
intgetInputFlags()Get the input flags associated with this object.
java.lang.StringgetInputFormatLongName()Get the long name for the input format.java.lang.StringgetInputFormatShortName()Get the short name for the input format.static IContainerFormatgetInstalledInputFormat(int index)Return an object for the input format at the given index.
static java.util.Collection<IContainerFormat>getInstalledInputFormats()Return a collection of all input formats installed on this system.static IContainerFormatgetInstalledOutputFormat(int index)Return an object for the output format at the given index.
static java.util.Collection<IContainerFormat>getInstalledOutputFormats()Return a collection of all output formats installed on this system.longgetMyCPtr()Internal Only.static intgetNumInstalledInputFormats()Get the number of input formats this install can demultiplex (read)
from.
static intgetNumInstalledOutputFormats()Get the number of output formats this install can multiplex
(write) to.
ICodec.IDgetOutputCodecID(int index)Queries for a supported codec id from the list of codecs
that can be encoded into this ContainerFormat.
java.util.List<ICodec.ID>getOutputCodecsSupported()Returns a list of all codecs supported for this Object.intgetOutputCodecTag(int index)Queries for a supported codec tag from the list of codecs
that can be encoded into this ContainerFormat.intgetOutputCodecTag(ICodec.ID id)Get the 4-byte tag the container would output for
the given codec id.
ICodec.IDgetOutputDefaultAudioCodec()Get the default audio codec this container prefers, if known.
ICodec.IDgetOutputDefaultSubtitleCodec()Get the default subtitle codec this container prefers, if known.
ICodec.IDgetOutputDefaultVideoCodec()Get the default video codec this container prefers, if known.
java.lang.StringgetOutputExtensions()Get the filename extensions that this output format prefers
(most common first).
booleangetOutputFlag(IContainerFormat.Flags flag)Get the output setting for the specified flag
intgetOutputFlags()Get the output flags associated with this object.
java.lang.StringgetOutputFormatLongName()Get the long name for the output format.java.lang.StringgetOutputFormatMimeType()Get the mime type for the output format.java.lang.StringgetOutputFormatShortName()Get the short name for the output format.intgetOutputNumCodecsSupported()Gets the number of different codecs this container
can include for encoding.
This can be used as an upper bound when using the
{#getOutputCodecID(int)} and
{#getOutputCodecTag(int)}
methods to dynamically query the actual codecs.
java.util.List<java.lang.Integer>getOutputTagsSupported()Returns a list of all codec tags supported for this container.inthashCode()Get a hashable value for this object.booleanisCodecSupportedForOutput(ICodec.ID id)Returns true if this container format can output media
encoded with the given codec.
booleanisInput()Is this an input container format?
booleanisOutput()Is this an output container format?
static IContainerFormatmake()Create a new IContainerFormat object.
voidsetInputFlag(IContainerFormat.Flags flag, boolean value)Set the input flag.
voidsetInputFlags(int newFlags)Set the input flags to use with this object.intsetInputFormat(java.lang.String shortName)Sets the input format for this container.
voidsetOutputFlag(IContainerFormat.Flags flag, boolean value)Set the output flag.
voidsetOutputFlags(int newFlags)Set the output flags to use with this object.intsetOutputFormat(java.lang.String shortName, java.lang.String url, java.lang.String mimeType)Sets the output format for this container.
We'll look at the shortName, url and mimeType and try to guess
a valid output container format.
java.lang.StringtoString()info about this format object-
Methods inherited from class com.avpkit.ferry.RefCounted
acquire, delete, getCPtr, getCurrentRefCount, getJavaRefCount, release
-
-
-
-
Constructor Detail
-
IContainerFormat
protected IContainerFormat(long cPtr, boolean cMemoryOwn)
Internal Only.
-
IContainerFormat
protected IContainerFormat(long cPtr, boolean cMemoryOwn, java.util.concurrent.atomic.AtomicLong ref)
Internal Only.
-
-
Method Detail
-
getCPtr
public static long getCPtr(IContainerFormat obj)
Internal Only. Not part of public API. Get the raw value of the native object that obj is proxying for.- Parameters:
obj- The java proxy object for a native object.- Returns:
- The raw pointer obj is proxying for.
-
getMyCPtr
public long getMyCPtr()
Internal Only. Not part of public API. Get the raw value of the native object that we're proxying for.- Overrides:
getMyCPtrin classRefCounted- Returns:
- The raw pointer we're proxying for.
-
copyReference
public IContainerFormat copyReference()
Create a new IContainerFormat object that is actually referring to the exact same underlying native object.- Overrides:
copyReferencein classRefCounted- Returns:
- the new Java object.
-
equals
public boolean equals(java.lang.Object obj)
Compares two values, returning true if the underlying objects in native code are the same object. That means you can have two different Java objects, but when you do a comparison, you'll find out they are the EXACT same object.- Overrides:
equalsin classjava.lang.Object- Returns:
- True if the underlying native object is the same. False otherwise.
-
hashCode
public int hashCode()
Get a hashable value for this object.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashable value.
-
toString
public java.lang.String toString()
info about this format object- Overrides:
toStringin classjava.lang.Object- Returns:
- information about this object
-
getOutputCodecsSupported
public java.util.List<ICodec.ID> getOutputCodecsSupported()
Returns a list of all codecs supported for this Object.If this object hasn't been set up for output, then we return null.
- Returns:
- A list of supported codecs, in decreasing preferred order.
- Since:
- 3.1
-
getOutputTagsSupported
public java.util.List<java.lang.Integer> getOutputTagsSupported()
Returns a list of all codec tags supported for this container.If this object hasn't been set up for output, then we return null.
- Returns:
- A list of supported codec tags, in decreasing preferred order.
- Since:
- 3.3
-
getInstalledInputFormats
public static java.util.Collection<IContainerFormat> getInstalledInputFormats()
Return a collection of all input formats installed on this system.- Returns:
- the list.
-
getInstalledOutputFormats
public static java.util.Collection<IContainerFormat> getInstalledOutputFormats()
Return a collection of all output formats installed on this system.- Returns:
- the list.
-
establishOutputCodecId
public ICodec.ID establishOutputCodecId(ICodec.Type type)
For a given output codec type guess the best codec for encoding into this container.- Parameters:
type- the codec type- Returns:
- the best guess output codec ID
- Throws:
java.lang.IllegalArgumentException- if type is null orisOutput()is false.java.lang.UnsupportedOperationException- if we cannot establish a codec.- See Also:
establishOutputCodecId(com.avpkit.core.ICodec.Type, com.avpkit.core.ICodec.ID)
-
establishOutputCodecId
public ICodec.ID establishOutputCodecId(ICodec.ID inputCodecId)
For a given input codec id guess an ID supported by this IContainerFormat that might be good for encoding.- Parameters:
inputCodecId- the input codec id- Returns:
- the best guess output codec ID
- Throws:
java.lang.IllegalArgumentException- if inputCodec is null orisOutput()is false.java.lang.UnsupportedOperationException- if we cannot establish a codec.- See Also:
establishOutputCodecId(com.avpkit.core.ICodec.Type, com.avpkit.core.ICodec.ID)
-
establishOutputCodecId
public ICodec.ID establishOutputCodecId(ICodec inputCodec)
For a given input codec guess an ID supported by this IContainerFormat that might be good for encoding.- Parameters:
inputCodec- the input codec- Returns:
- the best guess output codec ID
- Throws:
java.lang.IllegalArgumentException- if inputCodec is null orisOutput()is false.java.lang.UnsupportedOperationException- if we cannot establish a codec.- See Also:
establishOutputCodecId(com.avpkit.core.ICodec.Type, com.avpkit.core.ICodec.ID)
-
establishOutputCodecId
public ICodec.ID establishOutputCodecId(ICodec.Type type, ICodec.ID inputCodecId)
For a given input codec guess an ID supported by this IContainerFormat that might be good for encoding.For example, if the input codec ID was
ICodec.ID#CODEC_ID_FLACand you were trying to encoding into an "FLV" file that doesn't support that codec for outputting, this method will instead suggestICodec.ID#CODEC_ID_MP3instead.The algorithm followed is:
- If the container has a preferred codec for the given codec type, use that; else
- If the input codec can be used for encoding into this container, and is installed on this system, use that; else
- Query the container format to see what other formats it can support, and are installed on this system, and choose the first one that will work; else
- Throw an
UnsupportedOperationException.
This method relies on FFMPEGs internal database of codec IDs to identify the correct output codec IDs that can fit in this container.
- Parameters:
type- the type of codec desiredinputCodecId- an input codec id to attempt to match, or null if none.- Returns:
- the best guess output codec ID
- Throws:
java.lang.IllegalArgumentException- if inputCodecId is null or equal toICodec.ID#CODEC_ID_NONE, orisOutput()is false.java.lang.UnsupportedOperationException- if we cannot establish a codec.
-
setInputFormat
public int setInputFormat(java.lang.String shortName)
Sets the input format for this container.
- Parameters:
shortName- The short name for this container (using FFMPEG's
short name).- Returns:
- >= 0 on success. < 0 if shortName cannot be found.
-
setOutputFormat
public int setOutputFormat(java.lang.String shortName, java.lang.String url, java.lang.String mimeType)
Sets the output format for this container.
We'll look at the shortName, url and mimeType and try to guess
a valid output container format.
- Parameters:
shortName- The short name for this container (using FFMPEG's
short name).url- The URL for this container.mimeType- The mime type for this container.- Returns:
- >= 0 on success. < 0 if we cannot find a good container.
-
getInputFormatShortName
public java.lang.String getInputFormatShortName()
Get the short name for the input format.- Returns:
- The short name for the input format, or null if none.
-
getInputFormatLongName
public java.lang.String getInputFormatLongName()
Get the long name for the input format.- Returns:
- The long name for the input format, or null if none.
-
getOutputFormatShortName
public java.lang.String getOutputFormatShortName()
Get the short name for the output format.- Returns:
- The short name for the output format, or null if none.
-
getOutputFormatLongName
public java.lang.String getOutputFormatLongName()
Get the long name for the output format.- Returns:
- The long name for the output format, or null if none.
-
getOutputFormatMimeType
public java.lang.String getOutputFormatMimeType()
Get the mime type for the output format.- Returns:
- The mime type for the output format, or null if none.
-
make
public static IContainerFormat make()
Create a new IContainerFormat object.
- Returns:
- a new object, or null on error.
-
getInputFlags
public int getInputFlags()
Get the input flags associated with this object.
- Returns:
- The (compacted) value of all flags set.
-
setInputFlags
public void setInputFlags(int newFlags)
Set the input flags to use with this object. All values
must be ORed (|) together.
- Parameters:
newFlags- The new set flags for this codec.- See Also:
Flags
-
getInputFlag
public boolean getInputFlag(IContainerFormat.Flags flag)
Get the input setting for the specified flag
- Parameters:
flag- The flag you want to find the setting for
- Returns:
- 0 for false; non-zero for true
-
setInputFlag
public void setInputFlag(IContainerFormat.Flags flag, boolean value)
Set the input flag.
- Parameters:
flag- The flag to setvalue- The value to set it to (true or false)
-
getOutputFlags
public int getOutputFlags()
Get the output flags associated with this object.
- Returns:
- The (compacted) value of all flags set.
-
setOutputFlags
public void setOutputFlags(int newFlags)
Set the output flags to use with this object. All values
must be ORed (|) together.
- Parameters:
newFlags- The new set flags for this codec.- See Also:
Flags
-
getOutputFlag
public boolean getOutputFlag(IContainerFormat.Flags flag)
Get the output setting for the specified flag
- Parameters:
flag- The flag you want to find the setting for
- Returns:
- 0 for false; non-zero for true
-
setOutputFlag
public void setOutputFlag(IContainerFormat.Flags flag, boolean value)
Set the output flag.
- Parameters:
flag- The flag to setvalue- The value to set it to (true or false)
-
isOutput
public boolean isOutput()
Is this an output container format?
- Returns:
- true if output; false it not
-
isInput
public boolean isInput()
Is this an input container format?
- Returns:
- true if input; false it not
-
getOutputExtensions
public java.lang.String getOutputExtensions()
Get the filename extensions that this output format prefers
(most common first).
- Returns:
- a command separated string of output extensions, or
null if none.
-
getOutputDefaultAudioCodec
public ICodec.ID getOutputDefaultAudioCodec()
Get the default audio codec this container prefers, if known.
- Returns:
- the default audio codec id, or {ICodec.ID#CODEC_ID_NONE}
if unknown.
-
getOutputDefaultVideoCodec
public ICodec.ID getOutputDefaultVideoCodec()
Get the default video codec this container prefers, if known.
- Returns:
- the default video codec id, or {ICodec.ID#CODEC_ID_NONE}
if unknown.
-
getOutputDefaultSubtitleCodec
public ICodec.ID getOutputDefaultSubtitleCodec()
Get the default subtitle codec this container prefers, if known.
- Returns:
- the default subtitle codec id, or {ICodec.ID#CODEC_ID_NONE}
if unknown.
-
getOutputNumCodecsSupported
public int getOutputNumCodecsSupported()
Gets the number of different codecs this container
can include for encoding.
This can be used as an upper bound when using the
{#getOutputCodecID(int)} and
{#getOutputCodecTag(int)}
methods to dynamically query the actual codecs.
- Returns:
- The total number of different codec types that can
be encoded into this container format.
-
getOutputCodecID
public ICodec.ID getOutputCodecID(int index)
Queries for a supported codec id from the list of codecs
that can be encoded into this ContainerFormat.
- Parameters:
index- The index in our lookup table. Index >= 0 and
< {#getOutputNumCodecsSupported()}. Index values may
change between releases, so always query.
- Returns:
- The codec id at this position, or
{ICodec.ID#CODEC_ID_NONE}
if there is none.
-
getOutputCodecTag
public int getOutputCodecTag(int index)
Queries for a supported codec tag from the list of codecs
that can be encoded into this ContainerFormat.
Tags are 4-byte values that are often used as markers
in a container format for a codec type.
- Parameters:
index- The index in our lookup table. Index >= 0 and
< {#getOutputNumCodecsSupported()}. Index values may
change between releases, so always query.
- Returns:
- The codec id tag this position, or 0 if there is none.
-
getOutputCodecTag
public int getOutputCodecTag(ICodec.ID id)
Get the 4-byte tag the container would output for
the given codec id.
- Parameters:
id- the codec you are about
- Returns:
- the 4-byte codec tag, or 0 if that id is not
supported.
-
isCodecSupportedForOutput
public boolean isCodecSupportedForOutput(ICodec.ID id)
Returns true if this container format can output media
encoded with the given codec.
- Parameters:
id- the codec you care about.
- Returns:
- true if the codec can be put in this output container;
false otherwise.
-
getNumInstalledInputFormats
public static int getNumInstalledInputFormats()
Get the number of input formats this install can demultiplex (read)
from.
- Returns:
- the number of formats
-
getInstalledInputFormat
public static IContainerFormat getInstalledInputFormat(int index)
Return an object for the input format at the given index.
- Parameters:
index- an index for the input format list we maintain
- Returns:
- a format object for that input or null if
unknown, index < 0 or index >= {#getNumInstalledInputFormats()}
-
getNumInstalledOutputFormats
public static int getNumInstalledOutputFormats()
Get the number of output formats this install can multiplex
(write) to.
- Returns:
- the number of formats
-
getInstalledOutputFormat
public static IContainerFormat getInstalledOutputFormat(int index)
Return an object for the output format at the given index.
- Parameters:
index- an index for the output format list we maintain
- Returns:
- a format object for that output or null if
unknown, index < 0 or index >= {#getNumInstalledOutputFormats()}
-
-