Git Product home page Git Product logo

Comments (16)

alexmck avatar alexmck commented on June 9, 2024 4

@shogo4405 your PR #1446 fixes the issue in my testing.

Thank you for your patience, diligence, and perseverance in getting this bug fixed. πŸ™ It certainly was a tricky one to reproduce.

from haishinkit.swift.

alexmck avatar alexmck commented on June 9, 2024 1

I now have a way to reliably reproduce this issue. I've created a simple project that runs nginx-rtmp-module inside of a Docker container and a simple Node server to validate RTMP stream requests: https://github.com/alexmck/docker-nginx-rtmp

There are two RTMP end points in this project, /live which does not send a request to authorise a stream, and /delay which adds an artificial 2 second delay while it authorises a stream.

@zachsimone was able to confirm my findings. Recordings made to the /live RTMP endpoint had no audio and video sync issues, while some recordings to the /delay RTMP endpoint did exhibit audio and video sync issues. I should note that in our testing, it wasn't every stream to the /delay endpoint. In my testing with the sample HaishinKit app, I found that a second stream would often have a recording that would exhibit the audio and video sync issues. Zach said in his testing it was anywhere from the 2nd to 6th test stream.

The significance here is that many live streaming platforms authorise an RTMP stream before allowing the user to stream, while users who are streaming with 4G and poor latency may also exhibit the same problem even without authorisation from the server.

Please let me know if there is anything else I can do to help resolve this issue or if you have any questions about my testing methodology.

from haishinkit.swift.

alexmck avatar alexmck commented on June 9, 2024 1

Thanks for your attempted fix. I have tested this branch but unfortunately the bug still exists. Zach was also still able to reproduce this issue with this branch.

To delay the stream in nginx, I am using the on_publish directive in my nginx.conf. This on_publish method sends an HTTP request to a simple Node HTTP server I set up which adds a 2 second delay before allowing the stream to continue. My server.js file runs the simple HTTP server that adds this 2 second delay.

Please let me know if I can provide you with any more details or answer anymore questions.

from haishinkit.swift.

shogo4405 avatar shogo4405 commented on June 9, 2024 1

Thank you for your confirmation and for providing the reproduction steps. I have merged the revised version.

from haishinkit.swift.

shogo4405 avatar shogo4405 commented on June 9, 2024

I tried analyzing the received FLV file. It seems that there is one audio header information before and after the metadata. There seem to be cases where it works and cases where it doesn't. Could you please provide the FLV file that worked when it was successful?

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2024-04-08 22 22 57

from haishinkit.swift.

shogo4405 avatar shogo4405 commented on June 9, 2024

What will happen with specifying fcPublishName pattern in this branch? Will it be similar? https://github.com/shogo4405/HaishinKit.swift/pull/1414/files

from haishinkit.swift.

shogo4405 avatar shogo4405 commented on June 9, 2024

I confirmed it with VideoLAN and ffplay, but I couldn't notice any delay between the video and audio. How are you playing it?

from haishinkit.swift.

zachsimone avatar zachsimone commented on June 9, 2024

Hi @shogo4405, thank you for the quick reply.

What will happen with specifying fcPublishName pattern in this branch? Will it be similar? https://github.com/shogo4405/HaishinKit.swift/pull/1414/files

Unfortunately I still see the issue when using this newer version.

I couldn't notice any delay between the video and audio. How are you playing it?

My apologies, I didn't check before uploading and uploaded the wrong files. Attaching new recordings below. One is definitely out of sync, and the other is working well. The problematic one is noted in the file name. I'm playing them back using VLC on macOS.

Please let me know if I can provide any more information that might be helpful here :-)

Recordings.zip

from haishinkit.swift.

shogo4405 avatar shogo4405 commented on June 9, 2024

This is an image showing a dump of the contents of an FLV file. It can be observed that the timestamp of the data starts from 579, indicating a misalignment. Applications like VideoLAN tend to adhere to this timestamp, resulting in a discrepancy between the video and audio. It's implemented in https://github.com/shogo4405/HaishinKit.swift/tree/main/Examples/macOS.

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2024-04-12 10 17 51

from haishinkit.swift.

shogo4405 avatar shogo4405 commented on June 9, 2024

Unfortunately, I'm struggling to reproduce it on my end.
I'm testing it in the following environment. Would the same issue occur in the Example iOS?

  • iPhone15 Pro max + AirPods Pro + 44100.0 khz
  • main branch: 1c24433
  • Example iOS
% brew info rtmp-nginx-module
==> marcqualie/nginx/rtmp-nginx-module: stable 1.2.2-r1
NGINX-based Media Streaming Server
https://github.com/sergey-dryabzhinsky/nginx-rtmp-module
/opt/homebrew/Cellar/rtmp-nginx-module/1.2.2-r1_3 (94 files, 1.4MB) *
  Built from source on 2023-11-02 at 01:54:03
From: https://github.com/marcqualie/homebrew-nginx/blob/HEAD/Formula/rtmp-nginx-module.rb

from haishinkit.swift.

zachsimone avatar zachsimone commented on June 9, 2024

Thanks @shogo4405. Just a quick note to let you know I haven't forgotten about this and I'm trying to find a good way to reproduce that is decoupled from our streaming infrastructure. I'll let you know when I have more info.

from haishinkit.swift.

levs42 avatar levs42 commented on June 9, 2024

Just a thought after looking at the change, before the change FCPublish was called right after cleaning the timestamps with dataTimestamps.removeAll(). Now it's triggered from from createStream by handling NetStream.Connect.Success event. Maybe if there's a longer network delay before the createStream is triggered, the timestamps will accumulate the delay? Manually delaying createStream call would confirm that.

from haishinkit.swift.

alexmck avatar alexmck commented on June 9, 2024

Thank you @levs42. That gives me something to test to confirm this theory, and actually makes some sense as to why we might be seeing this issue.

from haishinkit.swift.

alexmck avatar alexmck commented on June 9, 2024

I believe I now have a method to consistently reproduce this error. I'm going to sanity check it with Zach and we will come back.

from haishinkit.swift.

shogo4405 avatar shogo4405 commented on June 9, 2024

If dataTimestamps is the cause, I believe I can improve it with this commit. There is a race condition because lockQueue is used within send(), but I believe we have a 100% reset understanding here. Please confirm.
main...feature/fix-outof-sync
https://github.com/shogo4405/HaishinKit.swift/tree/feature/fix-outof-sync

If possible, could you provide the code to delay nginx? My email is [email protected].

from haishinkit.swift.

shogo4405 avatar shogo4405 commented on June 9, 2024

@alexmck I was able to reproduce the issue using the method you introduced. Thank you. #1410 (comment)

I have confirmed that the issue is improved with this PR on my end. Please check if it works the same in your environment.#1446

from haishinkit.swift.

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.