push browser camera to aws rtmp server

0

i am using python and in frontend javascript.

I am using ffmpeg to push video to rtmp server.

ffmpeg -y -f mp4 -stream_loop -1 -re -i myvideo.mp4
-b:v 3M -vcodec libx264 -r 30.0 -s 1280x720
-c:a copy -b:a 96k
-f flv "rtmps://dfdf222.global-contribute.live-video.net:443/app/"

I test with OBS software, it is working well. It is working well but I am not getting how to push to rtmp server of my browser camera? i mean from javascript?

i am trying like this:

<body>
    <video id="vid" autoplay></video>

    <a href="#" onclick="streamVideo()">open and stream</a>

    <script>
        function streamVideo () {
            console.log('ddd')
            navigator.mediaDevices.getUserMedia({
            video: {

            },
            audio: {
                
            }
            }).then(stream=>{
                console.log(stream)
                document.getElementById('vid').srcObject = stream; 
            })

        }
    </script>
</body>

It is working but not getting any way to push from browser to rtmp server. I know browser doesnt support rtmp protocol, we need to send it from the backend but can I push it to the server so that it pushes to rtmp server?

Does anyone know the way?

已提問 2 年前檢視次數 375 次
2 個答案
0

Apologies for late response.

While I'm unsure how the ffmpeg has been implemented/integrated into your javascript framework, I believe you would have known about the ffmpeg guide https://trac.ffmpeg.org/wiki/Capture/Webcam explains how to access the webcam while using the various OS.

With that said, you may consider trying out the recently released IVS Web Broadcast SDK, which provides the off-the-shelf solution you may need and reduces complication. As the term, the Web Broadcast SDK works within the browser and does not require a backend server to stream into IVS.

The following guide helps you to know all about the Web Broadcast SDK https://aws.github.io/amazon-ivs-web-broadcast/docs/sdk-guides/introduction

I hope this helps. :)

AWS
已回答 2 年前
-1

Hi,

You may have to include both Stream URL and the Stream key in the FLV endpoint:

Example FFmpeg command:

ffmpeg -re -1 -i $VIDEO_FILEPATH -r 30 -c:v libx264 -pix_fmt yuv420p -profile:v main -preset veryfast -x264opts "nal-hrd=cbr:no-scenecut" -minrate 3000 -maxrate 3000 -g 60 -c:a aac -b:a 160k -ac 2 -ar 44100 -f flv rtmps://**INGEST_ENDPOINT**:443/app/**STREAM_KEY**

Please refer the following document for more details: https://docs.aws.amazon.com/ivs/latest/userguide/getting-started-set-up-streaming.html#ffmpeg

AWS
已回答 2 年前
  • Hi, You have not understand questions, i am not streaming recorded videos ! I want to live stream my webcam. like when user signup to my application, they can go live. but I am not getting any way to push from browser to rtmp. can you please help in this case?

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南