public
Last active

mediablast server example

  • Download Gist
.gitignore
1
/node_modules
README.md
Markdown

mediablast Server Example

Get the Server Running

npm install
npm start

Try the Audio Template

  1. Start the mediablast server: npm start
  2. Go to http://localhost:14007/admin/settings
  3. Put your s3 credentials into the audio template and press save.
  4. Open a window to http://localhost:14007/admin/status and move it to the side so you can watch it while you perform the test.
  5. Open another window to http://localhost:14007/admin/test
  6. Paste the audio template id into the box. The audio template id is c5014d30-47d1-11e2-bcfd-0800200c9a66.
  7. Use the file chooser input and choose an audio file.
  8. Watch the /admin/status window that you have open.
  9. Have a look at the files that were created in your s3 bucket.

Try the Image Template

  1. Start the mediablast server: npm start
  2. Go to http://localhost:14007/admin/settings
  3. Put your s3 credentials into the image template and press save.
  4. Open a window to http://localhost:14007/admin/status and move it to the side so you can watch it while you perform the test.
  5. Open another window to http://localhost:14007/admin/test
  6. Paste the image template id into the box. The image template id is c9961790-47d1-11e2-bcfd-0800200c9a66.
  7. Use the file chooser input and choose an image file.
  8. Watch the /admin/status window that you have open.
  9. Have a look at the files that were created in your s3 bucket.
package.json
JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
{
"name": "mediablast-example",
"private": true,
"version": "0.0.0",
"description": "mediablast server example",
"author": "Andrew Kelley",
"license": "MIT",
"dependencies": {
"plan-callback": "~0.0.1",
"plan-transcode": "~0.0.2",
"plan-waveform": "~0.0.4",
"plan-s3-download": "~0.1.0",
"plan-s3-upload": "~0.1.4",
"plan-thumbnail": "~0.1.0",
"mediablast": "~0.0.1"
}
}
server.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
var mediablast = require('mediablast')
, http = require('http')
, path = require('path')
 
var env = {
NODE_ENV: process.env.NODE_ENV = process.env.NODE_ENV || 'dev',
HOST: process.env.HOST || '0.0.0.0',
PORT: parseInt(process.env.PORT || '14007', 10),
};
console.log("Using environment:", env);
 
var app = mediablast({
settingsFile: path.join(__dirname, "settings.json")
});
 
app.registerTask('audio.transcode', require('plan-transcode'));
app.registerTask('audio.waveform', require('plan-waveform'));
app.registerTask('image.thumbnail', require('plan-thumbnail'));
app.registerTask('s3.upload', require('plan-s3-upload'));
app.registerTask('s3.download', require('plan-s3-download'));
app.registerTask('meta.callback', require('plan-callback'));
 
 
var server = http.createServer(app);
server.listen(env.PORT, env.HOST, function() {
console.log("Listening at http://" + env.HOST + ":" + env.PORT);
if (process.send) process.send('online');
});
settings.json
JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
{
"completed_job_lifespan": 60,
"templates": {
"c5014d30-47d1-11e2-bcfd-0800200c9a66": {
"options": {
"s3.upload": {
"s3Key": "your s3 key",
"s3Secret": "your s3 secret",
"s3Bucket": "your s3 bucket"
}
},
"tasks": {
"original": {
"task": "s3.upload",
"options": {
"url": "{uuid}/original{ext}"
}
},
"waveform": {
"task": "audio.waveform",
"options": {
"width": 1800,
"height": 200,
"colorCenter": "0081daff",
"colorOuter": "004678ff",
"colorBg": "00000000"
}
},
"waveform_upload": {
"task": "s3.upload",
"options": {
"url": "{uuid}/waveform{ext}"
},
"dependencies": [
"waveform"
]
},
"preview": {
"task": "audio.transcode",
"options": {
"bit_rate": 192,
"sample_rate": 44100,
"format": "mp3"
}
},
"preview_upload": {
"task": "s3.upload",
"options": {
"url": "{uuid}/preview{ext}"
},
"dependencies": [
"preview"
]
}
}
},
"c9961790-47d1-11e2-bcfd-0800200c9a66": {
"options": {
"s3.upload": {
"s3Key": "your s3 key",
"s3Secret": "your s3 secret",
"s3Bucket": "your s3 bucket"
}
},
"tasks": {
"original": {
"task": "s3.upload",
"options": {
"url": "{uuid}/original{ext}"
}
},
"tiny": {
"task": "image.thumbnail",
"options": {
"format": "png",
"width": 30,
"height": 30,
"crop": false
}
},
"tiny_upload": {
"task": "s3.upload",
"options": {
"url": "{uuid}/tiny{ext}"
},
"dependencies": [
"tiny"
]
},
"medium": {
"task": "image.thumbnail",
"options": {
"format": "png",
"width": 56,
"height": 56,
"crop": false
}
},
"medium_upload": {
"task": "s3.upload",
"options": {
"url": "{uuid}/medium{ext}"
},
"dependencies": [
"medium"
]
}
}
}
},
"auth": {
"username": "admin",
"password": "3pTkHwHV"
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.