|
111 | 111 | code](https://www.colincrawley.com/cc/wp-content/plugins/audio-file-size-calculator/audiofilesizecalculator.js)" |
112 | 112 | [production] |
113 | 113 | (let [dtb (path/recorded-path production) |
| 114 | + mono? (dtb/mono? dtb) |
114 | 115 | duration (quot (dtb/audio-length dtb) 1000) ; convert from millisecs to secs |
115 | 116 | ;; apparently stereo doesn't use twice as much space if you |
116 | 117 | ;; use joint stereo compression mode, so no need to divide by |
117 | 118 | ;; two. The legacy system just added a tolerance of 2% for |
118 | 119 | ;; stereo productions. |
119 | | - sampling-ratio (if (dtb/mono? dtb) 1 1.02) |
| 120 | + sampling-ratio (if mono? 1 1.02) |
120 | 121 | ;; BitRate is measured in kilobits per second |
121 | 122 | ;; BitRate (kbps) = (File Size (bytes) / Duration (seconds)) * 8/1000 |
122 | 123 | max-bitrate (* (/ max-capacity duration sampling-ratio) (/ 8 1000))] |
123 | | - (->> bitrates |
124 | | - ;; only use bitrate 32 for periodicals |
125 | | - (filter #(or (= (:production_type production) "periodical") (> % 32))) |
126 | | - ;; for stereo productions use only bitrates larger or equal than 96 |
127 | | - (filter #(or (dtb/mono? dtb) (>= % 96))) |
128 | | - (filter #(<= % max-bitrate)) |
129 | | - (apply max 0)))) |
| 124 | + (let [bitrate (->> bitrates |
| 125 | + ;; only use bitrate 32 for periodicals |
| 126 | + (filter #(or (= (:production_type production) "periodical") (> % 32))) |
| 127 | + ;; for stereo productions use only bitrates larger or equal than 96 |
| 128 | + (filter #(or mono? (>= % 96))) |
| 129 | + (filter #(<= % max-bitrate)) |
| 130 | + (apply max 0))] |
| 131 | + (log/infof "Calculating ideal bitrate for %s as %s (mono? %s, duration %d secs, sampling-ratio %s, max-bitrate %f)" |
| 132 | + (:id production) bitrate mono? duration sampling-ratio (float max-bitrate)) |
| 133 | + bitrate))) |
130 | 134 |
|
131 | 135 | (defn clean-up |
132 | 136 | "Clean up temporary files of a production, namely the mp3 encoded |
|
0 commit comments