Commit 03949b9f authored by Kelly Davis's avatar Kelly Davis
Browse files

Fixed #110

parent fc435aea
......@@ -20,5 +20,3 @@ For more options type:
```
gulp help
```
Note also that sox with `ogg` support is required on the server.
......@@ -377,11 +377,6 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"create-temp-file": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/create-temp-file/-/create-temp-file-1.0.0.tgz",
"integrity": "sha1-fFAr4RR6XPEmxaOZwH5QlbZzxds="
},
"cron": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/cron/-/cron-1.2.1.tgz",
......@@ -457,7 +452,8 @@
"duplexer": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
"integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E="
"integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=",
"dev": true
},
"duplexer2": {
"version": "0.0.2",
......@@ -1768,11 +1764,6 @@
"resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz",
"integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk="
},
"hash-to-array": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/hash-to-array/-/hash-to-array-1.0.1.tgz",
"integrity": "sha1-Kw4oTASjLDRYAkijMrli6xVeD28="
},
"hawk": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz",
......@@ -2457,7 +2448,8 @@
"os-tmpdir": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=",
"dev": true
},
"osenv": {
"version": "0.1.4",
......@@ -2999,11 +2991,6 @@
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.15.tgz",
"integrity": "sha1-AyAt9lwG0r2MfsI2KhkwVv7407E="
},
"sox-stream": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/sox-stream/-/sox-stream-2.0.1.tgz",
"integrity": "sha1-maQO7NKXUsai+h9KfMzd6ihDvPM="
},
"sparkles": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz",
......@@ -3049,6 +3036,11 @@
"integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=",
"dev": true
},
"stream-transcoder": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/stream-transcoder/-/stream-transcoder-0.0.5.tgz",
"integrity": "sha1-aCYb5O+0iEAjm1eRryPuO4vXmAg="
},
"streamqueue": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/streamqueue/-/streamqueue-0.0.6.tgz",
......@@ -3153,18 +3145,6 @@
}
}
},
"tempfile": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/tempfile/-/tempfile-1.1.1.tgz",
"integrity": "sha1-W8xOrsxKsscH2LwR2ZzMmiyyh/I=",
"dependencies": {
"uuid": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz",
"integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho="
}
}
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
......
......@@ -24,7 +24,7 @@
"preact": "^8.1.0",
"proxy-agent": "^2.0.0",
"simple-git": "^1.72.0",
"sox-stream": "^2.0.1",
"stream-transcoder": "0.0.5",
"walk": "^2.3.9"
},
"devDependencies": {
......
......@@ -9,11 +9,10 @@ const fs = require('fs');
const crypto = require('crypto');
const Promise = require('bluebird');
const mkdirp = require('mkdirp');
const MemoryStream = require('memorystream');
const findRemoveSync = require('find-remove');
const AWS = require('./aws');
const PassThrough = require('stream').PassThrough;
const sox = require('sox-stream');
const Transcoder = require('stream-transcoder');
const UPLOAD_PATH = path.resolve(__dirname, '../..', 'upload');
const CONFIG_PATH = path.resolve(__dirname, '../../..', 'config.json');
......@@ -147,14 +146,17 @@ export default class Clip {
if (contentType.includes('base64')) {
let passThrough = new PassThrough();
passThrough.end(Buffer.from(Buffer.concat(chunks).toString(), 'base64'));
let memStream = new MemoryStream();
memStream = passThrough.pipe(sox({output: { type: 'mp3' } })).pipe(memStream);
let params = {Bucket: BUCKET_NAME, Key: file, Body: memStream};
let transcoder = new Transcoder(passThrough);
transcoder = transcoder.audioCodec('mp3').format('mp3');
let transcoderStream = transcoder.stream();
let params = {Bucket: BUCKET_NAME, Key: file, Body: transcoderStream};
this.s3.upload(params, f());
} else {
// For now base64 uploads, we can just stream data.
let memStream = request.pipe(sox({output: { type: 'mp3' } })).pipe(new MemoryStream());
let params = {Bucket: BUCKET_NAME, Key: file, Body: memStream};
let transcoder = new Transcoder(request);
transcoder = transcoder.audioCodec('mp3').format('mp3');
let transcoderStream = transcoder.stream();
let params = {Bucket: BUCKET_NAME, Key: file, Body: transcoderStream};
this.s3.upload(params, f());
}
......
......@@ -5,7 +5,6 @@ const MemoryStream = require('memorystream');
const path = require('path');
const Promise = require('bluebird');
const Queue = require('better-queue');
const sox = require('sox-stream');
const AWS = require('./aws');
const BATCH_SIZE = 5;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment