Package io.antmedia.muxer
Class HLSMuxer
java.lang.Object
io.antmedia.muxer.Muxer
io.antmedia.muxer.HLSMuxer
-
Nested Class Summary
Nested classes/interfaces inherited from class io.antmedia.muxer.Muxer
Muxer.VideoBuffer
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
private static final String
private static final String
private static final String
private String
private String
private String
private String
private String
HLS Segment Type.private String
private String
private org.bytedeco.ffmpeg.avcodec.AVPacket
private boolean
private int
private static final String
protected static org.slf4j.Logger
private ByteBuffer
static final int
private String
private String
private String
private String
static final String
protected StorageClient
private org.bytedeco.ffmpeg.avcodec.AVPacket
private static final String
private boolean
Fields inherited from class io.antmedia.muxer.Muxer
audioPkt, avRationalTimeBase, BITSTREAM_FILTER_H264_MP4TOANNEXB, BITSTREAM_FILTER_HEVC_MP4TOANNEXB, bsfAudioFilterContextList, bsfFilterContextList, bsfVideoNames, DATE_TIME_PATTERN, extension, file, firstAudioDts, firstKeyFrameReceived, firstVideoDts, format, headerWritten, initialResourceNameWithoutExtension, inputOutputStreamIndexMap, inputTimeBaseMap, isInitialized, isRunning, loggerStatic, optionDictionary, options, outputFormatContext, registeredStreamIndexList, rotation, scope, SEGMENT_INDEX_LENGTH, streamId, subFolder, TEMP_EXTENSION, time2log, tmpPacket, vertx, videoExtradata, videoHeight, videoPkt, videoWidth
-
Constructor Summary
ConstructorDescriptionHLSMuxer
(io.vertx.core.Vertx vertx, StorageClient storageClient, String s3StreamsFolderPath, int uploadExtensionsToS3, String httpEndpoint, boolean addDateTimeToResourceName) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addID3Data
(String data) boolean
boolean
addStream
(org.bytedeco.ffmpeg.avcodec.AVCodecParameters codecParameters, org.bytedeco.ffmpeg.avutil.AVRational timebase, int streamIndex) Add stream to the muxer.boolean
addStream
(org.bytedeco.ffmpeg.avcodec.AVCodec codec, org.bytedeco.ffmpeg.avcodec.AVCodecContext codecContext, int streamIndex) Add a new stream with this codec, codecContext and stream Index parameters.protected void
static byte[]
convertIntToID3v2TagSize
(int size) void
File[]
getHLSFilesInDirectory
(String regularExpression) org.bytedeco.ffmpeg.avformat.AVFormatContext
private void
handleFinalization
(File file) void
Inits the file to write.boolean
isCodecSupported
(int codecId) boolean
boolean
static void
void
setDeleteFileOnExit
(boolean deleteFileOnExist) void
setHlsListSize
(String hlsListSize) void
setHlsParameters
(String hlsListSize, String hlsTime, String hlsPlayListType, String hlsFlags, String hlsEncryptionKeyInfoFile, String hlsSegmentType) void
setHlsPlayListType
(String hlsPlayListType) void
setHlsTime
(String hlsTime) void
setId3Enabled
(boolean id3Enabled) void
setSeiData
(String data) boolean
void
writeID3Packet
(ByteBuffer data) void
writeMetaData
(String data, long dts) We write metadata as ID3 tag for HLS Muxervoid
writePacket
(org.bytedeco.ffmpeg.avcodec.AVPacket pkt, org.bytedeco.ffmpeg.avutil.AVRational inputTimebase, org.bytedeco.ffmpeg.avutil.AVRational outputTimebase, int codecType) All other writePacket functions call this function to make the jobvoid
This function may be called by multiple encoders.Methods inherited from class io.antmedia.muxer.Muxer
addAudioStream, addExtradataIfRequired, addVideoStream, avNewStream, checkToDropPacket, contextChanged, contextWillChange, getAppAdaptor, getAppSettings, getAudioNotWrittenCount, getAverageBitrate, getBitStreamFilter, getBsfAudioNames, getCurrentVoDTimeStamp, getDurationInMs, getDurationInMs, getErrorDefinition, getExtendedName, getFile, getFileName, getFormat, getInputTimeBaseMap, getIsRunning, getLastPts, getOptionDictionary, getPacketBufferWithExtradata, getPreviewFile, getRecordFile, getRegisteredStreamIndexList, getResolution, getResourceFile, getSubFolder, getTmpPacket, getUserRecordFile, getVideoCodecId, getVideoHeight, getVideoNotWrittenCount, getVideoWidth, init, initAudioBitstreamFilter, initVideoBitstreamFilter, isAddDateTimeToSourceName, logPacketIssue, openIO, prepareIO, replaceDoubleSlashesWithSingleSlash, setAddDateTimeToSourceName, setAudioBitreamFilter, setBitstreamFilter, setCurrentVoDTimeStamp, setIsRunning, setOption, setSubfolder, writeAudioBuffer, writeAudioFrame, writeDataFrame, writePacket, writePacket, writeVideoBuffer, writeVideoBuffer, writeVideoFrame
-
Field Details
-
SEI_USER_DATA
- See Also:
-
LETTER_DOT
- See Also:
-
TS_EXTENSION
- See Also:
-
FMP4_EXTENSION
- See Also:
-
HLS_SEGMENT_TYPE_MPEGTS
- See Also:
-
HLS_SEGMENT_TYPE_FMP4
- See Also:
-
logger
protected static org.slf4j.Logger logger -
hlsListSize
-
hlsTime
-
hlsPlayListType
-
deleteFileOnExit
private boolean deleteFileOnExit -
hlsFlags
-
segmentInitFilename
-
hlsEncryptionKeyInfoFile
-
storageClient
-
s3StreamsFolderPath
-
uploadHLSToS3
private boolean uploadHLSToS3 -
segmentFilename
-
hlsSegmentType
HLS Segment Type. It can be "mpegts" or "fmp4" Note: The generated M3U8 for HEVC can be playable when it's fmp4 It's not playable when it's mpegts -
httpEndpoint
-
S3_CONSTANT
public static final int S3_CONSTANT- See Also:
-
id3StreamIndex
private int id3StreamIndex -
id3DataPkt
private org.bytedeco.ffmpeg.avcodec.AVPacket id3DataPkt -
id3Enabled
private boolean id3Enabled -
pendingSEIData
-
tmpPacketForSEI
private org.bytedeco.ffmpeg.avcodec.AVPacket tmpPacketForSEI -
segmentFileNameSuffix
-
-
Constructor Details
-
HLSMuxer
public HLSMuxer(io.vertx.core.Vertx vertx, StorageClient storageClient, String s3StreamsFolderPath, int uploadExtensionsToS3, String httpEndpoint, boolean addDateTimeToResourceName)
-
-
Method Details
-
setHlsParameters
-
init
Inits the file to write. Multiple encoders can init the muxer. It is redundant to init multiple times. -
getOutputURL
- Overrides:
getOutputURL
in classMuxer
-
getOutputFormatContext
public org.bytedeco.ffmpeg.avformat.AVFormatContext getOutputFormatContext()- Specified by:
getOutputFormatContext
in classMuxer
-
isCodecSupported
public boolean isCodecSupported(int codecId) - Specified by:
isCodecSupported
in classMuxer
-
writePacket
public void writePacket(org.bytedeco.ffmpeg.avcodec.AVPacket pkt, org.bytedeco.ffmpeg.avutil.AVRational inputTimebase, org.bytedeco.ffmpeg.avutil.AVRational outputTimebase, int codecType) Description copied from class:Muxer
All other writePacket functions call this function to make the job- Overrides:
writePacket
in classMuxer
- Parameters:
pkt
- Content of the data in AVPacket classinputTimebase
- input time base is required to calculate the correct dts and pts values for the containeroutputTimebase
- output time base is required to calculate the correct dts and pts values for the container
-
writeMetaData
We write metadata as ID3 tag for HLS Muxer- Overrides:
writeMetaData
in classMuxer
-
convertIntToID3v2TagSize
public static byte[] convertIntToID3v2TagSize(int size) -
addID3Data
-
writeID3Packet
-
writeHeader
public boolean writeHeader()- Overrides:
writeHeader
in classMuxer
-
createID3StreamIfRequired
public void createID3StreamIfRequired() -
writeTrailer
public void writeTrailer()This function may be called by multiple encoders. Make sure that it is called once. See the sample implementations how it is being protected Implement this function with synchronized keyword as the subclass- Overrides:
writeTrailer
in classMuxer
-
handleFinalization
-
getHLSFilesInDirectory
-
addStream
public boolean addStream(org.bytedeco.ffmpeg.avcodec.AVCodec codec, org.bytedeco.ffmpeg.avcodec.AVCodecContext codecContext, int streamIndex) Description copied from class:Muxer
Add a new stream with this codec, codecContext and stream Index parameters. After adding streams, need to call prepareIO() This method is called by encoder. After encoder is opened, it adds codec context to the muxer -
setSeiData
-
logError
-
addStream
public boolean addStream(org.bytedeco.ffmpeg.avcodec.AVCodecParameters codecParameters, org.bytedeco.ffmpeg.avutil.AVRational timebase, int streamIndex) Description copied from class:Muxer
Add stream to the muxer. This method is called by direct muxing. For instance from RTMP, SRT ingest & Stream Pull to HLS, MP4, HLS, DASH WebRTC Muxing -
addID3Stream
public boolean addID3Stream() -
getHlsListSize
-
setHlsListSize
-
getHlsTime
-
setHlsTime
-
getHlsPlayListType
-
setHlsPlayListType
-
isDeleteFileOnExit
public boolean isDeleteFileOnExit() -
setDeleteFileOnExit
public void setDeleteFileOnExit(boolean deleteFileOnExist) -
isUploadingToS3
public boolean isUploadingToS3() -
getSegmentFilename
-
setId3Enabled
public void setId3Enabled(boolean id3Enabled) -
clearResource
protected void clearResource()- Overrides:
clearResource
in classMuxer
-
getPendingSEIData
-