Skip to content

Instantly share code, notes, and snippets.

View PatrickKalkman's full-sized avatar
🏠
Working from home

Patrick Kalkman PatrickKalkman

🏠
Working from home
View GitHub Profile
result start_position date circuit name constructor
1.0 1.0 2008-03-16 Albert Park Grand Prix Circuit Lewis Hamilton McLaren
2.0 5.0 2008-03-16 Albert Park Grand Prix Circuit Nick Heidfeld BMW Sauber
3.0 7.0 2008-03-16 Albert Park Grand Prix Circuit Nico Rosberg Williams
4.0 12.0 2008-03-16 Albert Park Grand Prix Circuit Fernando Alonso Renault
5.0 3.0 2008-03-16 Albert Park Grand Prix Circuit Heikki Kovalainen McLaren
@PatrickKalkman
PatrickKalkman / scan_table.csv
Last active March 3, 2023 07:53
Table to store scan result
Column Name Data Type Constraints
id INTEGER UNIQUE
scan_id INTEGER UNIQUE
created TEXT
updated TEXT
progress INTEGER
high_alerts INTEGER
medium_alerts INTEGER
low_alerts INTEGER
info_alerts INTEGER
resources:
requests:
cpu: 1500m
memory: 1024Mi
limits:
cpu: 8000m
memory: 2524Mi
if (encodingInstructions.videoEncoder === constants.ENCODER_TYPES.X265) {
const ffmpegCommand = ffmpeg()
.input(inputAsset)
.videoBitrate(encodingInstructions.videoBitrate)
.videoCodec(encodingInstructions.videoEncoder)
.size(encodingInstructions.videoSize)
.audioCodec(encodingInstructions.audioEncoder)
.audioBitrate(encodingInstructions.audioBitrate)
.audioFrequency(encodingInstructions.audioFrequency)
.withOutputOptions('-force_key_frames "expr:gte(t,n_forced*2)"')
app.processEncodingTasks = function processEncodingTasks() {
encoderEngine.searchTasks((searchErr, encoderInstructions) => {
if (!searchErr && encoderInstructions) {
log.info(`Got encoder instructions, started encoder for task '${encoderInstructions.name}' id:${encoderInstructions._id}`);
encoderEngine.startEncoder(encoderInstructions, (startErr) => {
if (!startErr) {
encoderEngine.setTaskToFinished(encoderInstructions._id, (finishErr) => {
if (finishErr) {
log.error(`An error occurred while trying to set the task to finished. ${finishErr.message}`);
}
@PatrickKalkman
PatrickKalkman / scalingEngine.js
Created January 8, 2023 18:28
Very simple scaling algorithm
scalingEngine.getNumberOfNeededEncoders = (numberOfEncodingTasks, numberOfEncoders) => {
if (numberOfEncodingTasks >= 0 && numberOfEncodingTasks <= 10) {
if (numberOfEncoders >= 1 && numberOfEncodingTasks < 1) {
return 0;
}
return numberOfEncoders;
}
if (numberOfEncodingTasks > 10 && numberOfEncodingTasks <= 50) {
if (numberOfEncoders < 4) {
@PatrickKalkman
PatrickKalkman / encoder-scaler-deploy.yaml
Last active January 8, 2023 10:30
Specifying the service account so that the encoder scaler can access the encoder deployment via the Kubernetes API
apiVersion: apps/v1
kind: Deployment
metadata:
name: encoderscaler
spec:
replicas: 1
selector:
matchLabels:
app: encoderscaler
strategy:
import k8s from '@kubernetes/client-node';
import log from './log.js';
const kubernetesClient = {};
kubernetesClient.setNumberOfEncoders = async (numberOfEncoders) => {
try {
const kubeconfig = new k8s.KubeConfig();
if (process.env.NODE_ENV === 'production') {
@PatrickKalkman
PatrickKalkman / HLS Ladder.csv
Created November 9, 2022 19:22
HLS bitrate ladder
16:9 aspect ratio Bitrate Frame rate
416 x 234 145 ≤ 30 fps
640 x 360 365 ≤ 30 fps
768 x 432 730 ≤ 30 fps
768 x 432 1100 ≤ 30 fps
960 x 540 2000 Same as source
1280 x 720 3000 Same as source
1280 x 720 4500 Same as source
1920 x 1080 6000 Same as source
1920 x 1080 7800 Same as source
public List<ContentValues> parseMovies(JSONArray videoArray) throws JSONException {
List<ContentValues> videosToInsert = new ArrayList<>();
String title = video.optString(TAG_TITLE);
String description = video.optString(TAG_DESCRIPTION);
String short_description = video.optString(TAG_SHORT_DESCRIPTION);
if (description.isEmpty()) {
description = short_description;
}