Skip to content

Instantly share code, notes, and snippets.

View alastairmccormack's full-sized avatar

Alastair McCormack alastairmccormack

View GitHub Profile
@alastairmccormack
alastairmccormack / mp2aspect.py
Created March 4, 2014 21:26
MPEG 2 Transport Stream + MP2 Video DAR Aspect Detector
# An Display aspect ratio (DAR) detector for MPEG 2 Transport Streams with MP2 Video
import array
import logging
import sys
class NullHandler(logging.Handler):
def emit(self, record):
pass
@alastairmccormack
alastairmccormack / SCTE35 Decoder
Last active December 27, 2019 23:39
SCTE-35 Parser/Decoder in Python
#!/usr/bin/python
'''
SCTE-35 Decoder
The MIT License (MIT)
Copyright (c) 2014 Al McCormack
@alastairmccormack
alastairmccormack / PKCS12 Cert Expire Check
Created October 19, 2014 00:30
Checks the expiry of a cert from the a PKCS12 file and alerts using tunable warning period
from OpenSSL.crypto import *
import time
import datetime
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
help="PKCS12/pfx file", metavar="FILE")
parser.add_option("-p", "--password",
@alastairmccormack
alastairmccormack / widevinecdm.proto
Last active February 22, 2021 11:31
An incomplete reverse-engineer of the Widevine EME CDM request protobuf object.
// Used by https://github.com/use-sparingly/pywvpssh to automatically
// strip PSSH from MP4 files
package WidevineCDM;
message WvEmeRequest {
required int32 version = 1; // 1
//start rlen end
message Level1 { //0x02 1467 0x5BD
@alastairmccormack
alastairmccormack / hds_loadtest.py
Created September 4, 2015 09:06
Adobe HDS Load Testing Tool using Locust Framework. See inline for details
# HDS Load Testing Tool using Locust Load Testing Framework and HDS_Fragmenter library
# Simulates user access by fetching the bootstrap file to parse out fragment names.
# Bootstrap files are fetched 1/10 times.
#
# Usage:
# 1. Fetch dependencies given below
# 2. Edit "url_f4m_path" below to the stream-level manifest path/URI
# 3. Run: `locust -f hdslt.py -H http://my_origin_server`
# pip install locustio
@alastairmccormack
alastairmccormack / x509_sha1_fingerprint.py
Created November 13, 2015 03:40
Gets a SHA1 fingerprint from an x509 certificate using Python and OpenSSL crypto module
from OpenSSL.crypto import load_certificate, FILETYPE_PEM
cert_file_string = open("esx.crt", "rb").read()
cert = load_certificate(FILETYPE_PEM, cert_file_string)
sha1_fingerprint = cert.digest("sha1")
print sha1_fingerprint
@alastairmccormack
alastairmccormack / 123-reg to AWS Route53
Created January 21, 2016 14:39
Migrate 123-reg DNS entries to AWS Route53
import boto.route53
import boto.regioninfo
import requests
import logging
DOMAIN = ""
USERNAME_123REG = ""
PASSWORD_123REG = ""
AWS_ACCESS = ""
@alastairmccormack
alastairmccormack / iframe-probe.py
Last active September 10, 2024 19:50
Shows GOP structure for video file using ffmpeg --show-frames output
#!/usr/bin/env python
#
# Shows GOP structure of video file. Useful for checking suitability for HLS and DASH packaging.
# Example:
#
# $ iframe-probe.py myvideo.mp4
# GOP: IPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP 60 CLOSED
# GOP: IPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP 60 CLOSED
# GOP: IPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP 60 CLOSED
# GOP: IPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP 60 CLOSED
@alastairmccormack
alastairmccormack / chardet_open.py
Last active March 16, 2016 11:11
Encoding detecting Python open() - Automatically detects encoding of existing text files for reading and writing
from chardet.universaldetector import UniversalDetector # pip install chardet
import io
import os.path
def open(file, mode='r', buffering=-1, encoding=None, errors=None,
newline=None, closefd=True):
""" A wrapper for io.open(), which tries to detect the encoding of a file
using chardet before reading or writing
Supports all arguments of io.open(). "encoding" is only used if file does
@alastairmccormack
alastairmccormack / presets.json
Last active August 16, 2016 12:06
AWS Elastic Transcode Profiles conforming to Apple's TN2224 Best Practice (Revision: 2016-08-02)
{
"Audio": {"AudioPackingMode": null,
"BitRate": "96",
"Channels": "2",
"Codec": "AAC",
"CodecOptions": {"BitDepth": null,
"BitOrder": null,
"Profile": "AAC-LC",
"Signed": null},
"SampleRate": "48000"},