Last active
June 14, 2016 19:01
-
-
Save imbcmdth/358c6fb0eb7e0d27654441e222c34742 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffprobe C2.ts -show_frames | ./frames_to_json.js > C2.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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