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
Metadata issue leading to out-of-sync audio after recording on server #1410
Comments
What will happen with specifying fcPublishName pattern in this branch? Will it be similar? https://github.com/shogo4405/HaishinKit.swift/pull/1414/files |
I confirmed it with VideoLAN and ffplay, but I couldn't notice any delay between the video and audio. How are you playing it? |
Hi @shogo4405, thank you for the quick reply.
Unfortunately I still see the issue when using this newer version.
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 :-) |
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. |
Unfortunately, I'm struggling to reproduce it on my end.
|
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. |
Just a thought after looking at the change, before the change FCPublish was called right after cleaning the timestamps with |
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. |
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. |
I now have a way to reliably reproduce this issue. I've created a simple project that runs There are two RTMP end points in this project, @zachsimone was able to confirm my findings. Recordings made to the 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. |
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. If possible, could you provide the code to delay nginx? My email is shogo4405@gmail.com. |
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 Please let me know if I can provide you with any more details or answer anymore questions. |
@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 |
@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. |
[TBA] refs #1410 add metadata to duration.
Thank you for your confirmation and for providing the reproduction steps. I have merged the revised version. |
Describe the bug
When live streaming, we record the stream so we can send it off later to be transcoded and stored allowing people to re-watch it after the fact. We've noticed that since the HaishinKit 1.7.5 update, specifically commit 3052fce, the audio and video are out of sync on this recorded video. It is fine while live. When we revert commit 3052fce, things are fine again.
Using MediaInfo (I'll attach screenshots below), we notice there's an error
Missing ID_END
that shows on a file where the audio and video are out of sync. This could be a clue as to what's going wrong. Note that the error doesn't show using the earlier version (1.7.4) of HaishinKit.I note the above suggestion from the 1.7.5 release notes, and have tried both of these methods to set the
fcPublishName
to what it was being set to, but with no success. I wonder if it's got to do with the order changing for when the publish command is sent.To Reproduce
fcPublishName
Note that it doesn't happen every time, but it seems like it's more easily reproducible when the audio source is external (e.g. AirPods).
Expected behavior
Audio and video in sync on the recording, like it behaves when using 1.7.4.
Version
1.7.5
Smartphone info.
Reproducible on multiple devices running iOS 17.3, including iPhone 15 Pro, 15 Pro Max, iPhone 13 Pro, iPad Pro 11" 3rd gen.
Additional context
No response
Screenshots
Screenshots showing the MediaInfo differences when using 1.7.4 vs 1.7.5. Also attached 2x recordings (inside
Recordings.zip
) showing a recording with 1.7.4 vs 1.7.5.Recordings.zip
Relevant log output
No response
The text was updated successfully, but these errors were encountered: