fix(stream): downmix estéreo en el audio re-encodeado del modo copy
Sin -ac 2 una fuente 5.1 (AC3/EAC3) producía AAC de 6 canales del encoder nativo de ffmpeg, que WebKit/Apple HLS rechaza al sniffar el primer segmento: en el access log de Safari se ve master → index → init → seg-0 dos veces y silencio. Era el discriminador exacto del patrón de campo: episodios con AAC estéreo (copy de audio) reproducían en iPhone; todas las películas 5.1 fallaban. Verificado con Safari/macOS via WebDriver-less access log: con -ac 2 la progresión de segmentos avanza con normalidad. Espeja los flags del path de encode (aac 192k 48kHz estéreo). Test smoke ampliado: el re-encode debe llevar -ac 2.
This commit is contained in:
parent
6c756a2569
commit
f89396ceed
3 changed files with 20 additions and 1 deletions
|
|
@ -1968,7 +1968,12 @@ func buildHLSCopyArgs(cfg HLSSessionConfig, probe *StreamProbe, tmpDir string) [
|
||||||
if strings.EqualFold(audioCodec, "aac") {
|
if strings.EqualFold(audioCodec, "aac") {
|
||||||
args = append(args, "-c:a", "copy")
|
args = append(args, "-c:a", "copy")
|
||||||
} else {
|
} else {
|
||||||
args = append(args, "-c:a", "aac", "-b:a", "192k")
|
// Mirror the encode path exactly: AAC stereo 48k. WITHOUT -ac 2 a 5.1
|
||||||
|
// source produces 6-channel ffmpeg-native AAC, which WebKit/Apple HLS
|
||||||
|
// rejects at the first media segment (observed via Safari access log:
|
||||||
|
// master → index → init → seg-0 fetched twice, then silence — every
|
||||||
|
// 5.1 movie failed on iPhone while stereo-AAC episodes played).
|
||||||
|
args = append(args, "-c:a", "aac", "-b:a", "192k", "-ar", "48000", "-ac", "2")
|
||||||
}
|
}
|
||||||
|
|
||||||
args = append(args,
|
args = append(args,
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,12 @@ func TestHLSCopy_H264Ac3TranscodesAudio(t *testing.T) {
|
||||||
if !containsSeq(args, "-c:a", "aac") {
|
if !containsSeq(args, "-c:a", "aac") {
|
||||||
t.Errorf("expected -c:a aac for AC3 source, args: %v", args)
|
t.Errorf("expected -c:a aac for AC3 source, args: %v", args)
|
||||||
}
|
}
|
||||||
|
// MUST downmix to stereo: 6-channel ffmpeg-native AAC is rejected by
|
||||||
|
// WebKit/Apple HLS at the first media segment (every 5.1 movie failed on
|
||||||
|
// iPhone while stereo-AAC sources played — confirmed via Safari access log).
|
||||||
|
if !containsSeq(args, "-ac", "2") {
|
||||||
|
t.Errorf("expected -ac 2 (stereo downmix) for re-encoded audio, args: %v", args)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHLSCopy_Hevc10Eac3_IncidentShape(t *testing.T) {
|
func TestHLSCopy_Hevc10Eac3_IncidentShape(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -690,6 +690,14 @@ func (ss *StreamServer) HLSURLsJSON(sessionID string) string {
|
||||||
func (ss *StreamServer) hlsHandler(w http.ResponseWriter, r *http.Request) {
|
func (ss *StreamServer) hlsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
ss.lastActivity.Store(time.Now().UnixNano())
|
ss.lastActivity.Store(time.Now().UnixNano())
|
||||||
|
|
||||||
|
// Debug access log (UNARR_HLS_DEBUG=1): which client fetches which HLS
|
||||||
|
// resource. Off by default — a player polls the playlist every few
|
||||||
|
// seconds and segments stream constantly, far too chatty for normal logs.
|
||||||
|
if os.Getenv("UNARR_HLS_DEBUG") == "1" {
|
||||||
|
host, _, _ := net.SplitHostPort(r.RemoteAddr)
|
||||||
|
log.Printf("[hls-debug] %s %s from %s UA=%q", r.Method, r.URL.Path, host, r.Header.Get("User-Agent"))
|
||||||
|
}
|
||||||
|
|
||||||
if ss.writeCORSHeaders(w, r, "Content-Length, Content-Range, Accept-Ranges") {
|
if ss.writeCORSHeaders(w, r, "Content-Length, Content-Range, Accept-Ranges") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue