bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
11.65k stars 1.47k forks source link

Corrupt AAC decoding with Media Foundation Client #112

Closed jazzy348 closed 3 years ago

jazzy348 commented 3 years ago

Which version are you using?

v0.12.0

Which operating system are you using?

Windows / Linux

Describe the problem

When using a client built around the Media Foundation API, video comes through fine but audio is corrupt and glitchy, is there a work around for this?

Kind regards, Jazzy.

aler9 commented 3 years ago

Hello,

  1. try disabling UDP and see if there's a difference:

    protocols: [tcp]
  2. i need additional details to replicate this:

    • is the Media Foundation API-based client publishing or reading?
    • if the Media Foundation API-based client is publishing, who is reading, or vice-versa?
jazzy348 commented 3 years ago

Hi,

I've tried TCP only, this did not solve the issue.

Client is reading, FFMPEG is publishing. Command to publish is

ffmpeg -re -i sample.mp4 -c:a aac -c:v libx264 -f rtsp rtsp://xxxx

aler9 commented 3 years ago

Can you post a sample code of the client in order to allow me to replicate the issue? it's not an easy task to build a client from scratch, so i need the code. Thanks

jazzy348 commented 3 years ago

Hi,

The only client I have is Unity based, trial package can be downloaded from here: http://downloads.renderheads.com/2020/UnityPlugin-AVProVideo-Latest-Trial.unitypackage

Sorry for the work!

asleeponduty commented 3 years ago

Sorry to bump an old issue, but was this resolved on either of your ends? I am seeing the same issues @jazzy348 is having as well. Current version running is 0.15.5 Same setup as well - using the Media Foundation player in Unity via the AVPRO bindings. Like Jazzy, ffplay/vlc/mpv do not have any issues with playback. Likely this is because these don't use the media foundation api as their backend.

The simplest way to test if the stream is working is to install Unity2019 and import the package as linked above by Jazzy. I've confirmed this package can work with RTSP streams by opening one from a Wowza server with the same encoding.

asleeponduty commented 3 years ago

Attached, for convenience, is the PCAPS comparing this against wowza when the client is this Media Foundation player RTSP-PCAP.zip

Please reach out if you would like more information

jazzy348 commented 3 years ago

Hi, we did manage to resolve the issue. In SDP set "MPEG4_GENERIC" to lower case and set track 0 to be audio, track 1 for video. This is not an issue with RTSP-Simple-Server but an annoyance with AVPro.

See https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/653

asleeponduty commented 3 years ago

@aler9 Looking through Jazzy's linked issue, it seems like the SDP is not in compliance for the mpeg4 MIME -

From AndrewRH:

[...] Unfortunately the code that handles RTSP is inside Microsoft's Media Foundation DLLs so we cannot change this behaviour. Hopefully your server can instead send lower-case version.

I'm also not sure that uppercase is valid. Looking at the documentation:

Here you can see the list of mime-types, and while many are uppercase, mpeg4-generic is lower-case: https://www.iana.org/assignments/media-types/media-types.xhtml https://www.iana.org/assignments/media-types/video/mpeg4-generic https://tools.ietf.org/html/rfc5691#section-5.2

I'm not certain that RFC 2045 section 5.1 applies to SDP.

I've referenced this in an issue for you over in your library where this happens https://github.com/aler9/gortsplib/issues/35

github-actions[bot] commented 1 year ago

This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.