Package com.wowza.util
Class FLVUtils
- Object
- 
- com.wowza.util.FLVUtils
 
- 
 public final class FLVUtils extends ObjectFLVUtils: utility for reading and writing .flv files. 
- 
- 
Field SummaryFields Modifier and Type Field Description static Class<FLVUtils>CLASSstatic StringCLASSNAMEstatic intFLV_CHUNKHEADER_BUFFERSIZESize of temporary buffer needed for flv reading (byte[])static intFLV_CHUNKHEADER_FIRSTBYTEHeader values: first byte of packet datastatic intFLV_CHUNKHEADER_HEADERSIZESize of packet header (byte[])static intFLV_CHUNKHEADER_ISIZEHeader values: packet sizestatic intFLV_CHUNKHEADER_ITIMECODEHeader values: timecode (milliseconds)static intFLV_CHUNKHEADER_ITYPEHeaeder values: packet typestatic intFLV_CHUNKHEADER_SECONDBYTEHeader values: second byte of packet datastatic intFLV_CHUNKHEADER_VALUESIZESize of header values array (long[])static intFLV_DFRAMED video frame type (partial frame based on key frame)static intFLV_KFRAMEKey video frame typestatic intFLV_PFRAMEP video frame type (partial frame based on previous frame)static intFLV_TCINDEXAUDIOstatic intFLV_TCINDEXDATAstatic intFLV_TCINDEXVIDEOstatic intFLV_UFRAMEUnknown video frame typestatic longMETADATAFILTER_NONEstatic longMETADATAFILTER_REMOVE_OBJS
 - 
Constructor SummaryConstructors Constructor Description FLVUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static longadjustFirstPacketTCs(java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs)Align list of timecode for each data type.static intaudioCodecStringToId(String codecString)Parse a string to get the codec ID defined by IVHost.CODEC_AUDIO_*static StringaudioCodecToMetaDataString(int codec)Get a printable string representation of the audio codecs defined as IVHost.CODEC_AUDIO_* as the string used in the onMetaData eventstatic StringaudioCodecToString(int codec)Get a printable string representation of the audio codecs defined as IVHost.CODEC_AUDIO_*static StringframeTypeToString(int frameType)static intgetAudioCodec(int value)Return the codec portion of the first byte of an audio packet.static intgetAudioCodec(AMFPacket packet)Get the codec id for this audio packet.static intgetAudioMP3Layer(AMFPacket packet)Audio marked as MP3 is really MPEG1 Layer 1-3.static intgetFrameType(byte value)Given the first byte of a video packet, determine the frame type (FLV_*FRAME)static intgetFrameType(int value)Given the first byte of a video packet, determine the frame type (FLV_*FRAME)static intgetFrameType(int[] values)Given the headers values (including first byte of the packet), determine the type of video frame (FLV_*FRAME)static bytegetHeaderFlags(java.io.File file)static longgetLastTC(java.io.File file)Get the duration of an .flv file.static OnMetadataBasicgetOnMetadataData(AMFPacket metaDataPacket)static intgetPtsOffSetFromDts(byte[] buffer)Get the timecode offset in milliseconds between the PTS and DTS for this frame.static intgetPtsOffSetFromDts(AMFPacket packet)Get the timecode offset in milliseconds between the PTS and DTS for this frame.static intgetVideoCodec(int value)Return the codec portion of the first byte of an video packet.static intgetVideoCodec(AMFPacket packet)Get the codec id for this video packet.static intgetVideoFrameType(AMFPacket packet)static intgetVideoTimecodeOffset(byte[] buffer)Get the timecode offset in milliseconds between the PTS and DTS for this frame.static intgetVideoTimecodeOffset(AMFPacket packet)Get the timecode offset in milliseconds between the PTS and DTS for this frame.static java.util.ListinterleavePackets(java.util.List audioPackets, java.util.List videoPackets, java.util.List dataPackets, java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs, long[] currentTCs)This is a utility function primarily used for IMediaWriters.static java.util.List<AMFPacket>interleavePackets(java.util.List audioPackets, java.util.List videoPackets, java.util.List dataPackets, java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs, java.util.List dataTypes, long[] currentTCs)This is a utility function primarily used for IMediaWriters.static booleanisAudioCodecConfig(AMFPacket packet)Returns true if the packet is a audio codec config packetstatic booleanisAudioCodecConfig(java.nio.ByteBuffer buffer)Returns true if the packet is a audio codec config packetstatic booleanisOnMetadata(byte[] dataDataBytes)static booleanisOnMetadataPacket(AMFPacket packet)Returns true if packet is onMetaData or [@setDataFrame, onMetaData] data packet.static booleanisVideoCodecConfig(int firstByte, int secondByte)Returns true if the packet is a video codec config packetstatic booleanisVideoCodecConfig(AMFPacket packet)Returns true if the packet is a video codec config packetstatic booleanisVideoCodecConfig(java.nio.ByteBuffer buffer)Returns true if the packet is a video codec config packetstatic booleanisVideoKeyFrame(byte[] buffer)Returns true if the packet is a video key framestatic booleanisVideoKeyFrame(int[] chunkHeaderValues)Returns true if the packet is a video key framestatic booleanisVideoKeyFrame(AMFPacket packet)Returns true if the packet is a video key framestatic booleanisVideoKeyFrame(java.nio.ByteBuffer buffer)Returns true if the packet is a video key framestatic byte[]modifyOnMetadataEvent(byte[] buffer, long flags, java.util.List<String> itemsToRemove, java.util.Map<String,AMFData> itemsToAdd)Modifies onMetadata event to remove or add itemsstatic AMFPacketreadChunk(java.io.DataInput is)Read a packets worth of .flv data from an InputStream and return as an AMFPacketstatic AMFPacketreadChunk(java.io.InputStream is)Read a packets worth of .flv data from an InputStream and return as an AMFPacketstatic voidreadChunkHeader(java.io.RandomAccessFile is, byte[] buffer, int[] values)Read packet header.static booleanreadHeader(java.io.DataInput is)Read file header.static booleanreadHeader(java.io.InputStream is)Read file header.static voidreadPrevChunkHeader(java.io.RandomAccessFile is, byte[] buffer, int[] values)Back up one packet from current position in the file and read the packet header.static StringstreamCodecToString(int codec)Get a printable string representation of the stream codecs defined as IVHost.CODEC_STREAM_*static AMFPacketupdateOnCuePointTimecode(AMFPacket packet, long timecode)static java.nio.ByteBufferupdateOnCuePointTimecode(java.nio.ByteBuffer data, int dataType, long timecode)static intvideoCodecStringToCodecVersion(String codecString)Parse a string to get the codec version defined by IVHost.CODEC_VIDEO_VERSION_*static intvideoCodecStringToId(String codecString)Parse a string to get the codec ID defined by IVHost.CODEC_VIDEO_*static StringvideoCodecToMetaDataString(int codec)Get a printable string representation of the video codecs defined as IVHost.CODEC_VIDEO_* as the string used in the onMetaData eventstatic StringvideoCodecToMetaDataString(int codec, int codecVersion)Get a printable string representation of the video codecs defined as IVHost.CODEC_VIDEO_* as the string used in the onMetaData eventstatic StringvideoCodecToString(int codec)Get a printable string representation of the video codecs defined as IVHost.CODEC_VIDEO_*static StringvideoCodecToString(int codec, int codecVersion)static com.wowza.wms.mediawriter.MediaWriterStatuswriteChunk(java.io.DataOutput ds, java.nio.ByteBuffer data, int size, long timecode, byte type)static com.wowza.wms.mediawriter.MediaWriterStatuswriteChunk(java.io.OutputStream ds, java.nio.ByteBuffer data, int size, long timecode, byte type)Write a packets worth of data.static voidwriteDuration(java.io.File file, double duration)Write the duration to an existing .flv file.static voidwriteHeader(java.io.OutputStream ds, double duration, int audiocodecid, int videocodecid, String createdBy, java.util.Map extraMetadata)Write file header including onMetaData packet.static voidwriteHeader(java.io.OutputStream ds, double duration, java.util.Map extraMetadata)Write file header including onMetaData packet.static voidwriteHeaderFlags(java.io.File file, byte newFlags)static voidwritePackets(java.io.OutputStream ds, java.util.List packetList, long tcOffset)Write audio/video/data packets to an .flv file.static voidwritePackets(java.io.OutputStream ds, java.util.List audioPackets, java.util.List videoPackets, java.util.List dataPackets, java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs, long[] currentTCs)Write a bunch of packets to .flv file all at once.static voidwritePackets(java.io.OutputStream ds, java.util.List audioPackets, java.util.List videoPackets, java.util.List dataPackets, java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs, java.util.List dataTypes, long[] currentTCs)Write a bunch of packets to .flv file all at once.static voidwritePackets(java.io.OutputStream ds, java.util.List audioPackets, java.util.List videoPackets, java.util.List dataPackets, java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs, java.util.List dataTypes, long[] currentTCs, com.wowza.util.IFLVWriterAdjustTimecode dataPacketTimecodeAdjuster)Write a bunch of packets to .flv file all at once.static voidwriteShortHeader(java.io.DataOutput ds)static voidwriteShortHeader(java.io.OutputStream ds)Write just the FLV file header (without the metadata packet)
 
