Giter Club home page Giter Club logo

Comments (2)

sylyt62 avatar sylyt62 commented on May 24, 2024

I tried MediaPlayer() as well, it can play the .wav file properly.
I looked into the code, and found out that there's a resampler inside.

audio_resampler = av.AudioResampler(

But in my use case, the audio data is sent in streaming (one chunk for one video frame), so I cannot use MediaPlayer.

from aiortc.

sylyt62 avatar sylyt62 commented on May 24, 2024

Solved.

@jlaine Seems like aiortc wouldn't create sdp offer according to specific tracks. I added an audio track with sample rate 16k and ptime 40ms to peerconnection, but the generated offer still contains the default atributes:

m=audio 61921 UDP/TLS/RTP/SAVPF 96 0 8
c=IN IP4 2.0.0.1
a=sendrecv
a=extmap:1 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:2 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=mid:1
a=msid:7efcc2eb-a421-41b5-8aed-dd5914c45052 b3c4a814-0993-42bb-a5d6-fb32d37c902d
a=rtcp:9 IN IP4 0.0.0.0
a=rtcp-mux
a=ssrc:2645354522 cname:eee68eb0-1a58-49c2-9fe7-a6ab3c3db647
a=rtpmap:96 opus/48000/2
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000

I simply changed the line:

def change_sdp(sdp):
    target = 'a=rtpmap:96 opus/48000/2'
    update = 'a=rtpmap:96 opus/16000/1\r\na=fmtp:96 minptime=40;useinbandfec=1'
    return sdp.replace(target, update)

And the sound can be played properly.

from aiortc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.