Skip to content

Instantly share code, notes, and snippets.

@billyshambrook
billyshambrook / ffmpeg_build.sh
Last active September 23, 2022 07:15
Build FFMPEG, x264 and FDK-AAC
sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev yasm
sudo apt-get update
sudo apt-get -y install autoconf automake build-essential checkinstall git libass-dev \
libgpac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libspeex-dev \
libtheora-dev libtool libvorbis-dev pkg-config texi2html zlib1g-dev
cd
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
@billyshambrook
billyshambrook / test_skip_if.py
Last active August 29, 2015 14:11
Example of py.test skip if
import pytest
def is_connected():
import socket
try:
host = socket.gethostbyname("www.google.com")
socket.create_connection((host, 80), 2)
return True
except:
pass
@billyshambrook
billyshambrook / is_url.py
Created March 24, 2015 14:22
Check if string is a URL or not
import urlparse
def is_url(str_):
"""
Returns True if string is a URL.
>>> is_url('not a url')
False
>>> is_url('http://www.example.com')
@billyshambrook
billyshambrook / timer.py
Created March 30, 2015 16:58
Context statement timer
import time
class Timer(object):
def __enter__(self):
self.start = time.clock()
return self
def __exit__(self, *args):
self.end = time.clock()
@billyshambrook
billyshambrook / chunk.sh
Created April 1, 2015 20:44
chunk content
ffmpeg -i input.mpg -map 0 -c copy -an -f segment -reset_timestamps 1 -segment_time 10
"""
Requires FFprobe installed.
"""
import argparse
import json
import logging
import subprocess
logger = logging.getLogger('encode_tests')
@billyshambrook
billyshambrook / debug_qtsignals.py
Last active October 1, 2020 05:39
Debug QT Signals
import functools
import inspect
import log
from PyQt4 import QtCore
from PyQt4 import QtGui
logger = log.getLogger(__name__)
@billyshambrook
billyshambrook / debug_qtsignals_with_graph.py
Last active October 1, 2020 05:44
Debug Qt Signals with graph
import functools
import inspect
import graphviz
from PyQt4 import QtCore
from PyQt4 import QtGui
class MyGraph(object):
def __init__(self):
@billyshambrook
billyshambrook / multi_channels.py
Created November 10, 2015 17:06
Multiple channel pika consumer
import logging
import time
import pika
logger = logging.getLogger(__name__)
class Channel(object):
@billyshambrook
billyshambrook / conftest.py
Last active March 19, 2018 17:26
Categorise integration tests using PyTest.
import pytest
def pytest_addoption(parser):
parser.addoption("--integration", action="store_true", help="run integration tests")
def pytest_runtest_setup(item):
if 'integration' in item.keywords:
item.config.getoption("--integration", skip=True)