pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.57k stars 776 forks source link

audio tick noise #1605

Closed Lyman92 closed 1 month ago

Lyman92 commented 1 month ago

I user RtspStream If I set audio samplerate 8000 there is no tick noise but the quality is bad If I set samplerate to 44100 there is tick noise. Is it the problem with MicrophoneMode how to set MicrophoneMode with RtspStream

pedroSG94 commented 1 month ago

Hello,

Using this gradle:

  implementation 'com.github.pedroSG94.RootEncoder:library:f0b9aa3fcb'

Try add this line after create RtspStream class:

rtspStream.setTimestampMode(TimestampMode.BUFFER, TimestampMode.BUFFER)
Lyman92 commented 1 month ago

Thank you so much, It works, is it a temp version? Another question is “Electrical noise generated by background environmental sounds.” on an Android TV, it performs well on Android phone. Any guess for the reason or any suggestions . Thanks

pedroSG94 commented 1 month ago

Hello,

That version is a compilation of a commit that should be available in the next release but for now, it is only available in other branch.

Your noise was caused by the way the library calculate timestamp. By default I calculate the timestamp using the device system clock but using that new method the timestamp is calculated based on the buffer data.

The first way normally is working fine in all cases but in few devices or stream platforms the system clock could produce noise because the timestamp is not totally precise. The second way normally is more precise but could have problems others problems if the audio buffer is not continuous.

Lyman92 commented 1 month ago

Thanks,it's hardware issues maybe。