- 
- 
- 
Field Detail- 
CLASSpublic static final Class<FLVUtils> CLASS 
 - 
CLASSNAMEpublic static final String CLASSNAME - See Also:
- Constant Field Values
 
 - 
FLV_CHUNKHEADER_ITYPEpublic static final int FLV_CHUNKHEADER_ITYPE Heaeder values: packet type- See Also:
- Constant Field Values
 
 - 
FLV_CHUNKHEADER_ISIZEpublic static final int FLV_CHUNKHEADER_ISIZE Header values: packet size- See Also:
- Constant Field Values
 
 - 
FLV_CHUNKHEADER_ITIMECODEpublic static final int FLV_CHUNKHEADER_ITIMECODE Header values: timecode (milliseconds)- See Also:
- Constant Field Values
 
 - 
FLV_CHUNKHEADER_FIRSTBYTEpublic static final int FLV_CHUNKHEADER_FIRSTBYTE Header values: first byte of packet data- See Also:
- Constant Field Values
 
 - 
FLV_CHUNKHEADER_SECONDBYTEpublic static final int FLV_CHUNKHEADER_SECONDBYTE Header values: second byte of packet data- See Also:
- Constant Field Values
 
 - 
FLV_CHUNKHEADER_HEADERSIZEpublic static final int FLV_CHUNKHEADER_HEADERSIZE Size of packet header (byte[])- See Also:
- Constant Field Values
 
 - 
FLV_CHUNKHEADER_BUFFERSIZEpublic static final int FLV_CHUNKHEADER_BUFFERSIZE Size of temporary buffer needed for flv reading (byte[])- See Also:
- Constant Field Values
 
 - 
FLV_CHUNKHEADER_VALUESIZEpublic static final int FLV_CHUNKHEADER_VALUESIZE Size of header values array (long[])- See Also:
- Constant Field Values
 
 - 
FLV_UFRAMEpublic static final int FLV_UFRAME Unknown video frame type- See Also:
- Constant Field Values
 
 - 
FLV_KFRAMEpublic static final int FLV_KFRAME Key video frame type- See Also:
- Constant Field Values
 
 - 
FLV_DFRAMEpublic static final int FLV_DFRAME D video frame type (partial frame based on key frame)- See Also:
- Constant Field Values
 
 - 
FLV_PFRAMEpublic static final int FLV_PFRAME P video frame type (partial frame based on previous frame)- See Also:
- Constant Field Values
 
 - 
FLV_TCINDEXAUDIOpublic static final int FLV_TCINDEXAUDIO - See Also:
- Constant Field Values
 
 - 
FLV_TCINDEXVIDEOpublic static final int FLV_TCINDEXVIDEO - See Also:
- Constant Field Values
 
 - 
FLV_TCINDEXDATApublic static final int FLV_TCINDEXDATA - See Also:
- Constant Field Values
 
 - 
METADATAFILTER_NONEpublic static final long METADATAFILTER_NONE - See Also:
- Constant Field Values
 
 - 
METADATAFILTER_REMOVE_OBJSpublic static final long METADATAFILTER_REMOVE_OBJS - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
streamCodecToStringpublic static String streamCodecToString(int codec) Get a printable string representation of the stream codecs defined as IVHost.CODEC_STREAM_*- Parameters:
- codec- codec id defined IVHost.CODEC_STREAM_*
- Returns:
- codec name
 
 - 
