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 / start-webserver.sh
Last active August 31, 2019 13:46
Start simple webserver on 8080
#!/usr/bin/env bash
# Assume nodeJS and npm is installed
# Assume npm http-server is installed in global mode (-g)
echo "Starting local webserver on 8080"
http-server ~/origin -p 8080 --cors -c -1
@jordicenzano
jordicenzano / start-simple-streaming-server.sh
Last active September 8, 2021 23:34
Live streaming server RTMP in HLS out (1 rendition + overlay)
#!/usr/bin/env bash
# We assume ffmpeg installed (recommened v 4+)
# Acts as RMTP server for application named live (expects stream)
# transcodes the media data into h264-aac, craetes HLS 4s chunks,
# and sends the data to ~/origin
# Create 1 rendition1
# 854x480@30fps 1000Kbps (+ Overlay)
@jordicenzano
jordicenzano / extract-chunks-duration.ts
Created November 23, 2018 00:57
Analize video and audio duration of all .ts files in the same directory
#!/usr/bin/env node
const fs = require('fs');
const execSync = require('child_process').execSync;
// Local dir ts files
const ts_files = fs.readdirSync('.').filter(fn => fn.endsWith('.ts'));
let n = 0;
const res_total = {video:{ duration_s: 0.0, frames: 0, fr: 0}, audio: { duration_s: 0.0, frames: 0, sr: 0}};
console.log(`Num, Filename, video dur {s}, video frames, audio dur {s}, audio frames, diff (v-a), video frame rate, audio sample rate`)
@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
@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 / 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 / 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 / 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 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 / generate-fairplay.sh
Last active October 7, 2022 06:15
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"