Class HLSMuxer

java.lang.Object
io.antmedia.muxer.Muxer
io.antmedia.muxer.HLSMuxer

public class HLSMuxer extends Muxer
  • Field Details

    • SEI_USER_DATA

      public static final String SEI_USER_DATA
      See Also:
    • LETTER_DOT

      private static final String LETTER_DOT
      See Also:
    • TS_EXTENSION

      private static final String TS_EXTENSION
      See Also:
    • FMP4_EXTENSION

      private static final String FMP4_EXTENSION
      See Also:
    • HLS_SEGMENT_TYPE_MPEGTS

      private static final String HLS_SEGMENT_TYPE_MPEGTS
      See Also:
    • HLS_SEGMENT_TYPE_FMP4

      private static final String HLS_SEGMENT_TYPE_FMP4
      See Also:
    • logger

      protected static org.slf4j.Logger logger
    • hlsListSize

      private String hlsListSize
    • hlsTime

      private String hlsTime
    • hlsPlayListType

      private String hlsPlayListType
    • deleteFileOnExit

      private boolean deleteFileOnExit
    • hlsFlags

      private String hlsFlags
    • segmentInitFilename

      private String segmentInitFilename
    • hlsEncryptionKeyInfoFile

      private String hlsEncryptionKeyInfoFile
    • storageClient

      protected StorageClient storageClient
    • s3StreamsFolderPath

      private String s3StreamsFolderPath
    • uploadHLSToS3

      private boolean uploadHLSToS3
    • segmentFilename

      private String segmentFilename
    • hlsSegmentType

      private String 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

      private String 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

      private ByteBuffer pendingSEIData
    • tmpPacketForSEI

      private org.bytedeco.ffmpeg.avcodec.AVPacket tmpPacketForSEI
    • segmentFileNameSuffix

      private String segmentFileNameSuffix
  • Constructor Details

    • HLSMuxer

      public HLSMuxer(io.vertx.core.Vertx vertx, StorageClient storageClient, String s3StreamsFolderPath, int uploadExtensionsToS3, String httpEndpoint, boolean addDateTimeToResourceName)
  • Method Details

    • setHlsParameters

      public void setHlsParameters(String hlsListSize, String hlsTime, String hlsPlayListType, String hlsFlags, String hlsEncryptionKeyInfoFile, String hlsSegmentType)
    • init

      public void init(IScope scope, String name, int resolutionHeight, String subFolder, int bitrate)
      Inits the file to write. Multiple encoders can init the muxer. It is redundant to init multiple times.
      Overrides:
      init in class Muxer
    • getOutputURL

      public String getOutputURL()
      Overrides:
      getOutputURL in class Muxer
    • getOutputFormatContext

      public org.bytedeco.ffmpeg.avformat.AVFormatContext getOutputFormatContext()
      Specified by:
      getOutputFormatContext in class Muxer
    • isCodecSupported

      public boolean isCodecSupported(int codecId)
      Specified by:
      isCodecSupported in class Muxer
    • 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 class Muxer
      Parameters:
      pkt - Content of the data in AVPacket class
      inputTimebase - input time base is required to calculate the correct dts and pts values for the container
      outputTimebase - output time base is required to calculate the correct dts and pts values for the container
    • writeMetaData

      public void writeMetaData(String data, long dts)
      We write metadata as ID3 tag for HLS Muxer
      Overrides:
      writeMetaData in class Muxer
    • convertIntToID3v2TagSize

      public static byte[] convertIntToID3v2TagSize(int size)
    • addID3Data

      public void addID3Data(String data)
    • writeID3Packet

      public void writeID3Packet(ByteBuffer data)
    • writeHeader

      public boolean writeHeader()
      Overrides:
      writeHeader in class Muxer
    • 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 class Muxer
    • handleFinalization

      private void handleFinalization(File file)
    • getHLSFilesInDirectory

      public File[] getHLSFilesInDirectory(String regularExpression)
    • 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
      Overrides:
      addStream in class Muxer
      Returns:
    • setSeiData

      public void setSeiData(String data)
    • logError

      public static void logError(int ret, String message, String streamId)
    • 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
      Overrides:
      addStream in class Muxer
      streamIndex - , is the stream index of the source. Sometimes source and target stream index do not match
      Returns:
    • addID3Stream

      public boolean addID3Stream()
    • getHlsListSize

      public String getHlsListSize()
    • setHlsListSize

      public void setHlsListSize(String hlsListSize)
    • getHlsTime

      public String getHlsTime()
    • setHlsTime

      public void setHlsTime(String hlsTime)
    • getHlsPlayListType

      public String getHlsPlayListType()
    • setHlsPlayListType

      public void setHlsPlayListType(String hlsPlayListType)
    • isDeleteFileOnExit

      public boolean isDeleteFileOnExit()
    • setDeleteFileOnExit

      public void setDeleteFileOnExit(boolean deleteFileOnExist)
    • isUploadingToS3

      public boolean isUploadingToS3()
    • getSegmentFilename

      public String getSegmentFilename()
    • setId3Enabled

      public void setId3Enabled(boolean id3Enabled)
    • clearResource

      protected void clearResource()
      Overrides:
      clearResource in class Muxer
    • getPendingSEIData

      public ByteBuffer getPendingSEIData()