audioCodecStringToIdpublic static int audioCodecStringToId(String codecString) Parse a string to get the codec ID defined by IVHost.CODEC_AUDIO_*- Parameters:
- codecString- codec string
- Returns:
- codec ID
 
 - 
videoCodecToMetaDataStringpublic static String videoCodecToMetaDataString(int codec) Get a printable string representation of the video codecs defined as IVHost.CODEC_VIDEO_* as the string used in the onMetaData event- Parameters:
- codec- codec id defined IVHost.CODEC_VIDEO_*
- Returns:
- codec name
 
 - 
videoCodecToMetaDataStringpublic static String videoCodecToMetaDataString(int codec, int codecVersion)Get a printable string representation of the video codecs defined as IVHost.CODEC_VIDEO_* as the string used in the onMetaData event- Parameters:
- codec- codec id defined IVHost.CODEC_VIDEO_*
- codecVersion- codec version
- Returns:
- metadata string
 
 - 
audioCodecToMetaDataStringpublic static String audioCodecToMetaDataString(int codec) Get a printable string representation of the audio codecs defined as IVHost.CODEC_AUDIO_* as the string used in the onMetaData event- Parameters:
- codec- codec id defined IVHost.CODEC_AUDIO_*
- Returns:
- codec name
 
 - 
audioCodecToStringpublic static String audioCodecToString(int codec) Get a printable string representation of the audio codecs defined as IVHost.CODEC_AUDIO_*- Parameters:
- codec- codec id defined IVHost.CODEC_AUDIO_*
- Returns:
- codec name
 
 - 
videoCodecStringToCodecVersionpublic static int videoCodecStringToCodecVersion(String codecString) Parse a string to get the codec version defined by IVHost.CODEC_VIDEO_VERSION_*- Parameters:
- codecString-
- Returns:
- codec version string
 
 - 
videoCodecStringToIdpublic static int videoCodecStringToId(String codecString) Parse a string to get the codec ID defined by IVHost.CODEC_VIDEO_*- Parameters:
- codecString- codec string
- Returns:
- codec ID
 
 - 
videoCodecToStringpublic static String videoCodecToString(int codec) Get a printable string representation of the video codecs defined as IVHost.CODEC_VIDEO_*- Parameters:
- codec- codec id defined IVHost.CODEC_VIDEO_*
- Returns:
- codec name
 
 - 
videoCodecToStringpublic static String videoCodecToString(int codec, int codecVersion)
 - 
frameTypeToStringpublic static String frameTypeToString(int frameType) 
 - 
getFrameTypepublic static int getFrameType(int[] values) Given the headers values (including first byte of the packet), determine the type of video frame (FLV_*FRAME)- Parameters:
- values- header values
- Returns:
- type of video frame (FLV_*FRAME)
 
 - 
getFrameTypepublic static int getFrameType(int value) Given the first byte of a video packet, determine the frame type (FLV_*FRAME)- Parameters:
- value- first byte of packet
- Returns:
- type of video frame (FLV_*FRAME)
 
 - 
getAudioCodecpublic static int getAudioCodec(int value) Return the codec portion of the first byte of an audio packet. Return should be one of IVHost.CODEC_AUDIO_*- Parameters:
- value- first byte of audio packet
- Returns:
- codec id
 
 - 
getVideoCodecpublic static int getVideoCodec(int value) Return the codec portion of the first byte of an video packet. Return should be one of IVHost.CODEC_VIDEO_*- Parameters:
- value- first byte of audio packet
- Returns:
- codec id
 
 - 
getFrameTypepublic static int getFrameType(byte value) Given the first byte of a video packet, determine the frame type (FLV_*FRAME)- Parameters:
- value- first byte of packet
- Returns:
- type of video frame (FLV_*FRAME)
 
 - 
readChunkpublic static AMFPacket readChunk(java.io.InputStream is) Read a packets worth of .flv data from an InputStream and return as an AMFPacket- Parameters:
- is- InputStream
- Returns:
- AMFPacket of data or null if unsuccessful or end of file
 
 - 
readChunkpublic static AMFPacket readChunk(java.io.DataInput is) Read a packets worth of .flv data from an InputStream and return as an AMFPacket- Parameters:
- is- InputStream
- Returns:
- AMFPacket of data or null if unsuccessful or end of file
 
 - 
readPrevChunkHeaderpublic static void readPrevChunkHeader(java.io.RandomAccessFile is, byte[] buffer, int[] values)Back up one packet from current position in the file and read the packet header. This includes reading the first byte of the packet data. The file pointer will be positioned at the first byte of the packet data. values[FLV_CHUNKHEADER_ITYPE] will be set to 0x7f if failure or start of file.- Parameters:
- is- RandomAccessFile
- buffer- temporary buffer byte[FLV_CHUNKHEADER_BUFFERSIZE]
- values- header values long[FLV_CHUNKHEADER_VALUESIZE]
 
 - 
readChunkHeaderpublic static void readChunkHeader(java.io.RandomAccessFile is, byte[] buffer, int[] values)Read packet header. This includes reading the first byte of the packet data. The file pointer will be positioned at the first byte of the packet data. values[FLV_CHUNKHEADER_ITYPE] will be set to 0x7f if failure or end of file.- Parameters:
- is- RandomAccessFile
- buffer- temporary buffer byte[FLV_CHUNKHEADER_BUFFERSIZE]
- values- header values long[FLV_CHUNKHEADER_VALUESIZE]
 
 - 
readHeaderpublic static boolean readHeader(java.io.InputStream is) Read file header. Return true if successful. Basically this just skips first 13 bytes in file.
 - 
readHeaderpublic static boolean readHeader(java.io.DataInput is) Read file header. Return true if successful. Basically this just skips first 13 bytes in file.
 - 
writeShortHeaderpublic static void writeShortHeader(java.io.OutputStream ds) Write just the FLV file header (without the metadata packet)- Parameters:
- ds- OutputStream
 
 - 
writeShortHeaderpublic static void writeShortHeader(java.io.DataOutput ds) 
 - 
writeHeaderpublic static void writeHeader(java.io.OutputStream ds, double duration, java.util.Map extraMetadata)Write file header including onMetaData packet.- Parameters:
- ds- OutputStream
- duration- duration of .flv file in seconds
- extraMetadata- Map of name/value pairs of metadata that will be appended to the onMetaData block
 
 - 
