awc_opus.py: OpusHead pre-skip is 0, so exported .ogg starts with encoder priming and loses the real tail (312 samples with libopus)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- Medio día
- Aptitud para principiantes
- 42/100
Línea de trabajo
Start in tools/awc_opus.py around line 83, where OpusHead is packed with pre-skip 0, and in write_ogg_opus where granule positions are computed. Reproduce by encoding a sine with libopus, extracting packets, and checking the decoded offset against the reference. Done when the header carries the encoder pre-skip and granule positions include it, with the trimmed last granule as min(granule, pre_skip + length).
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What happens
awc_opus.py writes OpusHead with pre-skip 0, so every exported .ogg plays the encoder's priming samples at the start, and the end trim (length) then cuts the same amount of real audio off the end. with a libopus stream that's 312 samples (6.5 ms) shifted on both ends.
Commit
c2967a5e (main)
System
Linux, Python 3.10, ffmpeg 4.4 (libopus). no game files.
Where
A tool run by hand (tools/, scripts/)
Command and steps
tools/awc_opus.py:83:
head = b"OpusHead" + struct.pack("<BBHIhB", 1, channels, 0, 48000, 0, 0)
# ^ pre-skip = 0
every Opus encoder has lookahead, so its first ~312 output samples (libopus default) are priming and not audio. RFC 7845 §4.2 says the decoder drops pre-skip samples, and the granule positions count them too (§4.4: last granule = pre-skip + real samples).
repro without game data: encode a 1 s sine with libopus, pull the raw packets out of the ogg, and push them through write_ogg_opus(..., length=48000):
ref pre-skip 312, 51 packets
decoded samples: ref 48000, ours 48000
first non-silent sample: ref 5, ours 317
best alignment of ours vs ref: shifted by 312 samples
so the length matches, but the content is 312 samples late and the last 312 real samples are gone.
Fix (probably)
- write the real pre-skip into OpusHead, and add it to every granule position (including the trimmed last one:
min(granule, pre_skip + length)) - where does the value come from: for the music streams the per-channel
skipalready drops whole repeated packets, which is a different thing. for plain streams the AWC might store the encoder delay somewhere (rpf9-explorer's OpusPreview would be the place to check). if it doesn't, 312 (libopus at 48 kHz) is the safe default, since that's what any libopus encoder would have used.
i couldn't check what the game's own encoder used without game files, so whoever has a bank could compare one sfx's onset against the in-game sound, or check whether its packet count × frame size exceeds samples by about 312.
Output
n/a (wrong result, no error)
TL;DR: exported game audio (.ogg) starts about 6.5 ms late and loses the same amount at the end, because the Opus header says pre-skip 0. fix: write the encoder's pre-skip (probably 312) and count it in the granule positions. shown with a libopus round-trip, not yet with real game banks. AI-assisted (Claude Code).
- Lenguaje dominante
- Python
- Estrellas
- 14.9k
- Forks
- 1.2k
- Merge medio
- 1 h 58 min
- PR fusionados (30 d)
- 40
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ItsNotRexed/Leonida
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ItsNotRexed/Leonida#3990 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 Medio día Aptitud para principiantes 25/100
ItsNotRexed/Leonida#4257 · 18 comentarios ·
Los mantenedores suelen responder en 1 día
-
Python SPIR-V assembler encodes BF16 constants as IEEE halfPosiblemente ocupada @lumenpearson la tomó hoy. Abiertobug
Dificultad 3/5 Medio día Aptitud para principiantes 25/100
ItsNotRexed/Leonida#4237 ·
Los mantenedores suelen responder en 1 día
-
SPIR-V reflection rejects Int8 array length constantsPosiblemente ocupada @lumenpearson la tomó hoy. Abiertobug
Dificultad 3/5 Medio día Aptitud para principiantes 22/100
ItsNotRexed/Leonida#4221 ·
Los mantenedores suelen responder en 1 día
-
Interrupted stub rebuild can truncate a valid SPIR-V outputPosiblemente ocupada @lumenpearson la tomó hoy. Abiertobug
Dificultad 3/5 Medio día Aptitud para principiantes 18/100
ItsNotRexed/Leonida#4183 ·
Los mantenedores suelen responder en 1 día
Todos los issues de ItsNotRexed/Leonida
Issues similares
-
pydanty:is-working
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
pydantic/pydantic-ai#14187 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
[Bug]: legacy_json_to_doc crashes on persisted docs with "relationships": nullPosiblemente ocupada @Harsh23Kashyap la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
run-llama/llama_index#24392 ·
Los mantenedores suelen responder en 2 días
-
Add server: crowllm-mcpAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
pathintegral-institute/mcpm.sh#568 ·
Los mantenedores suelen responder en 21 días