Skip to content

Instantly share code, notes, and snippets.

@oimou
Created April 9, 2016 10:16
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 oimou/de2a0e1c019885fab2f7035650754cb3 to your computer and use it in GitHub Desktop.
Save oimou/de2a0e1c019885fab2f7035650754cb3 to your computer and use it in GitHub Desktop.
乃木坂って、どこ?
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)
#!/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
"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