Skip to content

Instantly share code, notes, and snippets.

View jordicenzano's full-sized avatar
🤓
Working ... probably

Jordi Cenzano jordicenzano

🤓
Working ... probably
View GitHub Profile
@jordicenzano
jordicenzano / elemental-input-switch.js
Last active January 12, 2017 14:45
Elemental API: Switch from input A to Input B inside the same event
#!/usr/bin/env node
//Replace following vars:
var base_url = "http://ELEMENTAL-NAME.YOURDOMAIN.ccc";
var user_name = "PUT ELEMENTAL YOUR USERNAME";
var api_key = "PUT YOUR ELEMENTAL API KEY";
var ev_number = EV_NUMBER_TO_SW; //Example: 33
var input_name_to_switch = "INPUT NAME"; //The input's name on elemental. Example: slate
const child_process = require('child_process');
@jordicenzano
jordicenzano / dns-propagation-time-check.js
Created March 27, 2017 21:58
Get the DNS propagation time
#!/usr/bin/env node
const dns = require('dns');
const options = {
ttl: true
};
if (process.argv.length < 4) {
console.error("Usage dns-propagation-time-check.js domain ip_target");
@jordicenzano
jordicenzano / generate-aes128.sh
Created October 29, 2017 03:21
Bash script that generates an HLS encrypted (AES128 chunk) from MP4
#Generate HLS chunklist with AES128 chunk encryption file
#Source data
SOURCE="/Users/jcenzano/Movies/test10m_baseline_30_320x240_a25fpsB.mp4"
#Dest data
DEST="/Users/jcenzano/Movies/hls-encrypted/result-aes128"
KEYS_DIR="keys"
DEST_KEYS=$DEST"/"$KEYS_DIR
@jordicenzano
jordicenzano / generate-fairplay.sh
Last active February 15, 2025 16:46
Bash script that generates an HLS chunklist with Fairplay DRM from MP4. Also providing a test chunklist bypassing DRM
#Generate fairplay file with random generated Key, IV.
#And generate also a trobleshooting chunklist bypassing fairplay server and providing the plain key for testing
#Source data
SOURCE="/Users/jcenzano/Movies/test10m_baseline_30_320x240_a25fpsB.mp4"
#Dest data
DEST="/Users/jcenzano/Movies/hls-encrypted/result-fairplay"
KEYS_DIR="keys"
KEY_IV_FILENAME="key-iv.bin"
@jordicenzano
jordicenzano / index.js
Created November 11, 2017 20:17
Upload a growing file to S3 (test - NOT working)
#!/usr/bin/env node
const AWS = require('aws-sdk');
const crypto = require('crypto');
const http = require('http');
const stream = require('stream');
const Readable = stream.Readable;
//Stream reader
class streamFromData extends Readable {
@jordicenzano
jordicenzano / complile_ffmpeg.sh
Last active May 1, 2018 03:25
Compile ffmpeg in EC2 (no vpx, no HEVC, YES SRT)
!/bin/sh
#Prerequirsites
sudo yum update
sudo yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel tcl openssl-devel
#prepare/cleanup environment
cd ~
rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffserver,lame,vsyasm,x264,yasm,ytasm}
mkdir ~/ffmpeg_sources
@jordicenzano
jordicenzano / index.js
Created November 30, 2017 19:56
Test s3 read after write consistency
#!/usr/bin/env node
const AWS = require('aws-sdk');
const http = require('http');
//Data from TOKIO region
//Upload data
const upload_tokio = {
bucketName: 'XX',
@jordicenzano
jordicenzano / jaws-ingest.js
Last active March 3, 2018 18:44
Test Brightcove VideoCloud JAWS ingest
#!/usr/bin/env node
const https = require('https');
if (process.argv.length !== 6) {
console.error("Use: ./jaws-ingest.js hls_asset_url client_id client_secret VC_account_id");
return 1;
}
function httpReq (method, host, path, headers, body, callback) {
let answer_raw = [];
@jordicenzano
jordicenzano / dbb-pagination-test.js
Created April 12, 2018 00:17
DynamoDB Javascript pagination test
#!/usr/bin/env node
const AWS = require('aws-sdk');
AWS.config.update({region: 'us-west-2'});
const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10' });
let dbparams_q1 = {
"TableName": "alive-qa-brain-ddb-tbllivejobs",
"IndexName": "account_id-job_created_at-index",
@jordicenzano
jordicenzano / ts2fmp4.sh
Last active July 23, 2018 13:47
Convert .ts chunk to .fmp4 (HLS) chunk (NOT FINISHED YET)
#!/usr/bin/env bash
# Assumimng input .ts with 2 tracks:
# Video: h264
# Audio: AAC
# Check ffmpeg and BENTO mp4extract are installed and in the PATH
if ! [ -x "$(command -v ffmpeg)" ]; then
echo 'Error: ffmpeg is not installed.' >&2