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

Can support aac codes, which payloadtype=104? #1888

Closed
yourchanges opened this issue Jul 16, 2021 · 10 comments
Closed

Can support aac codes, which payloadtype=104? #1888

yourchanges opened this issue Jul 16, 2021 · 10 comments

Comments

@yourchanges
Copy link

I test on a Hik camera, but can't get the audio works, so please support the aac codecs, thank you!

here is the stream info:

Input #0, rtsp, from 'rtsp://xxx:xxxk@xxxxxx:40052/Streaming/Channels/701':
  Metadata:
    title           : HIK Media Server V4.30.210
    comment         : HIK Media Server Session Description : standard
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: aac, 16000 Hz, mono, fltp

the original audio stream is: " Stream #0:1: Audio: aac, 16000 Hz, mono, fltp"
it seems not h264 standard aac codecs, it will work on webrtc ?

I use pion v2.2.26, it only has

	DefaultPayloadTypePCMU = 0
	DefaultPayloadTypePCMA = 8
	DefaultPayloadTypeG722 = 9
	DefaultPayloadTypeOpus = 111
	DefaultPayloadTypeVP8  = 96
	DefaultPayloadTypeVP9  = 98
	DefaultPayloadTypeH264 = 102

and my HIK media server's audio acc payloadtype is 104, here is rtsp despcrtion

m=audio 0 RTP/AVP 104
 i=Audio Media
a=rtpmap:104 MPEG4-GENERIC/16000/1
a=control:trackID=audio
a=fmtp:104 profile-level-id=15; streamtype=5; mode=AAC-hbr; config=1408;SizeLength=13; IndexLength=3; IndexDeltaLength=3; Profile=1;
b=AS:10
a=Media_header:MEDIAINFO=494D4B48020100000400000101200210401F00000000000000000000000000000000000000000000;
a=appversion:1.0
@yourchanges
Copy link
Author

the number "104" seems is dynamic, but it can be identify by "MPEG4-GENERIC"

@Sean-Der
Copy link
Member

Hey @yourchanges

WebRTC doesn't support AAC unfortunately. You will have to transcode to Opus or PCM.

We could add support to github.com/pion/rtp or maybe add a library that makes transcoding easier, but we can't play AAC in the browser.

@yourchanges
Copy link
Author

yourchanges commented Jul 16, 2021 via email

@yourchanges
Copy link
Author

@Sean-Der

Could you add support to github.com/pion/rtp or maybe add a library that makes transcoding (aac->pcm) easier?

@AngellusMortis
Copy link

WebRTC doesn't support AAC unfortunately. You will have to transcode to Opus or PCM.

Do you have a source on WebRTC not support AAC? I have seen that in a lot of places, but as far as I can tell, AAC support for WebRTC is 100% up to the browser and not required to be supported. Likely because it is not an open codec.

MDN actually says multiple times that the docs they list are only the required ones and that browsers can choose to add more.

This guide reviews the codecs that browsers are required to implement as well as other codecs that some or all browsers support for WebRTC.

The list above indicates the minimum required set of codecs that all WebRTC-compatible endpoints are required to implement. A given browser may also support other codecs; however, cross-platform and cross-device compatibility may be at risk if you use other codecs without carefully ensuring that support exists in all browsers your users might choose.

You can also see on MDN's page for AAC or caniuse that AAC is supported in nearly every browser.

@Sean-Der
Copy link
Member

Hey @AngellusMortis

rfc7874 has Opus, PCMA/PCMU and CN as REQUIRED.

Nothing is stopping WebRTC agents from supporting AAC. However libwebrtc the implementation used in every web browser does not have AAC

If you want to do Pion <-> Pion you can specify AAC in the MediaEngine and send the packets.

@AngellusMortis
Copy link

@Sean-Der thanks for the response. That really helps me fill in the part I was missing. One of my co-workers who knows a bit more about WebRTC also pointed the same thing out.

Browser's WebRTC implementation is 100% separate from their own media implementations so it cannot reuse system codecs and/or other codecs supported from elsewhere. That definitely seems maddeningly annoying.

@Sean-Der
Copy link
Member

@AngellusMortis best of luck on what you are building! I have seen users do AAC -> Opus using cgo, nothing in Pure Go that I know of unfortunately.

If you want to chat/throw ideas my way I am always around in Slack. Best of luck with your project :)

@uharband
Copy link

uharband commented Jun 9, 2022

Hey @AngellusMortis

rfc7874 has Opus, PCMA/PCMU and CN as REQUIRED.

Nothing is stopping WebRTC agents from supporting AAC. However libwebrtc the implementation used in every web browser does not have AAC

If you want to do Pion <-> Pion you can specify AAC in the MediaEngine and send the packets.

Hi @Sean-Der
Just to make sure i understood this, when you say "and send the packets" you mean we need to implement the packetization of AAC audio to rtp (i.e. rfc6416) and add to https://github.com/pion/rtp/tree/master/codecs right?
Thanks,
Uzi

@cedricve
Copy link

cedricve commented May 6, 2023

@Sean-Der Is there any example to transcode an audio channel (AAC) to OPUS/PCM?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants