Excessive number of chunks when streaming to MediaMTX
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 15/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Tranquilla
- Ambito
- mobile-dev, networking
Direzione di ricerca
The report gives no reproduction steps beyond streaming to MediaMTX, so start by reading the code it quotes: GenericStream setup, getStreamClient().setBitrateExponentialFactor(0.5f), the BitrateAdapter callback calling setVideoBitrateOnFly, and startStreaming calling genericStream.startStream. Done would mean identifying which of these changes bitrate or chunk sizing under poor LTE conditions, backed by a reproduction or test. The thread has no maintainer decision yet, so confirm the approach in the comments before writing code.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
When streaming to MediaMTX we see randomly excessive number of chunks recorded.
When streaming from an application created with RootEncoder we are randomly seeing excessive number of chunks (about 7000 in one instance) when recording the streaming. The same is observed on HLS streamed from the server.
The client (device) is an android phone with RootEncoder app. It is streaming over LTE(4g) mobile network with h264/720p/1.6 Mbps CBR.
The behaviour is observed on different quality of network connectivity (not only poor). We do not have control over location, quality of connectivity of the device doing the streaming.
We have 60 ingest servers (mediamtx handling incomming rtmp traffic) and the clinets are more or less equally distributed on them. Top planned load per server is 200 streams, and we are doing extremely minimal processing (e.g. appending a bit of metadata with ffmpeg, calling few curls to external services). Servers in and of themselves are not overloaded. Usuall observed load is in the range of 90% - 95%
code is mostly:
/**
* StreamActivity is responsible for handling the camera preview and video streaming functionality.
* It utilizes the RootEncoder library for streaming video and audio data.
* This activity implements the ConnectChecker interface to handle streaming connection events.
*/
class StreamActivity : ComponentActivity(), ConnectChecker, Loggable {
//region PROPERTIES ⤵
private lateinit var viewModel: StreamActivityViewModel
/**
* Lazy-loaded instance of GenericStream, used for handling video and audio streaming.
* Sets automatic orientation handling and adjusts bitrate based on network conditions.
*/
val genericStream: GenericStream by lazy {
GenericStream(this, this).apply {
getGlInterface().autoHandleOrientation = true
getStreamClient().setBitrateExponentialFactor(0.5f)
}
}
private var _binding: ActivityStreamBinding? = null
private val binding get() = _binding!!
private val width = 1280 // Video resolution width
private val height = 720 // Video resolution height
private val vBitrate = 1500 * 1000 // Video bitrate in bps
private var rotation = 0 // Video rotation angle
private val sampleRate = 44100 // Audio sample rate
private val isStereo = false // Stereo audio configuration(Mono)
private val aBitrate = 48 * 1000 // Audio bitrate in kbps
private var recordPath = "" // Path for saving recorded video
private val fps = 20 // Frames per second
private var timerJob: Job? = null
private var broadcastStartTime: Long = 0L
private var checkBatteryLevelTimer: Timer? = null
private val handler = Handler(Looper.getMainLooper())
private val orientationHelper = OrientationHelper()
private val section: Section = getCurrentSection()
private val backPressHandler = Handler(Looper.getMainLooper())
private var currentToast: Toast? = null
private var backPressedOnce = false
private var soundLevelJob: Job? = null
private var microphoneSourceWrapper: MicrophoneSourceWrapper? = null
private var startingTime: Date = Date()
// Bitrate adapter to dynamically adjust bitrate based on bandwidth conditions
private val bitrateAdapter = BitrateAdapter {
genericStream.setVideoBitrateOnFly(it)
}.apply {
setMaxBitrate(vBitrate + aBitrate)
}
/**
* Initiates streaming if not already active.
*
* @param rtmpUrl The RTMP URL to stream to.
*
*/
private fun startStreaming(rtmpUrl: String) {
logInfo("Start streaming to -> $rtmpUrl")
if (!genericStream.isStreaming) {
binding.apply {
genericStream.startStream(rtmpUrl)
}
}
}
To Reproduce
Start streaming against mediamtx
Expected behavior
Normal streaming with no chunking except in extremely lossy conditions (e.g. very bad 4/5G connectivity)
Smartphone (please complete the following information):
- Library version: 2.6.1
- Device: motorola moto e13
- OS: android 13
- Media server: MediaMTX 1.7.0
- Class used [e.g. RtmpCamera1]
Additional context
Cross posted to Mediamtx: https://github.com/bluenviron/mediamtx/issues/5810
- Lingua principale
- Kotlin
- Stelle
- 3k
- Fork
- 946
- Merge medio
- 5g 1h
- PR unite (30g)
- 6
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pedroSG94/RootEncoder
-
Scheme-less stream URLs throw NullPointerException instead of URISyntaxExceptionForse già presa @blihio l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
pedroSG94/RootEncoder#2218 ·
I maintainer di solito rispondono entro 3 giorni
-
Nullable GIF input causes NullPointerException in GifStreamObject.loadForse già presa @blihio l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
pedroSG94/RootEncoder#2216 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
pedroSG94/RootEncoder#2213 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
pedroSG94/RootEncoder#2207 · 1 reazione ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
pedroSG94/RootEncoder#2203 ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di pedroSG94/RootEncoder
Issue simili
-
bug follow-up
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
binding:web core docs p3
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
RunanywhereAI/runanywhere-sdks#1123 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
openai/openai-java#1202 ·
I maintainer di solito rispondono entro 1 giorno
-
StepExamBenchmarkTest runs a loop and prints a timing but asserts nothingForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertajules
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
open-learning-exchange/myplanet#18199 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno