Class KrakenVideoHelper

java.lang.Object
com.github.twitch4j.kraken.util.KrakenVideoHelper

public final class KrakenVideoHelper
extends java.lang.Object
  • Field Summary

    Fields
    Modifier and Type Field Description
    static int MAX_PIECE_LENGTH
    Max size of a video part byte array; avoids hitting 25MB.
    static int MIN_PIECE_LENGTH
    Minimum size of a video part byte array, 5 MiB.
  • Method Summary

    Modifier and Type Method Description
    static java.util.concurrent.CompletableFuture<KrakenVideo> uploadVideo​(@NonNull TwitchKraken api, java.lang.String authToken, java.lang.String channelId, @NonNull java.lang.String title, java.lang.String description, java.lang.String game, java.lang.String language, java.util.List<java.lang.String> tags, java.lang.String viewable, java.time.Instant viewableAt, @NonNull java.io.InputStream inputStream, int pieceLength, long sleepBetweenRequests)
    Uploads a video to the channel of an affiliate or partner.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_PIECE_LENGTH

      public static final int MAX_PIECE_LENGTH
      Max size of a video part byte array; avoids hitting 25MB.

      This is conservatively set to just over 18 MiB based on testing which values avoid peer connection resets.

      See Also:
      Official documentation, Constant Field Values
    • MIN_PIECE_LENGTH

      public static final int MIN_PIECE_LENGTH
      Minimum size of a video part byte array, 5 MiB.
      See Also:
      Official documentation, Constant Field Values
  • Method Details

    • uploadVideo

      public static java.util.concurrent.CompletableFuture<KrakenVideo> uploadVideo​(@NonNull @NonNull TwitchKraken api, java.lang.String authToken, java.lang.String channelId, @NonNull @NonNull java.lang.String title, java.lang.String description, java.lang.String game, java.lang.String language, java.util.List<java.lang.String> tags, java.lang.String viewable, java.time.Instant viewableAt, @NonNull @NonNull java.io.InputStream inputStream, int pieceLength, long sleepBetweenRequests)
      Uploads a video to the channel of an affiliate or partner.

      Helper function to automate the process of creating the video, uploading the parts, and marking the upload as complete.

      Videos with the following formats can be uploaded:

      • MP4, MOV, AVI and FLV file formats
      • AAC audio
      • h264 codec
      • Up to 10Mbps bitrate
      • Up to 1080p/60FPS
      There is a rate limit of 5 simultaneous uploads per user, with a maximum of 100 uploads in 24 hours.
      Parameters:
      api - Required: A TwitchKraken instance.
      authToken - Required: Auth Token (scope: channel_editor) that is authorized to upload to the specified channel.
      channelId - Optional: The id of the channel to upload to. If absent, it will use the user id associated with the auth token.
      title - Required: The title for the uploaded video (maximum 100 characters).
      description - Optional: A short description for the video.
      game - Optional: The name of the game in the video.
      language - Optional: Language of the video (for example, en).
      tags - Optional: Tags describing the video. Maximum: 100 characters per tag, 500 characters for the entire list.
      viewable - Optional: Specifies who can view the video. Valid values: public or private. Default: public.
      viewableAt - Optional: Date when the video will become public (if initially private).
      inputStream - Required: The stream of bytes containing the video. Must be encoded in a format supported by Twitch.
      pieceLength - Optional: The number of bytes of video for each video part to be uploaded. Invalid values will be clamped into the valid range.
      sleepBetweenRequests - Optional: The time to sleep after each video part upload. Invalid values will be treated as zero.
      Returns:
      a future wrapper around the uploaded video
      See Also:
      TwitchKraken.createVideo(String, String, String, String, String, String, List, String, Instant), TwitchKraken.uploadVideoPart(String, String, int, byte[]), TwitchKraken.completeVideoUpload(String, String)