Created
April 9, 2016 10:16
-
-
Save oimou/de2a0e1c019885fab2f7035650754cb3 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
from pytube import YouTube as YT | |
urls = [ | |
... | |
] | |
for url in urls: | |
yt = YT(url) | |
try: | |
video = yt.get("mp4", "720p") | |
except: | |
video = yt.get("mp4") | |
video.download("./video") | |
print("Download finished: " + url) |
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
#!/bin/bash | |
for f in video/*.mp4; do | |
DNAME=$(basename ${f%.*} | tr '.' '_') | |
mkdir -p frame/${DNAME} | |
ffmpeg -i ${f} -r 0.2 frame/${DNAME}/thumbnail-%04d.jpg | |
done |
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
"use strict"; | |
const fs = require("fs"); | |
const vision = require("node-cloud-vision-api"); | |
vision.init({ | |
auth: "API_KEY" | |
}) | |
let dirs = fs.readdirSync("./frame") | |
let count = 0; | |
let nEmit = 0; | |
let paths = []; | |
for (let dir of dirs) { | |
if (!fs.statSync("./frame/" + dir).isDirectory()) continue; | |
let files = fs.readdirSync("./frame/" + dir); | |
for (let file of files) { | |
let path = "./frame/" + dir + "/" + file; | |
paths.push(path); | |
count++; | |
if (count >= 16) { | |
emitPaths(); | |
nEmit++; | |
count = 0; | |
} | |
} | |
} | |
function emitPaths() { | |
let _paths = paths.concat(); | |
let reqs = _paths.map((path) => { | |
let req = new vision.Request({ | |
image: new vision.Image({ | |
path: path | |
}), | |
features: [ | |
new vision.Feature("LANDMARK_DETECTION", 1) | |
] | |
}); | |
return req; | |
}); | |
setTimeout(() => { | |
vision.annotate(reqs).then((res) => { | |
let results = res.responses; | |
_paths.forEach((path, i) => { | |
console.log(JSON.stringify({ | |
path: path, | |
result: results[i] | |
}) + ","); | |
}); | |
}, (err) => { | |
console.error("Error: " + err); | |
}); | |
}, nEmit * 2000); | |
paths = []; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment