mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
harden ffmpeg pipeline failure handling and stream mapping
This commit is contained in:
@@ -323,17 +323,7 @@ func (d *Downloader) streamManifestWithFFmpeg(ctx context.Context, sourceURL, ou
|
||||
return fmt.Errorf("ffmpeg not found for manifest stream: %w", err)
|
||||
}
|
||||
|
||||
args := []string{
|
||||
"-y",
|
||||
"-protocol_whitelist", "file,http,https,tcp,tls,crypto,data",
|
||||
"-i", sourceURL,
|
||||
}
|
||||
if includeVideo {
|
||||
args = append(args, "-map", "0")
|
||||
} else {
|
||||
args = append(args, "-map", "0:a:0")
|
||||
}
|
||||
args = append(args, "-c", "copy", "-hide_banner", "-nostats", "-progress", "pipe:2", outputPath)
|
||||
args := buildFFmpegStreamArgs(sourceURL, outputPath, includeVideo)
|
||||
|
||||
if !d.ProgressEnabled() {
|
||||
cmd := exec.CommandContext(ctx, "ffmpeg", args...)
|
||||
@@ -458,6 +448,24 @@ func (d *Downloader) streamManifestWithFFmpeg(ctx context.Context, sourceURL, ou
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildFFmpegStreamArgs(sourceURL, outputPath string, includeVideo bool) []string {
|
||||
args := []string{
|
||||
"-y",
|
||||
"-protocol_whitelist", "file,http,https,tcp,tls,crypto,data",
|
||||
"-i", sourceURL,
|
||||
}
|
||||
if includeVideo {
|
||||
args = append(args,
|
||||
"-map", "0:v:0?",
|
||||
"-map", "0:a:0?",
|
||||
)
|
||||
} else {
|
||||
args = append(args, "-map", "0:a:0")
|
||||
}
|
||||
args = append(args, "-c", "copy", "-hide_banner", "-nostats", "-progress", "pipe:2", outputPath)
|
||||
return args
|
||||
}
|
||||
|
||||
type scanState struct {
|
||||
totalMS int64
|
||||
currentMS int64
|
||||
|
||||
Reference in New Issue
Block a user