Optimize video quality settings for 720p/1080p streaming
- Implemented DefaultTrackSelector with forceHighestSupportedBitrate - Configured LoadControl with 30-60s buffer for HD streams - Set initial bandwidth estimate to 5 Mbps for faster HD start - Added quality logging for debugging - Created QUALITY_OPTIMIZATION.md documentation Cambios en PlayerActivity.java: - MaxVideoSize hasta 4K - MaxVideoBitrate sin límite - ExceedVideoConstraintsIfNecessary habilitado - Buffer optimizado: 30s min, 60s max - Inicio rápido: 2s
This commit is contained in:
153
QUALITY_OPTIMIZATION.md
Normal file
153
QUALITY_OPTIMIZATION.md
Normal file
@@ -0,0 +1,153 @@
|
||||
# Optimización de Calidad de Streaming
|
||||
|
||||
## 🎯 Objetivo
|
||||
|
||||
Maximizar la calidad de transmisión para aprovechar resoluciones 720p y 1080p cuando estén disponibles en los streams HLS.
|
||||
|
||||
## 📊 Cambios Implementados
|
||||
|
||||
### 1. **DefaultTrackSelector - Selección Inteligente de Calidad**
|
||||
|
||||
```java
|
||||
DefaultTrackSelector trackSelector = new DefaultTrackSelector(this);
|
||||
trackSelector.setParameters(
|
||||
new DefaultTrackSelector.ParametersBuilder(this)
|
||||
.setMaxVideoSize(3840, 2160) // Hasta 4K
|
||||
.setMaxVideoBitrate(Integer.MAX_VALUE) // Sin límite
|
||||
.setForceHighestSupportedBitrate(true) // MÁXIMA CALIDAD
|
||||
.setExceedVideoConstraintsIfNecessary(true)
|
||||
.build()
|
||||
);
|
||||
```
|
||||
|
||||
**Impacto:**
|
||||
- ✅ Prioriza automáticamente 1080p sobre 720p
|
||||
- ✅ Selecciona 720p sobre 480p cuando disponible
|
||||
- ✅ No limita artificialmente la calidad
|
||||
|
||||
### 2. **DefaultLoadControl - Buffering Optimizado**
|
||||
|
||||
```java
|
||||
DefaultLoadControl loadControl = new DefaultLoadControl.Builder()
|
||||
.setBufferDurationsMs(
|
||||
30000, // Buffer mínimo: 30 segundos
|
||||
60000, // Buffer máximo: 60 segundos
|
||||
2000, // Inicio rápido: 2 segundos
|
||||
5000 // Re-buffering: 5 segundos
|
||||
)
|
||||
.build();
|
||||
```
|
||||
|
||||
**Impacto:**
|
||||
- ✅ Buffers más grandes = menos interrupciones en HD
|
||||
- ✅ Inicio rápido (2s) para buena UX
|
||||
- ✅ Recuperación rápida de buffering (5s)
|
||||
|
||||
### 3. **DefaultBandwidthMeter - Estimación Optimista**
|
||||
|
||||
```java
|
||||
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter.Builder(this)
|
||||
.setInitialBitrateEstimate(5_000_000) // Asumir 5 Mbps inicialmente
|
||||
.build();
|
||||
```
|
||||
|
||||
**Impacto:**
|
||||
- ✅ Empieza con expectativa de HD (720p)
|
||||
- ✅ Se adapta dinámicamente según conexión real
|
||||
- ✅ Evita comenzar en calidad baja innecesariamente
|
||||
|
||||
### 4. **Logging de Calidad (Debug)**
|
||||
|
||||
```java
|
||||
if (player.getVideoFormat() != null) {
|
||||
Log.i("PlayerActivity",
|
||||
"Reproduciendo: " + player.getVideoFormat().width + "x" +
|
||||
player.getVideoFormat().height + " @ " +
|
||||
player.getVideoFormat().bitrate + " bps");
|
||||
}
|
||||
```
|
||||
|
||||
**Uso:** Ver en logcat qué calidad está reproduciendo actualmente
|
||||
|
||||
## 📈 Resultados Esperados
|
||||
|
||||
### Antes de la Optimización
|
||||
| Conexión | Calidad Típica | Bitrate |
|
||||
|----------|---------------|---------|
|
||||
| WiFi rápido | 480p-720p | 2-3 Mbps |
|
||||
| 4G/5G | 360p-480p | 1-2 Mbps |
|
||||
|
||||
### Después de la Optimización
|
||||
| Conexión | Calidad Típica | Bitrate |
|
||||
|----------|---------------|---------|
|
||||
| WiFi rápido | **720p-1080p** | **3-8 Mbps** |
|
||||
| 4G/5G | **480p-720p** | **2-5 Mbps** |
|
||||
|
||||
## 🔍 Cómo Verificar la Calidad
|
||||
|
||||
### Método 1: Logcat (Desarrollador)
|
||||
```bash
|
||||
adb logcat | grep "PlayerActivity"
|
||||
# Verás: "Reproduciendo: 1920x1080 @ 5500000 bps" (ejemplo 1080p)
|
||||
```
|
||||
|
||||
### Método 2: Visual
|
||||
- 1080p: Imagen muy nítida, detalles en textos pequeños
|
||||
- 720p: Imagen nítida, buena para la mayoría
|
||||
- 480p: Imagen suave, perceptible en pantallas grandes
|
||||
- 360p: Imagen pixelada, solo para conexiones lentas
|
||||
|
||||
## ⚠️ Consideraciones
|
||||
|
||||
### Consumo de Datos
|
||||
| Calidad | Consumo/hora |
|
||||
|---------|--------------|
|
||||
| 1080p | ~3-4 GB |
|
||||
| 720p | ~1.5-2 GB |
|
||||
| 480p | ~500-800 MB |
|
||||
| 360p | ~300-500 MB |
|
||||
|
||||
### Requisitos de Conexión
|
||||
- **1080p**: Mínimo 5 Mbps estable
|
||||
- **720p**: Mínimo 2.5 Mbps estable
|
||||
- **480p**: Mínimo 1 Mbps estable
|
||||
|
||||
## 🎮 Comportamiento Dinámico
|
||||
|
||||
El player ahora:
|
||||
1. **Inicia en alta calidad** (asume buena conexión)
|
||||
2. **Se adapta hacia abajo** si detecta buffering
|
||||
3. **Vuelve a subir** cuando la conexión mejora
|
||||
4. **Prioriza calidad** sobre conservar datos
|
||||
|
||||
## 📝 Notas Técnicas
|
||||
|
||||
### Sobre los Streams HLS
|
||||
Los streams de streamtpmedia.com típicamente ofrecen:
|
||||
- Resolución automática (adaptativa)
|
||||
- Múltiples bitrates para cada resolución
|
||||
- Fragmentos de 2-6 segundos
|
||||
|
||||
El `StreamUrlResolver` obtiene el **manifest master** (.m3u8) que contiene todas las calidades. ExoPlayer ahora elige la mejor automáticamente.
|
||||
|
||||
### Limitaciones del Source
|
||||
Si un stream específico solo ofrece hasta 720p, no se puede forzar 1080p. La calidad máxima depende de la fuente.
|
||||
|
||||
## 🔧 Futuras Mejoras Posibles
|
||||
|
||||
1. **Selector Manual de Calidad** (UI)
|
||||
- Botón para forzar 1080p/720p/auto
|
||||
- Requiere agregar controles personalizados
|
||||
|
||||
2. **Preferencias de Usuario**
|
||||
- Guardar preferencia de calidad
|
||||
- Modo "WiFi-only HD"
|
||||
|
||||
3. **Estadísticas en Pantalla**
|
||||
- Mostrar calidad actual en overlay
|
||||
- Indicador de buffering/bitrate
|
||||
|
||||
## 📦 Versión
|
||||
|
||||
Optimización implementada en: **v9.4.3** (pendiente)
|
||||
Archivo modificado: `PlayerActivity.java`
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!--
|
||||
This file is automatically generated by Crashlytics to uniquely
|
||||
identify the mapping file for your Android application.
|
||||
|
||||
Do NOT modify or commit to source control!
|
||||
-->
|
||||
<string name="com.google.firebase.crashlytics.mapping_file_id" tools:ignore="UnusedResources,TypographyDashes" translatable="false">00000000000000000000000000000000</string>
|
||||
</resources>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="default_web_client_id" translatable="false">123456789012-abcdefghijklmnopqrstuvwxyz123456.apps.googleusercontent.com</string>
|
||||
<string name="gcm_defaultSenderId" translatable="false">123456789012</string>
|
||||
<string name="google_api_key" translatable="false">AIzaSyAbCdEfGhIjKlMnOpQrStUvWxYz1234567</string>
|
||||
<string name="google_app_id" translatable="false">1:123456789012:android:abcdef1234567890</string>
|
||||
<string name="google_crash_reporting_api_key" translatable="false">AIzaSyAbCdEfGhIjKlMnOpQrStUvWxYz1234567</string>
|
||||
<string name="google_storage_bucket" translatable="false">streamplayer-example.appspot.com</string>
|
||||
<string name="project_id" translatable="false">streamplayer-example</string>
|
||||
</resources>
|
||||
@@ -1 +0,0 @@
|
||||
1:123456789012:android:abcdef1234567890
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user