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

RtmpFromFile streaming Video/Audio sync issue #1315

Closed
duyminhnguyen97 opened this issue Oct 30, 2023 · 11 comments
Closed

RtmpFromFile streaming Video/Audio sync issue #1315

duyminhnguyen97 opened this issue Oct 30, 2023 · 11 comments

Comments

@duyminhnguyen97
Copy link

duyminhnguyen97 commented Oct 30, 2023

Hi @pedroSG94,

I'm currently working on streaming video file from mobile device to streaming platforms such as Facebook, YouTube, or TikTok,... However, I noticed a problem with syncing video and audio, since audio always goes faster than video, and the video constantly stutter. I tried different bitrates and some modifications but it still happens. What settings and parameters do I have to change to reduce the desync between them? Do you have any idea what caused the desync?
I'm currently using RtmpFromFile v2.3.0, tested with Android studio emulator Pixel 4 API 31 device. Please let me know if you need anything.

Thanks in advance!

@pedroSG94
Copy link
Owner

Hello,

Please try with this branch using the app sample and let me know if the problem persist:
#1314

After that, if the problem persist share me a video to reproduce the problem and device Model/Android version

@duyminhnguyen97
Copy link
Author

Hi,

Thank you for your response. Your branch fixed the sync problem for me perfectly! However, the stutter problem is still there. Do you have any idea what caused this? Will it be an internet problem or a config problem?
Here is a video of the stream I tested. Sometimes (rarely) it can go smooth like this but most of the time it will be flashing and stuttering like this
I tested with Android studio emulator Pixel 4 API 31 Android 12. I set the video bitrate 3500 * 1024 and the audio bitrate 128 * 1024

Thanks in advance!

@pedroSG94
Copy link
Owner

The audio error sometimes happens for use google audio encoder (the only one on fews emulators):
https://github.com/pedroSG94/RootEncoder/blob/master/encoder/src/main/java/com/pedro/encoder/utils/CodecUtil.java#L437
If you are streaming to YouTube try with normal delay instead of low/ultralow delay. This can help you solve the issue.

If you can reproduce the problem in other platform. Let me know which platform and stream configuration in the platform.

@duyminhnguyen97
Copy link
Author

duyminhnguyen97 commented Nov 1, 2023

I'm encountering a very odd case with your fix/fromfile-video-no-audio branch. This time I tested my app with a physical mobile device (Samsung A50 Android 11). I tried with a random video I recorded previously (mp4, 1080p). The stream worked fine (still a little bit stutter) until a few hours ago. At first, the loop mode seemed to break when it cut out the last few seconds of my video (a 2mins video was cut for 10s, and a 10mins video was cut for over a minute). I tried again now without the loop mode. Then it didn't stream anymore. I opened the logcat and I saw sometimes the AudioDecoder said "end of file", and sometimes it's the VideoDecoder, even if I had just started streaming (sometimes after a few seconds). Here is an example logcat. This video is 2mins long and the stream ended after 30s, then the VideoDecoder log "end of file". And now this happened with and without loop mode. Can you help me with this problem? :(

@pedroSG94
Copy link
Owner

Hello,

Can you share me a video example with this problem to test it?

@duyminhnguyen97
Copy link
Author

Hi,

While recording examples for you I found out that this bug only happened with 1080p videos! I tried with 720p video and it works perfectly fine. At first, I tested with this video but other 1080p videos also faced the same problem. When I downgraded this video to 720p it streamed normally. Can you fix this problem since most recorded videos nowadays are in 1080p

Thanks in advance!!!

@pedroSG94
Copy link
Owner

Hello,

I detected an error related with your case and I fixed it in the last commit:
ed8c6d9
Please, get last commit and use from file rtmp example to test if the problem is solved. If not, let me know how to reproduce the case using my app example and share me a video if you can't reproduce it using that video.

I was using the video that you suggested but I downloaded it in 1080p using this web:
https://www.freemake.com/es/free_video_downloader_perfect/

@pedroSG94
Copy link
Owner

About the audio problem. I did a branch for it:
#1321
Test it and let me know if this help with the error

@duyminhnguyen97
Copy link
Author

duyminhnguyen97 commented Nov 2, 2023

Hi,

The problem with 1080p is now fixed! However, the "end of file" problem is still there. You can test with both 1080p and 720p of the video above while streaming on YouTube. Sometimes "end of file" problem happens with audio (logcat), sometimes with video (logcat). The loop also break because of the "end of file" problem since it triggers the loop right away (it continues restarting the video after a few seconds).

@pedroSG94
Copy link
Owner

Hello,

I can't reproduce the error in the app example. Can you tell me how to reproduce it using app example?
Share me a video and tell me steps to reproduce it.

Also, test the branch about the audio problem to know if this solve the error

@pedroSG94
Copy link
Owner

Closing as inactive.

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

No branches or pull requests

2 participants