summaryrefslogtreecommitdiff
path: root/rhimport/converter.go
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport/converter.go')
-rw-r--r--rhimport/converter.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/rhimport/converter.go b/rhimport/converter.go
index c4d8301..e53da9c 100644
--- a/rhimport/converter.go
+++ b/rhimport/converter.go
@@ -52,16 +52,16 @@ func NewFetchConverter(ctx *Context, filename string, metadata map[string]string
switch ctx.FetchConverter {
case "null":
// no support for loudness evaluation - leave normalization to Rivendell
- return NewNullFetchConverter(filename, metadata, ctx.conf.SampleRate, ctx.Channels)
+ return NewNullFetchConverter(ctx, filename, metadata)
case "ffmpeg":
// no support for loudness evaluation - leave normalization to Rivendell
- return NewFFMpegFetchConverter(filename, metadata, ctx.conf.SampleRate, ctx.Channels)
+ return NewFFMpegFetchConverter(ctx, filename, metadata)
case "bs1770":
ctx.NormalizationLevel = 0 // disable Rivendell normalization
- return NewBS1770FetchConverter(filename, metadata, ctx.conf.SampleRate, ctx.Channels)
+ return NewBS1770FetchConverter(ctx, filename, metadata)
case "ffmpeg-bs1770":
ctx.NormalizationLevel = 0 // disable Rivendell normalization
- return NewFFMpegBS1770FetchConverter(filename, metadata, ctx.conf.SampleRate, ctx.Channels)
+ return NewFFMpegBS1770FetchConverter(ctx, filename, metadata)
}
return nil, "", errors.New("unknown fetch converter type: " + ctx.FetchConverter)
}
@@ -74,10 +74,10 @@ type NullFetchConverter struct {
file *os.File
}
-func NewNullFetchConverter(filename string, metadata map[string]string, samplerate, channels uint) (n *NullFetchConverter, newFilename string, err error) {
+func NewNullFetchConverter(ctx *Context, filename string, metadata map[string]string) (n *NullFetchConverter, newFilename string, err error) {
n = &NullFetchConverter{}
newFilename = filepath.Dir(filename) + "/conv-null" + filepath.Ext(filename)
- rhl.Printf("null-converter: opening file '%s' -> '%s'", filename, newFilename)
+ ctx.stdlog.Printf("null-converter: opening file '%s' -> '%s'", filename, newFilename)
n.file, err = os.OpenFile(newFilename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
return
}
@@ -104,17 +104,17 @@ type FFMpegFetchConverter struct {
result chan FetchConverterResult
}
-func NewFFMpegFetchConverter(filename string, metadata map[string]string, samplerate, channels uint) (ff *FFMpegFetchConverter, filenameFlac string, err error) {
+func NewFFMpegFetchConverter(ctx *Context, filename string, metadata map[string]string) (ff *FFMpegFetchConverter, filenameFlac string, err error) {
ff = &FFMpegFetchConverter{}
filenameFlac = filepath.Dir(filename) + "/conv-ffmpeg.flac"
- rhl.Printf("ffmpeg-converter: starting ffmpeg for file '%s' -> '%s'", filename, filenameFlac)
+ ctx.stdlog.Printf("ffmpeg-converter: starting ffmpeg for file '%s' -> '%s'", filename, filenameFlac)
ff.cmd = exec.Command("ffmpeg", "-loglevel", "warning", "-i", "-", "-map_metadata", "0")
if metadata != nil {
for key, value := range metadata {
ff.cmd.Args = append(ff.cmd.Args, "-metadata", fmt.Sprintf("%s=%s", key, value))
}
}
- ff.cmd.Args = append(ff.cmd.Args, "-ar", strconv.FormatUint(uint64(samplerate), 10), "-ac", strconv.FormatUint(uint64(channels), 10), "-f", "flac", filenameFlac)
+ ff.cmd.Args = append(ff.cmd.Args, "-ar", strconv.FormatUint(uint64(ctx.conf.SampleRate), 10), "-ac", strconv.FormatUint(uint64(ctx.Channels), 10), "-f", "flac", filenameFlac)
if ff.pipe, err = ff.cmd.StdinPipe(); err != nil {
return nil, "", err
}
@@ -163,10 +163,10 @@ type BS1770FetchConverter struct {
result chan FetchConverterResult
}
-func NewBS1770FetchConverter(filename string, metadata map[string]string, samplerate, channels uint) (bs *BS1770FetchConverter, newFilename string, err error) {
+func NewBS1770FetchConverter(ctx *Context, filename string, metadata map[string]string) (bs *BS1770FetchConverter, newFilename string, err error) {
bs = &BS1770FetchConverter{}
newFilename = filepath.Dir(filename) + "/conv-bs1770" + filepath.Ext(filename)
- rhl.Printf("bs1770-converter: starting bs1770gain for file '%s' -> '%s'", filename, newFilename)
+ ctx.stdlog.Printf("bs1770-converter: starting bs1770gain for file '%s' -> '%s'", filename, newFilename)
bs.file, err = os.OpenFile(newFilename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
bs.cmd = exec.Command("bs1770gain", "--ebu", "-i", "--xml", "-")
@@ -241,18 +241,18 @@ type FFMpegBS1770FetchConverter struct {
resultBS chan FetchConverterResult
}
-func NewFFMpegBS1770FetchConverter(filename string, metadata map[string]string, samplerate, channels uint) (ff *FFMpegBS1770FetchConverter, filenameFlac string, err error) {
+func NewFFMpegBS1770FetchConverter(ctx *Context, filename string, metadata map[string]string) (ff *FFMpegBS1770FetchConverter, filenameFlac string, err error) {
ff = &FFMpegBS1770FetchConverter{}
filenameFlac = filepath.Dir(filename) + "/conv-ffmpeg-bs1770.flac"
- rhl.Printf("ffmpeg-bs1770-converter: starting ffmpeg and bs1770gain for file '%s' -> '%s'", filename, filenameFlac)
+ ctx.stdlog.Printf("ffmpeg-bs1770-converter: starting ffmpeg and bs1770gain for file '%s' -> '%s'", filename, filenameFlac)
ff.ffmpeg = exec.Command("ffmpeg", "-loglevel", "warning", "-i", "pipe:0", "-map_metadata", "0")
if metadata != nil {
for key, value := range metadata {
ff.ffmpeg.Args = append(ff.ffmpeg.Args, "-metadata", fmt.Sprintf("%s=%s", key, value))
}
}
- ff.ffmpeg.Args = append(ff.ffmpeg.Args, "-ar", strconv.FormatUint(uint64(samplerate), 10), "-ac", strconv.FormatUint(uint64(channels), 10), "-f", "flac", filenameFlac)
- ff.ffmpeg.Args = append(ff.ffmpeg.Args, "-ar", strconv.FormatUint(uint64(samplerate), 10), "-ac", strconv.FormatUint(uint64(channels), 10), "-f", "flac", "pipe:1")
+ ff.ffmpeg.Args = append(ff.ffmpeg.Args, "-ar", strconv.FormatUint(uint64(ctx.conf.SampleRate), 10), "-ac", strconv.FormatUint(uint64(ctx.Channels), 10), "-f", "flac", filenameFlac)
+ ff.ffmpeg.Args = append(ff.ffmpeg.Args, "-ar", strconv.FormatUint(uint64(ctx.conf.SampleRate), 10), "-ac", strconv.FormatUint(uint64(ctx.Channels), 10), "-f", "flac", "pipe:1")
if ff.pipe, err = ff.ffmpeg.StdinPipe(); err != nil {
return nil, "", err
}