Skip to content

Instantly share code, notes, and snippets.

@imbcmdth
Last active June 14, 2016 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imbcmdth/358c6fb0eb7e0d27654441e222c34742 to your computer and use it in GitHub Desktop.
Save imbcmdth/358c6fb0eb7e0d27654441e222c34742 to your computer and use it in GitHub Desktop.
ffprobe C2.ts -show_frames | ./frames_to_json.js > C2.json
#!/usr/bin/env node
'use strict';
let strings = [];
process.stdin.on('readable', () => {
var chunk = process.stdin.read();
if (chunk !== null) {
strings.push(chunk.toString());
}
});
process.stdin.on('end', () => {
let contents = strings.join('');
contents = contents.replace(/\[\/FRAME\]\n\[FRAME\]/igm, '},\n{');
contents = contents.replace(/\[FRAME\]/igm, '{');
contents = contents.replace(/\[\/FRAME\]/igm, '}');
contents = contents.replace(/(\w*)=([\d.]*)\n/igm, '"$1": $2,\n');
contents = contents.replace(/(\w*)=([^\n]*)\n/igm, '"$1": "$2",\n');
contents = contents.replace(/,\n}/igm, '\n}');
contents = '[' + contents + ']';
process.stdout.write(contents);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment