Skip to content

Instantly share code, notes, and snippets.

View alexzzhu's full-sized avatar

Alex Zhu alexzzhu

View GitHub Profile
@alexzzhu
alexzzhu / create_gif.sh
Last active November 27, 2018 18:52
Creates a gif from a sequence of images
convert -delay 1x60 -loop 0 *.png video.gif
@alexzzhu
alexzzhu / kalibr_to_ros_cinfo.py
Created March 20, 2018 17:40
Python script to generate ROS format yaml files from the output of Kalibr. Also useful to compute rectification and projection matrices with OpenCV.
#!/usr/bin/env python
import numpy as np
import cv2
import argparse
import ruamel.yaml
def main():
parser = argparse.ArgumentParser(description="Converts a cam info in kalibr yaml format to the expected ROS format for camera_info_manager.")
parser.add_argument("--camchain", dest="camchain",
help="Camchain yaml file with camera info.",
@alexzzhu
alexzzhu / compress_video
Last active February 24, 2018 20:08
Compresses a video using ffmpeg for conference submissions
# First, resize the video to a reasonable size. Here only the width is specified, and the height is determined by the
# aspect ratio.
ffmpeg -i input.mp4 -vf scale=1024:-2 -an input_resized.mp4
# Here a bitrate of 300k is used. To calculate the right bitrate, use the formula:
# bitrate = FILE_SIZE*8192*1000/LENGTH
# where FILE_SIZE is in MB and LENGTH is in seconds, and the output bitrate is in kilobits.
# e.g. for a 137s video and a desired file size of 5MB, the bitrate should be around 5*8192*1000/137 ~ 300k
ffmpeg -y -i input_resized.mp4 -c:v libx264 -preset medium -b:v 300k -pass 1 -an -f mp4 /dev/null
ffmpeg -i input_resized.mp4 -c:v libx264 -preset medium -b:v 300k -pass 2 -an input_compressed.mp4