30 lines
820 B
Racket
30 lines
820 B
Racket
#lang racket/base
|
|
(require racket-audio/audio-encoder
|
|
"log.rkt"
|
|
"util.rkt"
|
|
simple-ini
|
|
)
|
|
|
|
(provide convert-to-opus
|
|
)
|
|
|
|
|
|
(define (convert-to-opus flac-in opus-out ini)
|
|
(let* ((opus-kbps (ini-get ini 'opus 'kbps 224))
|
|
(settings (hash 'bitrate (* opus-kbps 1000)
|
|
'vbr #t))
|
|
)
|
|
(with-handlers ([exn? (λ (e)
|
|
(err-am (format "~a" e))
|
|
(when (file-exists? opus-out)
|
|
(delete-file opus-out))
|
|
#f)])
|
|
(let ((result (audio-encode flac-in opus-out
|
|
settings
|
|
#:encoder 'opus
|
|
#:copy-tags? #t)))
|
|
#t)
|
|
)
|
|
)
|
|
)
|