aws-samples / amazon-ivs-broadcast-android-sample

MIT No Attribution
9 stars 8 forks source link

IVS's new preset configurations is not appearing in SDK #64

Open Emefar opened 2 months ago

Emefar commented 2 months ago

Hello,

I checked FAQ page for new presets. But i cannot find new preset configurations in SDK. For example; how can i setting 'Constrained bandwidth delivery' at mobile SDK.

IVS FAQ

Here SDK's configurations

public static final class Configuration {
        public static final BroadcastConfiguration STANDARD_PORTRAIT = new BroadcastConfiguration();
        public static final BroadcastConfiguration STANDARD_LANDSCAPE;
        public static final BroadcastConfiguration BASIC_LANDSCAPE;
        public static final BroadcastConfiguration BASIC_PORTRAIT;
        public static final BroadcastConfiguration GAMING_LANDSCAPE;
        public static final BroadcastConfiguration GAMING_PORTRAIT;

        public Configuration() {
        }

        static {
            STANDARD_LANDSCAPE = STANDARD_PORTRAIT.changing(($) -> {
                $.video.setSize((int)$.video.getSize().y, (int)$.video.getSize().x);
                return $;
            });
            BASIC_LANDSCAPE = BroadcastConfiguration.with(($) -> {
                $.video.setInitialBitrate(1200000);
                $.video.setMaxBitrate(1500000);
                $.video.setUseBFrames(false);
                $.video.setSize(new BroadcastConfiguration.Vec2(852.0F, 480.0F));
                return $;
            });
            BASIC_PORTRAIT = BroadcastConfiguration.with(($) -> {
                $.video.setInitialBitrate(1200000);
                $.video.setMaxBitrate(1500000);
                $.video.setUseBFrames(false);
                $.video.setSize(new BroadcastConfiguration.Vec2(480.0F, 852.0F));
                return $;
            });
            GAMING_LANDSCAPE = BroadcastConfiguration.with(($) -> {
                $.video.setInitialBitrate(2100000);
                $.video.setMaxBitrate(6000000);
                $.video.setMinBitrate(900000);
                $.video.setSize(new BroadcastConfiguration.Vec2(1280.0F, 720.0F));
                $.video.setTargetFramerate(30);
                $.audio.setBitrate(128000);
                $.mixer.slots = new BroadcastConfiguration.Mixer.Slot[]{Slot.with((slot) -> {
                    slot.setSize($.video.getSize());
                    slot.setAspect(AspectMode.FILL);
                    slot.setName("game");
                    slot.setPreferredAudioInput(DeviceType.SYSTEM_AUDIO);
                    slot.setPreferredVideoInput(DeviceType.SCREEN);
                    return slot;
                }), Slot.with((slot) -> {
                    slot.setSize(new BroadcastConfiguration.Vec2(200.0F, 150.0F));
                    slot.setPosition(new BroadcastConfiguration.Vec2($.video.getSize().x - 300.0F, $.video.getSize().y - 200.0F));
                    slot.setAspect(AspectMode.FILL);
                    slot.setPreferredAudioInput(DeviceType.MICROPHONE);
                    slot.setPreferredVideoInput(DeviceType.CAMERA);
                    slot.setzIndex(10);
                    slot.setName("camera");
                    return slot;
                })};
                return $;
            });
            GAMING_PORTRAIT = BroadcastConfiguration.with(($) -> {
                $.video.setInitialBitrate(2100000);
                $.video.setMaxBitrate(6000000);
                $.video.setMinBitrate(900000);
                $.video.setSize(new BroadcastConfiguration.Vec2(720.0F, 1280.0F));
                $.video.setTargetFramerate(30);
                $.audio.setBitrate(128000);
                $.mixer.slots = new BroadcastConfiguration.Mixer.Slot[]{Slot.with((slot) -> {
                    slot.setSize($.video.getSize());
                    slot.setAspect(AspectMode.FILL);
                    slot.setName("game");
                    slot.setPreferredAudioInput(DeviceType.SYSTEM_AUDIO);
                    slot.setPreferredVideoInput(DeviceType.SCREEN);
                    return slot;
                }), Slot.with((slot) -> {
                    slot.setSize(new BroadcastConfiguration.Vec2(200.0F, 150.0F));
                    slot.setPosition(new BroadcastConfiguration.Vec2($.video.getSize().x - 300.0F, $.video.getSize().y - 200.0F));
                    slot.setAspect(AspectMode.FILL);
                    slot.setPreferredAudioInput(DeviceType.MICROPHONE);
                    slot.setPreferredVideoInput(DeviceType.CAMERA);
                    slot.setzIndex(10);
                    slot.setName("camera");
                    return slot;
                })};
                return $;
            });
        }
    }
bclymer commented 1 month ago

Hey @Emefar , apologies for the confusion. The presets seen on the FAQ page are unrelated to the presets found in the SDK (despite both having Standard as an option). The presets on the FAQ page relate mostly to the transcode ladder, which impacts the output HLS stream, independent of the input RTMP stream.

The only time the input RTMP stream video bitrate impacts the output HLS stream bitrate is when a "source" rendition is passed through, like on the Standard and Basic channel types.

cemnisan commented 1 month ago

Hello @bclymer, I have the same issue with @Emefar. I want to make a feature which will allow my users to broadcast 160p. Is it possible to do this using the SDK?

bclymer commented 1 month ago

@cemnisan yes, just set the video config to broadcast at 160p.

val config = Presets.Configuration.STANDARD_LANDSCAPE
config.video.size = Vec2(240, 160) // whatever resolution you want.

Then pass that config to the BroadcastSession when you create it.