Skip to content

Instantly share code, notes, and snippets.

#! /bin/env python
# -*- coding: utf-8 -*-
"""
This module is intended as an example of one application of
"align_videos_by_soundtrack.align". Suppose that a certain concert is
shot by multiple people from multiple angles. In most cases, shooting
start and shooting end time have individual differences. It is now time
for "align_videos_by_soundtrack.align" to come. Based on the information
obtained from "align_videos_by_soundtrack.align", this script combines
movies of multiple angles in a tile shape with "hstack" and "vstack".
# -*- coding: utf-8 -*-
import math
from PIL import Image, ImageDraw, ImageFont
#
# see details: https://en.wikipedia.org/wiki/MIDI_tuning_standard
#
_KTAB = [
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
@hhsprings
hhsprings / video_split_by_blank.py
Last active October 5, 2020 03:30
splitting video at blank using with ffmpeg
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function
import re
import io
import os
import sys
import subprocess
@hhsprings
hhsprings / pre2to3_step_zero.sh
Created March 9, 2019 03:02
pre py2to3 step zero
#! /bin/sh
#
# * fix only print_function, absolute_import
# * keep the target as code working in Python 2.7
#
_2to3="${_2to3:-/c/Python35/Tools/scripts/2to3.py}"
#
test -d "$1" && exit 1 # must be file
test -f "$1" || exit 1 # must be file
@hhsprings
hhsprings / my_mecab_userdict_build.py
Last active February 8, 2020 13:37
MeCab のユーザ辞書作成支援的ななにか
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import io
import os
import sys
import csv
if hasattr("", "decode"): # python 2
class _reader(object):
def __init__(self, f, dialect=None, *args, **kwds):
@hhsprings
hhsprings / neologd_diff_for_userdic.py
Last active October 10, 2019 13:12
MeCab のユーザ辞書作成支援的ななにか (2)
# -*- coding: utf-8-unix -*-
#
# mecab-ipadic-neologd の辞書修正・追加の考え方に共感できないところがある
# ため取捨選択しての利用としたい。
#
import io
import os
import re
import csv
import logging
@hhsprings
hhsprings / my_mecab_userdict_tyousokuon_build.py
Last active November 5, 2019 15:39
MeCab のユーザ辞書作成支援的ななにか (3)
# -*- coding: utf-8 -*-
# 入力の Adj.csv (形容詞) とか Noun.adjv.csv (名詞,形容動詞語幹) に
# 長促音を追加するやーつ。「あったかい」→「あったかーい」とか。
# Python 2.7 では動かない。対応するつもりもない。
#
# TODO: 取捨選択の規則が埋め込みだけれど、コントロール可能にすべきね。
# TODO: そもそもターゲットの絞込みフィルタも同じくね。(狙ったものだけ
# 欲しい、とかだろ、普通。)
import io
@hhsprings
hhsprings / my_mecab_userdict_from_myoujijiten.py
Last active November 5, 2019 16:09
MeCab のユーザ辞書作成支援的ななにか (4)
# -*- coding: utf-8 -*-
#
# Copyright (c) 2019, Hiroaki Itoh <https://bitbucket.org/hhsprings/>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
@hhsprings
hhsprings / ffchopreview.py
Last active April 6, 2022 21:12
to preview ffmpeg's trim
#! py -3
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import io
import sys
import subprocess
import pipes
import os
import re
@hhsprings
hhsprings / video_to_x265.py
Last active October 12, 2021 03:48
shorthand of "ffmpeg ... -c:v libx265 ..."
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import sys
import re
import subprocess
import shutil
import tempfile
import logging