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
FieldsModifier and TypeFieldDescriptionprivate booleanstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate StringHLS Segment Type.private Stringprivate Stringprivate org.bytedeco.ffmpeg.avcodec.AVPacketprivate booleanprivate intprivate static final Stringprotected static org.slf4j.Loggerprivate ByteBufferstatic final intprivate Stringprivate Stringprivate Stringprivate Stringstatic final Stringprotected StorageClientprivate org.bytedeco.ffmpeg.avcodec.AVPacketstatic final Stringprivate booleanFields 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, initialResourceNameOverride, 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
ConstructorsConstructorDescriptionHLSMuxer(io.vertx.core.Vertx vertx, StorageClient storageClient, String s3StreamsFolderPath, int uploadExtensionsToS3, String httpEndpoint, boolean addDateTimeToResourceName) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddID3Data(String data) booleanbooleanaddStream(org.bytedeco.ffmpeg.avcodec.AVCodecParameters codecParameters, org.bytedeco.ffmpeg.avutil.AVRational timebase, int streamIndex) Add stream to the muxer.booleanaddStream(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 voidstatic byte[]convertIntToID3v2TagSize(int size) static booleanconvertToMp4(String inputUrl, String outputUrl) voidstatic File[]getHLSFilesInDirectory(File localFile, String regularExpression) org.bytedeco.ffmpeg.avformat.AVFormatContextprivate voidhandleFinalization(File file) voidInits the file to write.booleanisCodecSupported(int codecId) booleanbooleanstatic voidvoidnotifyStreamFinish(String streamId, String filePath) voidsetDeleteFileOnExit(boolean deleteFileOnExist) voidsetHlsListSize(String hlsListSize) voidsetHlsParameters(String hlsListSize, String hlsTime, String hlsPlayListType, String hlsFlags, String hlsEncryptionKeyInfoFile, String hlsSegmentType) voidsetHlsPlayListType(String hlsPlayListType) voidsetHlsTime(String hlsTime) voidsetId3Enabled(boolean id3Enabled) voidsetSeiData(String data) booleanvoidwriteID3Packet(ByteBuffer data) voidwriteMetaData(String data, long dts) We write metadata as ID3 tag for HLS MuxervoidwritePacket(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 jobvoidThis function may be called by multiple encoders.Methods inherited from class io.antmedia.muxer.Muxer
addAudioStream, addExtradataIfRequired, addVideoStream, allocateAVPacket, avNewStream, checkToDropPacket, contextChanged, contextChanged, contextWillChange, contextWillChange, getAppAdaptor, getAppSettings, getAudioNotWrittenCount, getAverageBitrate, getBitStreamFilter, getBsfAudioNames, getBsfFilterContextList, getCurrentVoDTimeStamp, getDurationInMs, getDurationInMs, getErrorDefinition, getExtendedName, getFile, getFileName, getFormat, getInputTimeBaseMap, getIsRunning, getLastPts, getOptionDictionary, getPacketBufferWithExtradata, getPreviewFile, getRecordFile, getRegisteredStreamIndexList, getResolution, getResourceFile, getSubFolder, getTmpPacket, getUserRecordFile, getVideoCodecId, getVideoExtradata, getVideoHeight, getVideoNotWrittenCount, getVideoWidth, init, initAudioBitstreamFilter, initVideoBitstreamFilter, isAddDateTimeToSourceName, logPacketIssue, openIO, prepareIO, replaceDoubleSlashesWithSingleSlash, setAddDateTimeToSourceName, setAudioBitreamFilter, setBitstreamFilter, setCurrentVoDTimeStamp, setFormat, setInitialResourceNameOverride, setIsRunning, setOption, setStreamId, 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:
-
HLS_FILES_REGEX_MATCHER
- 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:
getOutputURLin classMuxer
-
getOutputFormatContext
public org.bytedeco.ffmpeg.avformat.AVFormatContext getOutputFormatContext()- Specified by:
getOutputFormatContextin classMuxer
-
isCodecSupported
public boolean isCodecSupported(int codecId) - Specified by:
isCodecSupportedin 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:MuxerAll other writePacket functions call this function to make the job- Overrides:
writePacketin 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:
writeMetaDatain classMuxer
-
convertIntToID3v2TagSize
public static byte[] convertIntToID3v2TagSize(int size) -
addID3Data
-
writeID3Packet
-
writeHeader
public boolean writeHeader()- Overrides:
writeHeaderin 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:
writeTrailerin classMuxer
-
convertToMp4
-
notifyStreamFinish
- Throws:
IOException
-
handleFinalization
-
getHLSFilesInDirectory
-
addStream
public boolean addStream(org.bytedeco.ffmpeg.avcodec.AVCodec codec, org.bytedeco.ffmpeg.avcodec.AVCodecContext codecContext, int streamIndex) Description copied from class:MuxerAdd 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:MuxerAdd 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:
clearResourcein classMuxer
-
getPendingSEIData
-