Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [ "es2015" ]
}
105 changes: 7 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,115 +3,29 @@ Mediainfo

Wrapper around the `mediainfo` command for obtaining information about media
files.
Exposed as API to supply info of urls

Overview
--------

This module provides an interface to the `mediainfo` command. It returns the
(parsed) output of the command with all the keys lower-cased. There's not a lot
to say here.
I have extended it to be a web service providing info of url's

Usage
-----

The module exposes just one function, which has a signature of:
Once deployed you can pass url to the /info endpoint like this:

`mediainfo("/path/to/file", "/path/to/other/file", [...], callback)`
http://localhost:8080/info?url=http://myfile.mp4

The callback function is called, in familiar node fashion, with two arguments.
The first is an Error object on error, or null on success. The second argument
is an array of objects, forming what you'd expect from the output of mediainfo,
if it were mangled into a JSON object.

It's really easier to just see the output, so here:

```
[
{
tracks: [
{
type: 'Audio',
format: 'MPEG Audio',
format_version: 'Version 1',
format_profile: 'Layer 3',
mode: 'Joint stereo',
duration: '3mn 2s',
bit_rate_mode: 'Constant',
bit_rate: '320 Kbps',
channel_s_: '2 channels',
sampling_rate: '44.1 KHz',
compression_mode: 'Lossy',
stream_size: '6.97 MiB (100%)',
writing_library: 'LAME3.97'
}
],
complete_name: 'test1.mp3',
format: 'MPEG Audio',
file_size: '6.98 MiB',
duration: '3mn 2s',
overall_bit_rate: '320 Kbps',
album: 'We No Speak Americano (High Rankin\'s Bait n Wobble Mix)',
track_name: 'We No Speak Americano (High Rankin\'s Bait n Wobble Mix)',
track_name_position: '1',
track_name_total: '1',
performer: 'Yolanda Be Cool & DCUP',
accompaniment: 'High Rankin',
genre: 'Dubstep',
recorded_date: '2010',
writing_library: 'LAME in FL Studio 8 / LAME3.97'
},
{
tracks: [
{
type: 'Audio',
format: 'MPEG Audio',
format_version: 'Version 1',
format_profile: 'Layer 3',
mode: 'Joint stereo',
duration: '3mn 2s',
bit_rate_mode: 'Constant',
bit_rate: '320 Kbps',
channel_s_: '2 channels',
sampling_rate: '44.1 KHz',
compression_mode: 'Lossy',
stream_size: '6.97 MiB (100%)',
writing_library: 'LAME3.97'
}
],
complete_name: 'test2.mp3',
format: 'MPEG Audio',
file_size: '6.98 MiB',
duration: '3mn 2s',
overall_bit_rate: '320 Kbps',
album: 'We No Speak Americano (High Rankin\'s Bait n Wobble Mix)',
track_name: 'We No Speak Americano (High Rankin\'s Bait n Wobble Mix)',
track_name_position: '1',
track_name_total: '1',
performer: 'Yolanda Be Cool & DCUP',
accompaniment: 'High Rankin',
genre: 'Dubstep',
recorded_date: '2010',
writing_library: 'LAME in FL Studio 8 / LAME3.97'
}
]
```

(bite me, it's a decent track)
response would be a json with info of that mp4

Example
-------

```javascript
var mediainfo = require("mediainfo");

mediainfo("/path/to/something.mp3", function(err, res) {
if (err) {
return console.log(err);
}

console.log(res);
});
```
http://localhost:8080/info?url=http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4

Requirements
------------
Expand All @@ -122,11 +36,6 @@ node is running as.
License
-------

For media-info wrapper:
3-clause BSD. A copy is included with the source.

Contact
-------

* GitHub ([deoxxa](http://github.com/deoxxa))
* Twitter ([@deoxxa](http://twitter.com/deoxxa))
* Email ([deoxxa@fknsrs.biz](mailto:deoxxa@fknsrs.biz))
4 changes: 2 additions & 2 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node

var util = require("util"),
mediainfo = require("./");
mediainfo = require("./server/mediainfo/mediainfo.js");

mediainfo("test1.mp3", "test2.mp3", function(err, res) {
mediainfo("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4", function(err, res) {
if (err) {
return console.log(err);
}
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('./server');
31 changes: 21 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{
"name": "mediainfo",
"description": "Wrapper around the `mediainfo' program for obtaining information about media files",
"version": "0.0.2",
"description": "Node micro service to return media-info for given url",
"version": "0.0.1",
"author": {
"name": "Conrad Pankoff",
"email": "deoxxa@fknsrs.biz",
"url": "http://www.fknsrs.biz/"
"name": "Ady Levy",
"email": "ady.levy@teamaol.com",
"url": "http://www.adylevy.com/"
},
"url": "http://github.com/deoxxa/node-mediainfo",
"url": "https://github.com/adylevy/node-mediainfo",
"license": "BSD",
"repository": {
"type": "git",
"url": "git://github.com/deoxxa/node-mediainfo.git"
"url": "git://github.com/adylevy/node-mediainfo.git"
},
"scripts": {
"start": "babel-node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"mediainfo",
Expand All @@ -24,12 +28,19 @@
"mkv",
"avi"
],
"main": "./lib/mediainfo",
"main": "index.js",
"engines": {
"node": ">=0.6.11"
},
"dependencies": {
"node-expat": "2.0.x",
"filesize-parser": "~0.0.2"
"node-expat": "~2.3.13",
"filesize-parser": "~1.4.1",
"express": "^4.13.3",
"cors": "^2.7.1"
},
"devDependencies": {
"babel-cli": "^6.9.0",
"babel-core": "^6.9.0",
"babel-preset-es2015": "^6.9.0"
}
}
14 changes: 14 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import http from 'http';
import express from 'express';
import cors from 'cors';
import mediainfo from './mediainfo'

var app = express();
app.server = http.createServer(app);
app.use(cors());
app.use('/info', mediainfo());
app.server.listen(process.env.PORT || 8080);

console.log(`Started on port ${app.server.address().port}`);

export default app;
30 changes: 30 additions & 0 deletions server/mediainfo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Router } from 'express';
import mediainfo from './mediainfo.js';

export default function () {
var api = Router();

api.get('/', (req, res) => {
var url = req.query.url;

if (url && url != ''){
mediainfo(url, function(err, mediaResult) {
if (err) {
res.json({
error:err
})
}
res.json(mediaResult);
});

}
else{
res.json({
error:'url not provided.'
})
}

});
return api;
}

2 changes: 1 addition & 1 deletion lib/mediainfo.js → server/mediainfo/mediainfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = function() {
}

if (track !== null) {
key = name;
key = name.replace(/\_+$/g,'');
}
});

Expand Down