Skip to content

Instantly share code, notes, and snippets.

Avatar
🪲

Ben Lopatin bennylope

🪲
View GitHub Profile
@bennylope
bennylope / ffmpeg-watermark.md
Created Apr 22, 2016 — forked from webkader/ffmpeg-watermark.md
FFmpeg add a watermark to video
View ffmpeg-watermark.md

How to Add a Watermark to Video

FFMPEG filters provide a powerful way to programmatically enhance or alter videos, and it’s fairly simple to add a watermark to a video using the overlay filter. The easiest way to install ffmpeg is to download a pre-built binary for your specific platform. Then you don’t have to worry about including and installing all the right dependencies and codecs you will be using.

Once you have ffmpeg installed, adding a watermark is as easy as passing your existing source through an overlay filter like so:

ffmpeg -i test.mp4 -i watermark.png -filter_complex "overlay=10:10" test1.mp4

Basically, we’re passing in the original video, and an overlay image as inputs, then passing it through the filter, and saving the output as test1.mp4.

@bennylope
bennylope / migrate.py
Last active Oct 20, 2022
PostgreSQL migration script, Heroku -> Crunchy
View migrate.py
#!/usr/bin/env python
import argparse
import os
import subprocess
import sys
import time
# Required so we don't generate tons of logs during restore
disable_logging_sql = "ALTER USER postgres RESET pgaudit.log;"
@bennylope
bennylope / gist:1894706
Created Feb 23, 2012
Canonical URLs with Jekyll
View gist:1894706
<link rel="canonical" href="http://yourdomain.com{{ page.url | replace:'index.html','' }}" />
@bennylope
bennylope / LICENSE
Last active Aug 3, 2022
Django manage.py file that loads environment variables from a .env file per Honcho/Foreman
View LICENSE
Copyright the authors of Honcho and/or Ben Lopatin
Licensed for reuse, modification, and distribution under the terms of the MIT license
View slacktime.fish
function slacktime
while read line;
if [ (string match "*WORKTIME" "$line") ]
continue
else
echo $line
end
end < /etc/hosts > /tmp/hosts
sudo cp /tmp/hosts /etc/hosts
end
@bennylope
bennylope / remotefiles.conf
Created Oct 19, 2011
nginx remote file proxying
View remotefiles.conf
location ~* ^/remote-files/(http[s]*://)(.*?)/(.*) {
# Do not allow people to mess with this location directly
# Only internal redirects are allowed
internal;
# nginx has to be able to resolve the remote URLs
resolver 8.8.8.8;
# Location-specific logging
#access_log /usr/local/etc/nginx/logs/internal_redirect.access.log main;
View annotated.py
from functools import wraps
def annotated(annotation_name):
"""
Decorator for returning pre-calculated, annotated values
This should be used with model instance methods that fetch some
kind of related or calculated data. If the method is called on
a single instance in isolation, we should expect the method to
@bennylope
bennylope / ansible.yml
Created Apr 30, 2014
Deployment w/ Capistrano style deployments with Ansible & Capistrano
View ansible.yml
---
- name: Deploy new site release
user: deployer
hosts: all
tasks:
- name: Fetch repo updates
git: >
repo=git@github.com:my/repo.git
@bennylope
bennylope / create_db_restore.sh
Last active Aug 20, 2020
Create a named database and restore from the lastest downloaded file
View create_db_restore.sh
#!/usr/bin/env bash
LATEST_DB="$HOME/Downloads/$(ls -t ~/Downloads | head -1)"
BACKUP_PATH=${2-$LATEST_DB}
DB=$1
echo "Creating database name $DB from $BACKUP_PATH"
psql -c "CREATE DATABASE $DB;"
View remotefile.py
import requests
class RemoteFile:
"""
Context manager for handling remote OR local files
Can be used like so:
>>> with RemoteFile("/path/to/local/file.txt") as f: