Run unified player in preview-only mode

This commit is contained in:
Stu Leak 2026-01-07 02:27:46 -05:00
parent 037b771b0d
commit d8c649427b

View file

@ -97,6 +97,12 @@ func NewUnifiedPlayer(config Config) *UnifiedPlayer {
},
audioBufferSize: 32768, // 170ms at 48kHz for smooth playback
}
if config.WindowWidth > 0 {
player.windowW = config.WindowWidth
}
if config.WindowHeight > 0 {
player.windowH = config.WindowHeight
}
ctx, cancel := context.WithCancel(context.Background())
player.ctx = ctx
@ -155,6 +161,7 @@ func (p *UnifiedPlayer) Load(path string, offset time.Duration) error {
}
}
if !p.previewMode {
// Initialize audio context for playback
sampleRate := 48000
channels := 2
@ -175,6 +182,7 @@ func (p *UnifiedPlayer) Load(path string, offset time.Duration) error {
p.audioContext = ctx
logging.Info(logging.CatPlayer, "Audio context initialized successfully")
}
// Start FFmpeg process for unified A/V output
err = p.startVideoProcess()
@ -183,7 +191,9 @@ func (p *UnifiedPlayer) Load(path string, offset time.Duration) error {
}
// Start audio stream processing
if !p.previewMode {
go p.readAudioStream()
}
return nil
}
@ -545,6 +555,18 @@ func (p *UnifiedPlayer) startVideoProcess() error {
"-hide_banner", "-loglevel", "error",
"-ss", fmt.Sprintf("%.3f", p.currentTime.Seconds()),
"-i", p.currentPath,
}
if p.previewMode {
args = append(args,
"-map", "0:v:0",
"-an",
"-f", "rawvideo",
"-pix_fmt", "rgb24",
"-r", "24",
"pipe:1",
)
} else {
args = append(args,
// Video stream to pipe 4
"-map", "0:v:0",
"-f", "rawvideo",
@ -557,6 +579,7 @@ func (p *UnifiedPlayer) startVideoProcess() error {
"-ar", "48000",
"-f", "s16le",
"pipe:5",
)
}
// Add hardware acceleration if available