示例#1
0
def dump_frames(args, v_info):
    if args.frame_rate is None:
        frame_rate = v_info["frame_rate"]
    else:
        frame_rate = args.frame_rate

    cmd = [
        find_executable("avconv", "ffmpeg"), "-loglevel", "info", "-r",
        str(frame_rate), "-i", args.video, "-filter:v", "yadif", "-ss",
        str(args.offset), "-t",
        str(args.duration)
    ]

    if args.width != 0:
        if v_info["dar"] is not None:
            src_width, src_height = v_info["dar"].split(":")
        else:
            src_width, src_height = map(v_info.get, ["width", "height"])

        src_width, src_height = map(int, [src_width, src_height])

        width = args.width
        height = (args.width * src_height) / src_width

        cmd += ["-s", "{}x{}".format(width, height)]

    cmd += ["{}/%05d.png".format(args.dist)]

    print("exec: {}".format(" ".join(cmd)))
    subprocess.check_call(cmd)
示例#2
0
def open_dir(directory):
    cmd = [
        find_executable("xdg-open", "open"),
        directory
    ]
    print("exec: {}".format(" ".join(cmd)))
    subprocess.check_call(cmd, stderr=subprocess.PIPE)
示例#3
0
def get_video_info(video):
    cmd = [
        find_executable("avprobe", "ffprobe"), "-loglevel", "error",
        "-show_streams", "-show_format_entry", "width", "-show_format_entry",
        "height", "-show_format_entry", "display_aspect_ratio",
        "-show_format_entry", "avg_frame_rate", video
    ]
    print("exec: {}".format(" ".join(cmd)))
    out = subprocess.check_output(cmd, stderr=subprocess.PIPE)

    info = {}
    for line in out.split(os.linesep):
        kv = line.split("=")
        if len(kv) == 1:
            k = kv[0]
            v = None
        elif len(kv) == 2:
            k, v = kv
        else:
            raise "Invalid line format: {}".format(kv)
        if k not in info:
            info[k] = v

    info["dar"] = info.get("display_aspect_ratio")
    info["frame_rate"] = parse_frame_rate(info.get("avg_frame_rate"))

    return info
示例#4
0
def get_video_info(video):
    cmd = [
        find_executable("avprobe", "ffprobe"),
        "-loglevel", "error",
        "-show_streams",
        "-show_format_entry", "width",
        "-show_format_entry", "height",
        "-show_format_entry", "display_aspect_ratio",
        "-show_format_entry", "avg_frame_rate",
        video
    ]
    print("exec: {}".format(" ".join(cmd)))
    out = subprocess.check_output(cmd, stderr=subprocess.PIPE)

    info = {}
    for line in out.split(os.linesep):
        kv = line.split("=")
        if len(kv) == 1:
            k = kv[0]
            v = None
        elif len(kv) == 2:
            k, v = kv
        else:
            raise "Invalid line format: {}".format(kv)
        if k not in info:
            info[k] = v

    info["dar"] = info.get("display_aspect_ratio")
    info["frame_rate"] = parse_frame_rate(info.get("avg_frame_rate"))

    return info
示例#5
0
def dump_frames(args, v_info):
    if args.frame_rate is None:
        frame_rate = v_info["frame_rate"]
    else:
        frame_rate = args.frame_rate

    cmd = [
        find_executable("avconv", "ffmpeg"),
        "-loglevel", "info",
        "-r", str(frame_rate),
        "-i", args.video,
        "-filter:v", "yadif",
        "-ss", str(args.offset),
        "-t", str(args.duration)
    ]

    if args.width != 0:
        if v_info["dar"] is not None:
            src_width, src_height = v_info["dar"].split(":")
        else:
            src_width, src_height = map(v_info.get, ["width", "height"])

        src_width, src_height = map(int, [src_width, src_height])

        width = args.width
        height = (args.width * src_height) / src_width

        cmd += ["-s", "{}x{}".format(width, height)]

    cmd += ["{}/%05d.png".format(args.dist)]

    print("exec: {}".format(" ".join(cmd)))
    subprocess.check_call(cmd)
示例#6
0
def open_gif(gif):
    cmd = [
        find_executable("xdg-open", "open"),
        gif
    ]
    print("exec: {}".format(" ".join(cmd)))
    subprocess.check_call(cmd, stderr=subprocess.PIPE)
示例#7
0
def get_video_info(video):
    cmd = [
        find_executable("avprobe", "ffprobe"),
        "-of", "json",
        "-loglevel", "error",
        "-show_streams",
        video
    ]
    print("exec: {}".format(" ".join(cmd)))
    out = subprocess.check_output(cmd, stderr=subprocess.PIPE)
    out = json.loads(out)

    for stream in out["streams"]:
        if stream["codec_type"] != "video":
            continue
        info = stream
    info["dar"] = info.get("display_aspect_ratio")
    info["frame_rate"] = parse_frame_rate(info.get("avg_frame_rate"))

    return info
示例#8
0
def open_dir(directory):
    cmd = [find_executable("xdg-open", "open"), directory]
    print("exec: {}".format(" ".join(cmd)))
    subprocess.check_call(cmd, stderr=subprocess.PIPE)
import util
import sys
import os
import re

inkscape = util.find_executable("inkscape", ["/Applications/Inkscape.app/Contents/Resources/bin/inkscape", "/usr/bin/inkscape"])
def svg2eps(svg_fname, eps_fname):
    os.popen(inkscape + " " + svg_fname + " --export-eps=" + eps_fname)

def svg2png(svg_fname, png_fname, width="500"):
    os.popen(inkscape + " " + svg_fname + " --export-png=" + png_fname + " --export-width=" + width)

def svg2pdf(svg_fname, pdf_fname):
    os.popen(inkscape + " " + svg_fname + " --export-pdf=" + pdf_fname)

## MAIN
if (len(sys.argv) < 2):
    raise Exception("Syntax: batch_svg2image <path> <output format>")

for fname in os.listdir(sys.argv[1]):
    if (fname[len(fname)-4:] == ".svg"):
        base_fname = sys.argv[1] + "/" + fname[0:len(fname)-4]
        print "converting", base_fname
        if (len(sys.argv) < 3 or sys.argv[2] == "png"):
            svg2png(base_fname + ".svg", base_fname + ".png")
        elif (sys.argv[2] == "eps"):
            svg2eps(base_fname + ".svg", base_fname + ".eps")
        elif (sys.argv[2] == "pdf"):
            svg2pdf(base_fname + ".svg", base_fname + ".pdf")
        else:
            raise Exception("unknown output figure format: " + sys.argv[2])
示例#10
0
import util
import sys
import os
import re

inkscape = util.find_executable("inkscape", [
    "/Applications/Inkscape.app/Contents/Resources/bin/inkscape",
    "/usr/bin/inkscape"
])


def svg2eps(svg_fname, eps_fname):
    os.popen(inkscape + " " + svg_fname + " --export-eps=" + eps_fname)


def svg2png(svg_fname, png_fname, width="500"):
    os.popen(inkscape + " " + svg_fname + " --export-png=" + png_fname +
             " --export-width=" + width)


def svg2pdf(svg_fname, pdf_fname):
    os.popen(inkscape + " " + svg_fname + " --export-pdf=" + pdf_fname)


## MAIN
if (len(sys.argv) < 2):
    raise Exception("Syntax: batch_svg2image <path> <output format>")

for fname in os.listdir(sys.argv[1]):
    if (fname[len(fname) - 4:] == ".svg"):
        base_fname = sys.argv[1] + "/" + fname[0:len(fname) - 4]
示例#11
0
#!/usr/bin/python

import os
from chemistry import ChemGraph
from chemconstants import *
import util
import svg
import sys

molconvert = util.find_executable("molconvert", ["/Applications/MarvinBeans/bin/molconvert", "/home/eladn/ChemAxon/MarvinBeans/bin/molconvert"])
inkscape = util.find_executable("inkscape", ["/Applications/Inkscape.app/Contents/Resources/bin/inkscape", "/usr/bin/inkscape"])

import gzip
global map_compound2graph; map_compound2graph = {}
global map_hash2compound; map_hash2compound = {}
global map_hash2compound_unchiral; map_hash2compound_unchiral = {}

def load_mcard(filename, gzipped=False):
    if (gzipped):
        file = gzip.GzipFile(filename, 'r')
    else:
        file = open(filename, 'r')
    
    print >> sys.stderr, "Parsing database file: %s" % filename
    # Parse the Mcard SDF database file:
    while True:
        header = file.readline()
        if (header == ""):
            break
        
        body = util.readlines_until_mark(file, "$$$$")
示例#12
0
#!/usr/bin/python

import os
from chemistry import ChemGraph
from chemconstants import *
import util
import svg
import sys

molconvert = util.find_executable("molconvert", [
    "/Applications/MarvinBeans/bin/molconvert",
    "/home/eladn/ChemAxon/MarvinBeans/bin/molconvert"
])
inkscape = util.find_executable("inkscape", [
    "/Applications/Inkscape.app/Contents/Resources/bin/inkscape",
    "/usr/bin/inkscape"
])

import gzip
global map_compound2graph
map_compound2graph = {}
global map_hash2compound
map_hash2compound = {}
global map_hash2compound_unchiral
map_hash2compound_unchiral = {}


def load_mcard(filename, gzipped=False):
    if (gzipped):
        file = gzip.GzipFile(filename, 'r')
    else:
示例#13
0
def open_gif(gif):
    cmd = [find_executable("xdg-open", "open"), gif]
    print("exec: {}".format(" ".join(cmd)))
    subprocess.check_call(cmd, stderr=subprocess.PIPE)