Skip to content

Slightly reduced AudioRenderThread sleep duration#30

Open
LukasKastern wants to merge 1 commit intobakjos:masterfrom
LukasKastern:Audio-Crackling-Bug
Open

Slightly reduced AudioRenderThread sleep duration#30
LukasKastern wants to merge 1 commit intobakjos:masterfrom
LukasKastern:Audio-Crackling-Bug

Conversation

@LukasKastern
Copy link
Copy Markdown

This fixes a permanent crackling sound we did hear which was caused by samples missing for some frames.
Slightly nuding the sleep duration down fixed the issue

This fixes a bug where audio samples are missing for some frames and a crackling sound is played
int64_t dif = endTime - startTime;
if ( dif < 33333) {
av_usleep(33333 - dif);
if ( dif < 32333) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this value, and I think we should calculate it based the audio FPS instead of a fixed value, what do you think? IN your case, what's the FPS ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure about the FPS, we've tested a lot of different videos and all had the same behaviour which was fixed after lowering that value (we also tested RTMP streams).

I guess this value should indeed be calculated by the video FPS since it also drives the playback speed when the Time control is set to audio.

@kabassmusic
Copy link
Copy Markdown

kabassmusic commented May 24, 2021

Hello. I found this plugin this week and came here to say that fix didn't solve the audio stuttering for me.
I was using a M3U8 live feed. Tried with multiple feeds from different sources. Same issue.

@bakjos
Copy link
Copy Markdown
Owner

bakjos commented May 24, 2021

@kabassmusic do you have the link to the m3u8 feed and is it public? if not can you give me details about the audio FPS and codec? does it help if you decrease the wait even more? and are you using the audio or video for the sync?

@kabassmusic
Copy link
Copy Markdown

kabassmusic commented May 24, 2021

@kabassmusic do you have the link to the m3u8 feed and is it public? if not can you give me details about the audio FPS and codec? does it help if you decrease the wait even more? and are you using the audio or video for the sync?

I was using this HLS demo I found online for testing. https://vd1.wmspanel.com/video_demo/stream/playlist.m3u8

I was using the Audio Master. Video Master made the audio almost nonexistent.

I tried decreasing it to a crazy amount like 333.

@LukasKastern
Copy link
Copy Markdown
Author

The demo you send is working fine for us @kabassmusic . We are capping our game to 60fps could it be related to that @bakjos?

@kabassmusic
Copy link
Copy Markdown

kabassmusic commented May 25, 2021

Interesting. I tried capping the fps to 60 and even 30. The sleep duration is at 32333, compiled.
I even used this MP4 stream with the same results. https://docs.unrealengine.com/Attachments/WorkingWithMedia/MediaFramework/HowTo/StreamMediaSource/Infiltrator%20Demo.mp4

Enabled settings are:
Allow Frame Drop (Enabled or Disabled doesnt fix it)
Use Hardware Accelerated Codecs
Zero Latency Streaming (Also doesnt fix it if enabled/disabled. )
Audio Master

Ran it in Selected Viewport, and Standalone too.

EDIT:
However, I tried this m3u8 stream and it seems pretty fast even after capping the game to 30FPS
http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear2/prog_index.m3u8

@LukasKastern
Copy link
Copy Markdown
Author

Hello again! It seems like this 'fix' only worked with 4.25.4 which was the version we used with commit 517b328.

In UE 4.26.2 and the latest master, we hear that sound bug again (with and without this fix).
I couldn't find any substantial changes in the commit history which make me wonder if something in the way Unreal consumes the audio samples changed that could've broken something.

@kabassmusic
Copy link
Copy Markdown

kabassmusic commented Jul 6, 2021

Very interesting. Glad you were able to figure out it was Unreals fault at least. I was wondering how you got it to work. I'm gonna try this in a 4.25.4 project now then.

Oh, just realized it won't compile for 4.25 using the latest version.

@kabassmusic
Copy link
Copy Markdown

kabassmusic commented Jul 6, 2021

UPDATE: After downloading the version you provided where that commit is and after changing location errors of some includes of that version, I have successfully got it to work on 4.25.2.

I also didn't use this fix either and it sounds fine to me now. Way better than with 4.26.

But that version doesn't compile with 4.26.

Another thing I realized is that versions video is faster than the audio when selecting Audio Master. But the video plays fine if it's the Video Master. Could there be a way to combine the effects of Audio and Video Master so that they are equally timed?

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

Successfully merging this pull request may close these issues.

3 participants