Skip to content

Instantly share code, notes, and snippets.

View CrashLaker's full-sized avatar
💭
🌌 Wired

Carlos Aguni • 顾宁 CrashLaker

💭
🌌 Wired
View GitHub Profile
#!/bin/bash
#$2 .mp3
ffmpeg -i $1 -acodec libmp3lame -aq 4 $2
#https://ubuntuforums.org/showthread.php?t=1493682
@CrashLaker
CrashLaker / vtt2srt
Last active February 15, 2017 00:49
Bash script convert vtt subtitle to srt
#!/bin/bash
# $1 = filelocation
# Renames filename.vtt to filename.srt besides converting it
sed -i "/WEBVTT/d" $1
for i in `grep -n "\-\->" $1 | cut -d: -f1`; do sed -i "${i}s/\([0-9]\)\.\([0-9]\)/\1,\2/g" $1; done
newname=`echo $1 | sed "s/vtt/srt/g"`
mv $1 $newname
x=1;for i in `grep -n "^$" $newname | cut -d: -f1`; do sed -i "${i}s/.*/crashlaker${x}/" $newname; x=$((x+1)); done
@CrashLaker
CrashLaker / mergeMp4
Last active April 30, 2018 15:52
Merge mp4 video files using bash + ffmpeg
#!/bin/bash
# $1 = filename
rm -f ${1}.mp4
a=1;for file in `ls ${1}*.mp4`; do ffmpeg -i $file -c copy -bsf:v h264_mp4toannexb -f mpegts tmpfile${a}.ts; a=$((a+1)); done
ffmpeg -i "concat:`ls tmpfile*.ts | paste -s -d\"|\"`" -c copy -bsf:a aac_adtstoasc ${1}.mp4
@CrashLaker
CrashLaker / python-dateing-1.py
Last active May 5, 2019 02:47
python dateing-1
import datetime
import time
date = datetime.datetime(2019,5,1) # date object
print(date) # 2019-05-01 00:00:00
ts = time.mktime(date.timetuple()) # timestamp in seconds
print(ts) # 1556668800.0
import datetime
timestamp = 1556668800.0
date = datetime.datetime.utcfromtimestamp(timestamp)
print(date) # 2019-05-01 00:00:00
import datetime
import pytz
timestamp = 1556668800.0
date = datetime.datetime.utcfromtimestamp(timestamp)
print(date) # 2019-05-01 00:00:00
# Applying timezone without converting it
date_sp = pytz.timezone("America/Sao_Paulo").localize(date)
print(date_sp.strftime(fmt)) # 2019-05-01 00:00:00 -03-0300
import datetime
import pytz
timestamp = 1556668800.0
date = datetime.datetime.utcfromtimestamp(timestamp)
print(date) # 2019-05-01 00:00:00
# Applying timezone without converting it
date_utc = pytz.utc.localize(date)
print(date_utc.strftime(fmt)) # 2019-05-01 00:00:00 UTC+0000
@CrashLaker
CrashLaker / index.html
Last active March 3, 2020 04:55
rooms schedule timeline chart
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.line {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}
.zoom {
gistup