LiveTranscoding
Transcoding configurations for Media Push.
public class LiveTranscoding { public enum AudioSampleRateType { TYPE_32000(32000), TYPE_44100(44100), TYPE_48000(48000); private int value; private AudioSampleRateType(int v) { value = v; } public static int getValue(AudioSampleRateType type) { return type.value; } } public enum VideoCodecProfileType { BASELINE(66), MAIN(77), HIGH(100); private int value; private VideoCodecProfileType(int v) { value = v; } public static int getValue(VideoCodecProfileType type) { return type.value; } } public enum AudioCodecProfileType { LC_AAC(0), HE_AAC(1), HE_AAC(1); HE_AAC_V2(2); private int value; private AudioCodecProfileType(int v) { value = v; } public static int getValue(AudioCodecProfileType type) { return type.value; } } public enum VideoCodecType { H264(1), H265(2); private int value; private VideoCodecType(int v) { value = v; } public static int getValue(VideoCodecType type) { return type.value; } } public int width; public int height; public int videoBitrate; public int videoFramerate; public boolean lowLatency; @Deprecated public boolean lowLatency; public int videoGop; private ArrayList<AgoraImage> watermarkList; public void addWatermark(AgoraImage watermark) { if (watermarkList == null) { watermarkList = new ArrayList<AgoraImage>(); } watermarkList.add(watermark); } public boolean removeWatermark(AgoraImage watermark) { if (watermarkList == null) { return false; } return watermarkList.remove(watermark); } public ArrayList<AgoraImage> getWatermarkList() { return watermarkList; } private ArrayList<AgoraImage> backgroundImageList; public void addBackgroundImage(AgoraImage backgroundImage) { if (backgroundImageList == null) { backgroundImageList = new ArrayList<AgoraImage>(); } backgroundImageList.add(backgroundImage); } public boolean removeBackgroundImage(AgoraImage backgroundImage) { if (backgroundImageList == null) { return false; } return backgroundImageList.remove(backgroundImage); } public ArrayList<AgoraImage> getBackgroundImageList() { return backgroundImageList; } public AudioSampleRateType audioSampleRate; public int audioBitrate; public int audioChannels; public AudioCodecProfileType audioCodecProfile; public VideoCodecProfileType videoCodecProfile; public VideoCodecType videoCodecType; @Deprecated public int userCount; @Deprecated public int backgroundColor; public String userConfigExtraInfo; public String metadata; @Deprecated public String metadata; private Map<Integer, TranscodingUser> transcodingUsers; private Map<String, Boolean> advancedFeatures; public void setAdvancedFeatures(String featureName, Boolean opened) { advancedFeatures.put(featureName, opened); } public Map<String, Boolean> getAdvancedFeatures() { return advancedFeatures; } public static class TranscodingUser { public int uid; public String userId; public String userId; public int x; public int y; public int width; public int height; public int zOrder; public float alpha; public int audioChannel; public TranscodingUser() { alpha = 1; } } public LiveTranscoding() { width = 360; height = 640; videoBitrate = 400; videoCodecProfile = VideoCodecProfileType.HIGH; videoCodecType = VideoCodecType.H264; videoGop = 30; videoFramerate = 15; lowLatency = false; audioSampleRate = AudioSampleRateType.TYPE_44100; audioBitrate = 48; audioChannels = 1; audioCodecProfile = AudioCodecProfileType.LC_AAC; transcodingUsers = new HashMap<>(); advancedFeatures = new HashMap<>(); backgroundColor = 0xFF000000; userConfigExtraInfo = null; metadata = null; } public int addUser(TranscodingUser user) { if (user == null || user.uid == 0) { return -Constants.ERR_INVALID_ARGUMENT; } transcodingUsers.put(user.uid, user); userCount = transcodingUsers.size(); return Constants.ERR_OK; } public final ArrayList<TranscodingUser> getUsers() { Collection<TranscodingUser> values = transcodingUsers.values(); return new ArrayList<>(values); } public void setUsers(ArrayList<TranscodingUser> users) { transcodingUsers.clear(); if (users != null) { for (TranscodingUser user : users) { transcodingUsers.put(user.uid, user); } } userCount = transcodingUsers.size(); } public void setUsers(Map<Integer, TranscodingUser> users) { transcodingUsers.clear(); if (users != null) { transcodingUsers.putAll(users); } userCount = transcodingUsers.size(); } public int removeUser(int uid) { if (!transcodingUsers.containsKey(uid)) return -Constants.ERR_INVALID_ARGUMENT; transcodingUsers.remove(uid); userCount = transcodingUsers.size(); return Constants.ERR_OK; } public int getUserCount() { return transcodingUsers.size(); } public int getBackgroundColor() { return this.backgroundColor; } public void setBackgroundColor(int color) { this.backgroundColor = color; } public void setBackgroundColor(int red, int green, int blue) { this.backgroundColor = (red << 16) | (green << 8) | (blue << 0); } @Deprecated public int getRed() { return (backgroundColor >> 16) & 0x0ff; } @Deprecated public int getGreen() { return (backgroundColor >> 8) & 0x0ff; } @Deprecated public int getBlue() { return backgroundColor & 0x0ff; } @Deprecated public void setRed(int red) { int green = getGreen(); int blue = getBlue(); this.backgroundColor = (red << 16) | (green << 8) | (blue << 0); } @Deprecated public void setGreen(int green) { int red = getRed(); int blue = getBlue(); this.backgroundColor = (red << 16) | (green << 8) | (blue << 0); } @Deprecated public void setBlue(int blue) { int red = getRed(); int green = getGreen(); this.backgroundColor = (red << 16) | (green << 8) | (blue << 0); } }
Attributes
- width
-
The width of the video in pixels. The default value is 360.
- When pushing video streams to the CDN, the value range of
width
is [64,1920]. If the value is less than 64, Agora server automatically adjusts it to 64; if the value is greater than 1920, Agora server automatically adjusts it to 1920. - When pushing audio streams to the CDN, set
width
andheight
as 0.
- When pushing video streams to the CDN, the value range of
- height
-
The height of the video in pixels. The default value is 640.
- When pushing video streams to the CDN, the value range of
height
is [64,1080]. If the value is less than 64, Agora server automatically adjusts it to 64; if the value is greater than 1080, Agora server automatically adjusts it to 1080. - When pushing audio streams to the CDN, set
width
andheight
as 0.
- When pushing video streams to the CDN, the value range of
- videoBitrate
-
Bitrate of the output video stream for Media Push in Kbps. The default value is 400 Kbps.
Set this member according to the Video profile table. If you set a bitrate beyond the proper range, the SDK automatically adapts it to a value within the range.
- videoFrameRate
-
Frame rate (fps) of the output video stream set for Media Push. The default value is 15. The value range is (0,30].
Attention: The Agora server adjusts any value over 30 to 30. - lowLatency
-
- Deprecated
- This member is deprecated.
Latency mode:
true
: Low latency with unassured quality.false
: (Default) High latency with assured quality.
- videoGop
- GOP (Group of Pictures) in fps of the video frames for Media Push. The default value is 30.
- videoCodecProfile
-
Video codec profile type for Media Push. Set it as 66, 77, or 100 (default). See VideoCodecProfileType for details.
Attention: If you set this parameter to any other value, Agora adjusts it to the default value. - videoCodecType
- Video codec profile types for Media Push. See VideoCodecType.
- transcodingUsers
-
Manages the user layout configuration in the Media Push. Agora supports a maximum of 17 transcoding users in a Media Push channel. See TranscodingUser.
- userConfigExtraInfo
-
Reserved property. Extra user-defined information to send SEI for the H.264/H.265 video stream to the CDN live client. Maximum length: 4096 bytes. For more information on SEI, see SEI-related questions.
- backgroundColor
-
- Deprecated
- Obsolete and not recommended for use. Use setBackgroundColor [1/2] instead.
- userCount
-
- Deprecated
- Obsolete and not recommended for use. Use getUserCount instead.
The number of users in the Media Push. The value range is [0,17].
- metadata
-
- Deprecated
- Obsolete and not recommended for use.
The metadata sent to the CDN client.
- audioSampleRate
-
The audio sampling rate (Hz) of the output media stream. See AudioSampleRateType.
- audioBitrate
-
Bitrate (Kbps) of the audio output stream for Media Push. The default value is 48, and the highest value is 128.
- audioChannels
-
The number of audio channels for Media Push. Agora recommends choosing 1 (mono), or 2 (stereo) audio channels. Special players are required if you choose 3, 4, or 5.
- 1: (Default) Mono
- 2: Stereo.
- 3: Three audio channels.
- 4: Four audio channels.
- 5: Five audio channels.
- audioCodecProfile
- Audio codec profile type for Media Push. See AudioCodecProfileType.
Method
- addBackgroundImage
- Adds a background image. See addBackgroundImage.
- addUser
- Adds a user for video mixing during the CDN live streaming. See addUser.
- addWatermark
- Adds a watermark. See addWatermark.
- getAdvancedFeatures
- Gets the status of the advanced features of streaming with transcoding. See getAdvancedFeatures.
- getBackgroundColor
- Gets the background color in hex. See getBackgroundColor.
- getBackgroundImageList
- Gets the list of background images. See getBackgroundImageList.
- getBlue
-
- Deprecated
- Obsolete and not recommended for use.
Gets the background color's blue component. See getBlue.
- getGreen
-
- Deprecated
- Obsolete and not recommended for use.
Gets the background color's green component. See getGreen.
- getRed
-
- Deprecated
- Obsolete and not recommended for use.
Gets the background color's red component. See getRed.
- getUserCount
- Gets the number of users transcoded in the CDN live streaming. See getUserCount.
- getUsers
- Gets the user list in the CDN live streaming. See getUsers.
- getWatermarkList
- Gets the watermark list. See getWatermarkList.
- removeBackgroundImage
- Removes a background image from the background image list. See removeBackgroundImage.
- removeUser
- Removes a user from video mixing during the CDN live streaming. See removeUser.
- removeWatermark
- Removes a watermark from the watermark list. See removeWatermark.
- setAdvancedFeatures
- Sets whether to enable the advanced features of streaming with transcoding. See setAdvancedFeatures.
- setBackgroundColor [1/2]
- Sets the background color of the CDN live stream in the format of RGB hex. See setBackgroundColor [1/2].
- setBackgroundColor [2/2]
- Sets the background color in RGB format. See setBackgroundColor [2/2].
- setBlue
-
- Deprecated
- Obsolete and not recommended for use.
Sets the background color's blue component. See setBlue.
- setGreen
-
- Deprecated
- Obsolete and not recommended for use.
Sets the background color's green component. See setGreen.
- setRed
-
- Deprecated
- Obsolete and not recommended for use.
Sets the background color's red component. See setRed.
- setUsers [1/2]
- Sets the users in batches in the CDN live streaming. See setUsers [1/2].
- setUsers [2/2]
- Sets the users in batches in the CDN live streaming. See setUsers [2/2].