Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    James Causon
    @xCausxn
    I guess I would just need to create a websocket similar to apprtc?
    Jeremy Lainé
    @jlaine
    What do you mean by "using a websocket"?
    James Causon
    @xCausxn
    I think I have somewhat done that part now
    Fairly hacky but works
    async def create(self):
            message = {
                'janus': 'create',
                'transaction': transaction_id(),
            }
    
            # connect to websocket
            self._websocket = await websockets.connect(self._root_url)
            await self._websocket.send(json.dumps(message))
    
            print(f"Waiting for {message['transaction']}")
    
            while self._sessionId is None:
                response = await self.receive()
                if response["transaction"] == message["transaction"]:
                    self._sessionId = response["data"]["id"]
                    print(f"Found transaction {message['transaction']}")
    
    
            self._poll_task = asyncio.ensure_future(self._poll())
    Sorry for the late reply, busy week in work :)
    recorder = MediaRecorder("rtmp://live-lhr.twitch.tv/app/live_STREAMKEY", format='flv')
    Is that the correct way to use the mediarecorder?
    Jeremy Lainé
    @jlaine
    I think so yes @xCausxn though I have to admit I have no direct experience with RTMP
    Italo José
    @italojs
    Guys, I'm need so much help, I need t do a project to: send a video to server -> process the frame -> send a response back as a STRING.
    I'm using the server example https://github.com/aiortc/aiortc/tree/master/examples/server it's works great to send frame to server and get a FRAME back
    but i need send a string as a response, how can I do it? please, help me, I'm trying to make it all the day, tks
    Jeremy Lainé
    @jlaine
    what does that even mean "send a response back as a string"?
    a response to what?
    what does the string contain?
    if you mean "submit a frame over HTTP and get a string response back": no point in using aiortc :)
    Italo José
    @italojs
    ok, I need respond to the browser a string contain the position abour the face pose, so, I receive a webcam frame(with a face) from browser in my server.py, my server process this image to get the face position (front, up, down...), so I need send to browser back a response with this position
    I already get the position, but my problem is, how can I send it to browser?
    Jeremy Lainé
    @jlaine
    datachannels are an option
    Italo José
    @italojs
    Instead another frmae
    ok , datachannels...
    @pc.on('track')
        def on_track(track):
            log_info('Track %s received', track.kind)
    
            if track.kind == 'audio':
                pc.addTrack(player.audio)
                recorder.addTrack(track)
            elif track.kind == 'video':
                local_video = VideoTransformTrack(track, transform=params['video_transform'])
                pc.addTrack(local_video)
    
            @pc.on('datachannel')
            def on_datachannel(channel):
                @channel.on('message')
                def on_message(message):
                    if isinstance(message, str) and message.startswith('ping'):
                        channel.send('pong' + message[4:])
    this?
    Jeremy Lainé
    @jlaine
    you'll want to get rid of VideoTransformTrack / pc.addTrack(local_video) since you don't want to send back any video
    instead you'll want a loop that consumes incoming video frames, does whatever you want to do then sends your message over "channel"
    Jason Hunter
    @hunterjm
    You’ll also want to initiate the data channel since you are sending the data, not responding to a message over the data channel.
    Jeremy Lainé
    @jlaine
    hi Jason :)
    Jason Hunter
    @hunterjm
    Hi Jeremy 😁
    I’ve got some SRTP questions for you later 😉
    Jeremy Lainé
    @jlaine
    that's kind of up to you but indeed it seems more logical to have the server create a data channel, that way you're not dependent on in which order you receive the datachannel / the remote video
    "later" had better be soon, it's 11:20PM in my TZ
    Italo José
    @italojs
    yeah, but I need tranform the image, so, I will remove the pc.add_track, but need stil use the class VideoTransformTrack(VideoStreamTrack):
    right?
    Jason Hunter
    @hunterjm
    The reply can be async, so long as you don’t forget about me. I’ll DM since it’s not strictly aiortc related 😁
    Italo José
    @italojs
    but I dont understand a thing, who recv() is responding?
    Italo José
    @italojs
    I guess i finally get it
    guys, soooory so much by my despair, it's a SUPER importatn feature to company and my job depends from it ahahaha
    sorry so much, I know that people is boring to help
        @pc.on('track')
        def on_track(track):
            if track.kind == 'video':
                local_video = VideoTransformTrack(track, transform=params['video_transform'])
                pc.addTrack(local_video)
    
            @pc.on('datachannel')
            def on_datachannel(channel):
                @channel.on('message')
                def on_message(message):
                    channel.send(str(local_video.getR()))
    this is my final code
    Ghost
    @ghost~5cfd2d3dd73408ce4fc29567
    hey all
    qube13
    @qube13

    Hey all, I have a short question, that I hope you can maybe guide me in the right direction.

    I want to implement a camera-service in python that distributes a live stream of a USB-Camera to other services. I want to do this without an internet connection over the local network. I have two other services that use the stream, a classification service, in python and a front-end that displays the live stream written in html and javascript.

    You can find the whole question here: https://stackoverflow.com/questions/56582908/webrtc-connection-on-localhost-without-an-internet-connection

    without an internet connection, the streaming with aiortc between the python services works without any problems
    but the streaming between the camera service and the front-end in javascript does only work with an internet connection
    Jeremy Lainé
    @jlaine
    "it doesn't work" is usually a poor start to get help :)
    Can you describe what does happen? Is SDP exchanged between the peers?
    Have you tried running the server in verbose mode?
    Is the "server" machine firewalled?
    qube13
    @qube13
    the javascript does not complete the ice gathering
    in chrome I dont get any error message but when I run it in Firefox I get the message "ICE failed, see about:webrtc for more detail"
    When I comment the part in javascript where the ice gathering is completed:
           return new Promise(function(resolve) {
                if (pc.iceGatheringState === 'complete') {
                    resolve();
                } else {
                    function checkState() {
                        if (pc.iceGatheringState === 'complete') {
                            pc.removeEventListener('icegatheringstatechange', checkState);
                            resolve();
                        }
                    }
                    pc.addEventListener('icegatheringstatechange', checkState);
    then the sdp is exchanged but the video stream is not transferred
    qube13
    @qube13
    About the firewall I am not sure, but I run everything on localhost on one PC, so I think there should not be any firewall issues
    Andrew Kralovec
    @AndrewKralovec

    Hey guys,

    Im new to the project, and was hoping for some advice.
    I'm trying to use aiortc allow two clients (browser webcams) to connect to the server, and have the server broadcast both ( and it will only ever be two), video streams to each user. So they can see each other. What example on github would best help me with this ? I was thinking about merging webcam & apprtc. I'll be honest though. Im unsure how to convert the image reciver to a media player. Any advice would be appreciated.

    Tomasz Rojek
    @trojek
    @italojs Did you try to send message to the browser using WebSockets?
    You can use socket.io which works both on python and javascript