writeHeaderpublic static void writeHeader(java.io.OutputStream ds, double duration, int audiocodecid, int videocodecid, String createdBy, java.util.Map extraMetadata)Write file header including onMetaData packet. With this method you can provide a Map of metadata to write to the file. This map can include a mixture of simple types like: int, long, String, boolean. These types will be wrapped in AMFData classes before they are written to the file. This map can also contain AMFData items. For example if you wanted to insert and array of cuePoints the code would look like: Map extraMetadata = new HashMap(); AMFDataArray amfArray = new AMFDataArray(); for(int i=0;i - Parameters:
- ds- OutputStream
- duration- duration of .flv file in seconds
- audiocodecid- audio codec ID see IVHost.CODEC_AUDIO_* (-1 for now audio)
- videocodecid- video codec ID see IVHost.CODEC_VIDEO_* (-1 for now video)
- createdBy- created by string (null for empty)
- extraMetadata- Map of name/value pairs of metadata that will be appended to the onMetaData block
 
 - 
writeChunkpublic static com.wowza.wms.mediawriter.MediaWriterStatus writeChunk(java.io.OutputStream ds, java.nio.ByteBuffer data, int size, long timecode, byte type)Write a packets worth of data.- Parameters:
- ds- OutputStream
- data- packet data
- size- size of the packet
- timecode- timecode (milliseconds)
- type- type of packet IVHost.CONTENTTYPE_*
 
 - 
writeChunkpublic static com.wowza.wms.mediawriter.MediaWriterStatus writeChunk(java.io.DataOutput ds, java.nio.ByteBuffer data, int size, long timecode, byte type)
 - 
interleavePacketspublic static java.util.List interleavePackets(java.util.List audioPackets, java.util.List videoPackets, java.util.List dataPackets, java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs, long[] currentTCs)This is a utility function primarily used for IMediaWriters. It is a way of taking the discrete audio/video/data packets and timecodes and interleaving them into a single list of AMFPacket objects. The currentTCs array is an array of longs containing the last timecode for each of the packet types FLV_TCINDEX* (long[3]). This array will be used to calculate the absolute timecode for a given packet. For example if the relative timecode for an audio packet is 26 and the currentTCs value for the audio channel is 1003 then the absolute timecode for that packet will be 1029. The currentTCs array will be updated after this call to reflect the absolute timecode of the last packet processed of each type.- Parameters:
- audioPackets- list of audio packets (ByteBuffer)
- videoPackets- list of video packets (ByteBuffer)
- dataPackets- list of data packets (ByteBuffer)
- audioTCs- list of relative audio timecodes (Long)
- videoTCs- list of relative video timecodes (Long)
- dataTCs- list of relative data timecodes (Long)
- currentTCs- array of longs containing last TCs written for each packet type FLV_TCINDEX* (long[3]). Last timecode written for each packet type wil be returned in this same array.
- Returns:
- List of AMFPacket objects sorted by timecodes
 
 - 
interleavePacketspublic static java.util.List<AMFPacket> interleavePackets(java.util.List audioPackets, java.util.List videoPackets, java.util.List dataPackets, java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs, java.util.List dataTypes, long[] currentTCs) This is a utility function primarily used for IMediaWriters. It is a way of taking the discrete audio/video/data packets and timecodes and interleaving them into a single list of AMFPacket objects. The currentTCs array is an array of longs containing the last timecode for each of the packet types FLV_TCINDEX* (long[3]). This array will be used to calculate the absolute timecode for a given packet. For example if the relative timecode for an audio packet is 26 and the currentTCs value for the audio channel is 1003 then the absolute timecode for that packet will be 1029. The currentTCs array will be updated after this call to reflect the absolute timecode of the last packet processed of each type.- Parameters:
- audioPackets- list of audio packets (ByteBuffer)
- videoPackets- list of video packets (ByteBuffer)
- dataPackets- list of data packets (ByteBuffer)
- audioTCs- list of relative audio timecodes (Long)
- videoTCs- list of relative video timecodes (Long)
- dataTCs- list of relative data timecodes (Long)
- dataTypes- list of integer packets types (IVHost.CONTENTTYPE_DATA0, IVHost.CONTENTTYPE_DATA3) - if null assumed to be IVHost.CONTENTTYPE_DATA0
- currentTCs- array of longs containing last TCs written for each packet type FLV_TCINDEX* (long[3]). Last timecode written for each packet type wil be returned in this same array.
- Returns:
- List of AMFPacket objects sorted by timecodes
 
 - 
writePacketspublic static void writePackets(java.io.OutputStream ds, java.util.List packetList, long tcOffset)Write audio/video/data packets to an .flv file. They will be written in the packetList order.- Parameters:
- ds- OutputStream
- packetList- List of AMFPacket objects
- tcOffset- timecode offset
 
 - 
writePacketspublic static void writePackets(java.io.OutputStream ds, java.util.List audioPackets, java.util.List videoPackets, java.util.List dataPackets, java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs, long[] currentTCs)Write a bunch of packets to .flv file all at once. The packets will be sorted by timecode as written- Parameters:
- ds- OutputStream
- audioPackets- list of audio packets (ByteBuffer)
- videoPackets- list of video packets (ByteBuffer)
- dataPackets- list of data packets (ByteBuffer)
- audioTCs- list of relative audio timecodes (Long)
- videoTCs- list of relative video timecodes (Long)
- dataTCs- list of relative data timecodes (Long)
- currentTCs- array of longs containing last TCs written for each packet type FLV_TCINDEX* (long[3]). Last timecode written for each packet type wil be returned in this same array.
 
 - 
writePacketspublic static void writePackets(java.io.OutputStream ds, java.util.List audioPackets, java.util.List videoPackets, java.util.List dataPackets, java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs, java.util.List dataTypes, long[] currentTCs)Write a bunch of packets to .flv file all at once. The packets will be sorted by timecode as written- Parameters:
- ds- OutputStream
- audioPackets- list of audio packets (ByteBuffer)
- videoPackets- list of video packets (ByteBuffer)
- dataPackets- list of data packets (ByteBuffer)
- audioTCs- list of relative audio timecodes (Long)
- videoTCs- list of relative video timecodes (Long)
- dataTCs- list of relative data timecodes (Long)
- dataTypes- list of integer packets types (IVHost.CONTENTTYPE_DATA0, IVHost.CONTENTTYPE_DATA3) - if null assumed to be IVHost.CONTENTTYPE_DATA0
- currentTCs- array of longs containing last TCs written for each packet type FLV_TCINDEX* (long[3]). Last timecode written for each packet type wil be returned in this same array.
 
 - 
writePacketspublic static void writePackets(java.io.OutputStream ds, java.util.List audioPackets, java.util.List videoPackets, java.util.List dataPackets, java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs, java.util.List dataTypes, long[] currentTCs, com.wowza.util.IFLVWriterAdjustTimecode dataPacketTimecodeAdjuster)Write a bunch of packets to .flv file all at once. The packets will be sorted by timecode as written- Parameters:
- ds- OutputStream
- audioPackets- list of audio packets (ByteBuffer)
- videoPackets- list of video packets (ByteBuffer)
- dataPackets- list of data packets (ByteBuffer)
- audioTCs- list of relative audio timecodes (Long)
- videoTCs- list of relative video timecodes (Long)
- dataTCs- list of relative data timecodes (Long)
- dataTypes- list of integer packets types (IVHost.CONTENTTYPE_DATA0, IVHost.CONTENTTYPE_DATA3) - if null assumed to be IVHost.CONTENTTYPE_DATA0
- currentTCs- array of longs containing last TCs written for each packet type FLV_TCINDEX* (long[3]). Last timecode written for each packet type wil be returned
- dataPacketTimecodeAdjuster- class that implements the IFLVWriterAdjustTimecode interface for adjusting timecodes in this same array.
 
 - 
adjustFirstPacketTCspublic static long adjustFirstPacketTCs(java.util.List audioTCs, java.util.List videoTCs, java.util.List dataTCs)Align list of timecode for each data type. Assume first entry in each list is absolute timecode. When done lowest entry in three lists will be zero and other lists will be offset accordingly.- Parameters:
- audioTCs- list of audio timecodes
- videoTCs- list of video timecodes
- dataTCs- list of data timecodes
- Returns:
- lowest of three absolute timecodes
 
 - 
writeDurationpublic static void writeDuration(java.io.File file, double duration)Write the duration to an existing .flv file. This routine will hunt through the .flv file for the onMetaData packet and the duration metadata. It will rewrite the value if found. If not found it will do nothing.- Parameters:
- file- .flv file
- duration- new duration value (seconds)
 
 - 
getLastTCpublic static long getLastTC(java.io.File file) Get the duration of an .flv file. This routine will find the onMetaData packet and the duration metadata and return the value. If not found it will read the last packet in the file and return the timecode of that packet.- Parameters:
- file-
- Returns:
- duration (milliseconds)
 
 - 
isVideoKeyFramepublic static boolean isVideoKeyFrame(AMFPacket packet) Returns true if the packet is a video key frame- Parameters:
- packet- packet
- Returns:
- true if is video key frame
 
 - 
isVideoCodecConfigpublic static boolean isVideoCodecConfig(int firstByte, int secondByte)Returns true if the packet is a video codec config packet- Parameters:
- firstByte- first byte of packet
- secondByte- second byte of packet
- Returns:
- true if video codec
 
 - 
isVideoCodecConfigpublic static boolean isVideoCodecConfig(AMFPacket packet) Returns true if the packet is a video codec config packet- Parameters:
- packet-
- Returns:
- true if the packet is a video codec config packet
 
 - 
isVideoCodecConfigpublic static boolean isVideoCodecConfig(java.nio.ByteBuffer buffer) Returns true if the packet is a video codec config packet- Parameters:
- buffer- packet data
- Returns:
- true if the packet is a video codec config packet
 
 - 
isAudioCodecConfigpublic static boolean isAudioCodecConfig(AMFPacket packet) Returns true if the packet is a audio codec config packet- Parameters:
- packet-
- Returns:
- true if the packet is a audio codec config packet
 
 - 
isAudioCodecConfigpublic static boolean isAudioCodecConfig(java.nio.ByteBuffer buffer) Returns true if the packet is a audio codec config packet- Parameters:
- buffer- packet data
- Returns:
- true if the packet is a audio codec config packet
 
 - 
getAudioMP3Layerpublic static int getAudioMP3Layer(AMFPacket packet) Audio marked as MP3 is really MPEG1 Layer 1-3. Only MPEG1 Layer 3 is truely MP3. This function will return the layer number for this packet.- Parameters:
- packet- amf packet
- Returns:
- layer number
 
 - 
getAudioCodecpublic static int getAudioCodec(AMFPacket packet) Get the codec id for this audio packet. Returns IVHost.CODEC_AUDIO_UNKNOWN is unknown or not audio packet- Parameters:
- packet- packet
- Returns:
- codec id IVHost.CODEC_AUDIO_*
 
 - 
getVideoCodecpublic static int getVideoCodec(AMFPacket packet) Get the codec id for this video packet. Returns IVHost.CODEC_VIDEO_UNKNOWN is unknown or not video packet- Parameters:
- packet- packet
- Returns:
- codec id IVHost.CODEC_VIDEO_*
 
 - 
getVideoFrameTypepublic static int getVideoFrameType(AMFPacket packet) 
 - 
getPtsOffSetFromDtspublic static int getPtsOffSetFromDts(AMFPacket packet) Get the timecode offset in milliseconds between the PTS and DTS for this frame.- Parameters:
- packet- AMFPacket
- Returns:
- PTS timecode offset from DTS in milliseconds (can be negative)
 
 - 
getVideoTimecodeOffsetpublic static int getVideoTimecodeOffset(AMFPacket packet) Get the timecode offset in milliseconds between the PTS and DTS for this frame.- Parameters:
- packet- AMFPacket
- Returns:
- PTS timecode offset from DTS in milliseconds (can be negative)
 
 - 
getPtsOffSetFromDtspublic static int getPtsOffSetFromDts(byte[] buffer) Get the timecode offset in milliseconds between the PTS and DTS for this frame.- Parameters:
- buffer- video packet buffer
- Returns:
- PTS timecode offset from DTS in milliseconds (can be negative)
 
 - 
getVideoTimecodeOffsetpublic static int getVideoTimecodeOffset(byte[] buffer) Get the timecode offset in milliseconds between the PTS and DTS for this frame.- Parameters:
- buffer- video packet buffer
- Returns:
- PTS timecode offset from DTS in milliseconds (can be negative)
 
 - 
isVideoKeyFramepublic static boolean isVideoKeyFrame(java.nio.ByteBuffer buffer) Returns true if the packet is a video key frame- Parameters:
- buffer- packet data (only need first two bytes of data)
- Returns:
- true if is video key frame
 
 - 
isVideoKeyFramepublic static boolean isVideoKeyFrame(byte[] buffer) Returns true if the packet is a video key frame- Parameters:
- buffer- packet data (only need first two bytes of data)
- Returns:
- true if is video key frame
 
 - 
isVideoKeyFramepublic static boolean isVideoKeyFrame(int[] chunkHeaderValues) Returns true if the packet is a video key frame- Parameters:
- chunkHeaderValues- chunk header values returned by FLVUtils.readChunkHeader
- Returns:
- true if is video key frame
 
 - 
updateOnCuePointTimecodepublic static AMFPacket updateOnCuePointTimecode(AMFPacket packet, long timecode) 
 - 
updateOnCuePointTimecodepublic static java.nio.ByteBuffer updateOnCuePointTimecode(java.nio.ByteBuffer data, int dataType, long timecode)
 - 
isOnMetadatapublic static boolean isOnMetadata(byte[] dataDataBytes) 
 - 
isOnMetadataPacketpublic static boolean isOnMetadataPacket(AMFPacket packet) Returns true if packet is onMetaData or [@setDataFrame, onMetaData] data packet.- Parameters:
- packet- packet
- Returns:
- true if onMetaData packet
 
 - 
getOnMetadataDatapublic static OnMetadataBasic getOnMetadataData(AMFPacket metaDataPacket) 
 - 
getHeaderFlagspublic static byte getHeaderFlags(java.io.File file) 
 - 
writeHeaderFlagspublic static void writeHeaderFlags(java.io.File file, byte newFlags)
 - 
modifyOnMetadataEventpublic static byte[] modifyOnMetadataEvent(byte[] buffer, long flags, java.util.List<String> itemsToRemove, java.util.Map<String,AMFData> itemsToAdd)Modifies onMetadata event to remove or add items- Parameters:
- buffer- byte buffer with onMetadata event serialized
- flags- flags to control what gets removed (see METADATAFILTER_*)
- itemsToRemove- list of names of fields to remove
- itemsToAdd- map of items to add
- Returns:
- serialized onMetadata event
 
 
- 
 
-