Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting resolution for push and pull streaming using WebRTC is not working ,Android #4262

Open
lichao5585 opened this issue Dec 18, 2024 · 3 comments
Labels
EnglishNative This issue is conveyed exclusively in English.

Comments

@lichao5585
Copy link

lichao5585 commented Dec 18, 2024

html code

<script type="text/javascript">
        $(function() {
            let sdk = null; 

            const startPublish = async function() {
                const videoElement = $('#rtc_media_player')[0];

                
                try {
                    const stream = await navigator.mediaDevices.getUserMedia({
                        video: {
                            width: { ideal: 3840 }, // 4K
                            height: { ideal:  2160}, // 4K
                            frameRate: { ideal: 60, max: 120 } // 
                        },
                        audio: true // 
                    });

                  
                    if (sdk) {
                        sdk.close();
                    }

                    sdk = new SrsRtcPublisherAsync();
                    videoElement.srcObject = stream;
                    sdk.stream = stream; 

                    const url = "webrtc://xxxxxx";
                    await sdk.publish(url); 
                    console.log("success!");
                    alert("success");
                } catch (error) {
                    console.error("failed :", error);
                    alert("failed : " + error.message);
                    if (sdk) sdk.close();
                }
            };

            $("#btn_publish").click(startPublish);
        });
    </script>

srs.sdk.js code

self.constraints = {
        audio: true,
        video: {
            width: {ideal: 3840},
            height: { ideal: 2160 },
            frameRate: { ideal: 60, max: 120 }
            // facingMode: 'environment'
        }
    };

But the actual recording is 720 * 1280 should i need to configure any additional information

@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label Dec 18, 2024
@lichao5585 lichao5585 changed the title Recording with Webview on Android reduces resolution Setting resolution for push and pull streaming using WebRTC is not working ,Android Dec 18, 2024
@suzp1984
Copy link
Contributor

try to set sdk.constraints instead of the sdk.stream before sdk.publish.
And use MediaDevices.getSupportedConstraints to get a list of available constraints.

@lichao5585
Copy link
Author

try to set sdk.constraints instead of the sdk.stream before sdk.publish. And use MediaDevices.getSupportedConstraints to get a list of available constraints.

Still can't do it ,still 720*1280

`<script type="text/javascript">
$(function() {
let sdk = null;

        const startPublish = async function() {
            const videoElement = $('#rtc_media_player')[0];

            try {
                const constraints = {
                    video: {
                        width: 3840, // 4K
                        height: 2160, // 4K
                        frameRate: { ideal: 60, max: 120 }, // 60~120fps
                        facingMode: 'environment'
                    }
                };

                const stream = await navigator.mediaDevices.getUserMedia(constraints);

                if (sdk) {
                    sdk.close();
                }

                sdk = new SrsRtcPublisherAsync();

              
                sdk.constraints = constraints; 

              
                videoElement.srcObject = stream;

                const url = "webrtc://xxxxxx";
                await sdk.publish(url); 
                console.log("Publish success!");
                alert("Publish success!");
            } catch (error) {
                console.error("Publish failed:", error);
                alert("Publish failed: " + error.message);
                if (sdk) sdk.close();
            }
        };

        $("#btn_publish").click(startPublish);
    });
</script>`

@lichao5585
Copy link
Author

The phone itself supports 4K, and I can obtain the resolution of the camera, but I cannot achieve 4K playback during recording

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EnglishNative This issue is conveyed exclusively in English.
Projects
None yet
Development

No branches or pull requests

3 participants