Run unified player in preview-only mode
This commit is contained in:
parent
037b771b0d
commit
d8c649427b
|
|
@ -97,6 +97,12 @@ func NewUnifiedPlayer(config Config) *UnifiedPlayer {
|
||||||
},
|
},
|
||||||
audioBufferSize: 32768, // 170ms at 48kHz for smooth playback
|
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())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
player.ctx = ctx
|
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
|
// Initialize audio context for playback
|
||||||
sampleRate := 48000
|
sampleRate := 48000
|
||||||
channels := 2
|
channels := 2
|
||||||
|
|
@ -175,6 +182,7 @@ func (p *UnifiedPlayer) Load(path string, offset time.Duration) error {
|
||||||
|
|
||||||
p.audioContext = ctx
|
p.audioContext = ctx
|
||||||
logging.Info(logging.CatPlayer, "Audio context initialized successfully")
|
logging.Info(logging.CatPlayer, "Audio context initialized successfully")
|
||||||
|
}
|
||||||
|
|
||||||
// Start FFmpeg process for unified A/V output
|
// Start FFmpeg process for unified A/V output
|
||||||
err = p.startVideoProcess()
|
err = p.startVideoProcess()
|
||||||
|
|
@ -183,7 +191,9 @@ func (p *UnifiedPlayer) Load(path string, offset time.Duration) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start audio stream processing
|
// Start audio stream processing
|
||||||
|
if !p.previewMode {
|
||||||
go p.readAudioStream()
|
go p.readAudioStream()
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -545,6 +555,18 @@ func (p *UnifiedPlayer) startVideoProcess() error {
|
||||||
"-hide_banner", "-loglevel", "error",
|
"-hide_banner", "-loglevel", "error",
|
||||||
"-ss", fmt.Sprintf("%.3f", p.currentTime.Seconds()),
|
"-ss", fmt.Sprintf("%.3f", p.currentTime.Seconds()),
|
||||||
"-i", p.currentPath,
|
"-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
|
// Video stream to pipe 4
|
||||||
"-map", "0:v:0",
|
"-map", "0:v:0",
|
||||||
"-f", "rawvideo",
|
"-f", "rawvideo",
|
||||||
|
|
@ -557,6 +579,7 @@ func (p *UnifiedPlayer) startVideoProcess() error {
|
||||||
"-ar", "48000",
|
"-ar", "48000",
|
||||||
"-f", "s16le",
|
"-f", "s16le",
|
||||||
"pipe:5",
|
"pipe:5",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add hardware acceleration if available
|
// Add hardware acceleration if available
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user