Skip to content

Instantly share code, notes, and snippets.

View sinkers's full-sized avatar

Andrew Sinclair sinkers

View GitHub Profile
@sinkers
sinkers / tasks.py
Created September 5, 2014 02:36
Celery chord issue
# tasks.py
from celery import task, Celery, subtask, group
import time
REDIS_SERVER = 'redis://localhost:6379'
celery = Celery("app", broker=REDIS_SERVER, backend=REDIS_SERVER)
@task()
def task1(input):
@sinkers
sinkers / gist:fac6da1475dc49c038ac
Created August 25, 2014 05:04
Simple task submission to Celery
# First part is a unit test script effectively, this code would go in the Flask app
from celery import Celery
# There needs to be a seperate tasks module, see below
import tasks
# Celery uses redis to commuicate between tasks
celery = Celery("app", broker='redis://localhost:6379',backend='redis://localhost:6379')
# This submits the task to run via Celery
@sinkers
sinkers / gist:7200afc08a6118f073a9
Created August 25, 2014 04:55
Simple tornado based server
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
import tornado.netutil
import requests
import os
import netifaces
from worker import app
from worker import register
@sinkers
sinkers / gist:4e35c1b9922b8bd85452
Last active August 28, 2018 18:50
Encoding HLS and DASH in a simple script, lot's of tweaks to go
#!/usr/bin/python
# Script to encode HLS and DASH from a multi TS mezzanine file
# Places encoded files in a folder of the same name as the source input
# Steps
# 1. Check file with mediainfo (optional)
# 2. Encode to resolutions as mp4
# 3. Split into TS segments and create playlists
# 4. Create variant playlist
import subprocess
@sinkers
sinkers / livestreammonitor.py
Created July 14, 2014 04:50
Script for live video streaming monitoring with notifications
#!/usr/bin/python
'''
Script to monitor live streams and send an Amazon SNS if the stream is down (and possibly take restorative action)
Future:
Black detect: ffmpeg -i out.mp4 -vf blackdetect -f null -
Note the following doesn't seem to fully work without looking at the debug logs
On live ffmpeg -y -i rtmp://cp30129.live.edgefcs.net/live/videoops-videoops@50541 -vf blackdetect -t 10 -loglevel debug -f null -
'''
@sinkers
sinkers / gist:5cc2854e01a05a2db650
Created July 11, 2014 07:07
Creating multiple DASH renditions with a bitrate text overlay, using ffmpeg and Bento
#!/bin/sh
# encode_bitrate_overlay.sh
#
#
# Created by Andrew Sinclair on 11/07/2014.
#
#!/bin/bash
VIDSOURCE=$1
OUTNAME=$2
@sinkers
sinkers / gist:c4d39960018bca3540d4
Created July 11, 2014 04:12
Script for multiple bitrate encoding with text on each bitrate for testing
#!/bin/sh
# encode_bitrate_overlay.sh
#
#
# Created by Andrew Sinclair on 11/07/2014.
#
#!/bin/bash
VIDSOURCE=$1
OUTNAME=$2
@sinkers
sinkers / gist:148a39f8d926a443501a
Created July 11, 2014 01:42
Simple script for encoding files for use with Akamai HD and generating a SMIL file
#!/bin/bash
VIDSOURCE=$1
OUTNAME=$2
RESOLUTION1="320x180"
RESOLUTION2="512x288"
RESOLUTION3="640x360"
RESOLUTION4="960x540"
RESOLUTION5="1024x576"
RESOLUTION6="1280x720"
RESOLUTION7="1920x1080"
<adRequest networkId="90750" version="1" profile="90750:ooyala_android">
<capabilities>
<supportsSlotTemplate />
<supportsAdUnitInMultipleSlots />
<supportNullCreative />
<supportsSlotCallback />
<requiresVideoCallbackUrl />
<supportsFallbackAds />
<expectMultipleCreativeRenditions />
<requiresRendererManifest />
@sinkers
sinkers / freewheelvmap.py
Last active April 2, 2019 17:26
Generating a Freewheel VMAP 1.0 Ad Tag
import requests
import random
import xml.dom.minidom
'''
Simple script to simulate what needs to go in a Freewheel ad request
This example is for VMAP but what needs to be requested is similar on other response types e.g. FW Smart XML
To use Smart XML response just change the resp parameter to "xml"
'''