Compare commits
110 Commits
40eb9aa808
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| fe531b185f | |||
| e009688aa0 | |||
| bade7f762a | |||
|
01edb8f277
|
|||
| 1474e23aea | |||
| 08ed0a411d | |||
| 9fb52326f9 | |||
| 56e4ad3386 | |||
| 0ecad79655 | |||
| 8c4fbcc4a8 | |||
| dcf670070d | |||
| 121d451982 | |||
| 240d38eea0 | |||
| 37e6c770d7 | |||
| 1db6c9e9b0 | |||
| a25c209ddf | |||
| 3b6daf46a1 | |||
| 25b741d913 | |||
| 8a348ac299 | |||
| aed6afbe38 | |||
| 6b879c4d66 | |||
| aa948710a2 | |||
| 923f7fbcd6 | |||
| 80227c1d76 | |||
| 2d0191c775 | |||
| 079cec8402 | |||
| c1c6fec29c | |||
| 740fc319db | |||
| 3bff9be48a | |||
| 172396583f | |||
| cefab517a5 | |||
| 159c8cff90 | |||
| 67bd7e4454 | |||
| 606096c674 | |||
| 19f90233de | |||
| 5715367556 | |||
| 9216d7cee5 | |||
| 9876fcf4cd | |||
| e175fefa18 | |||
| 2a6522b4b7 | |||
| dc88f6cc36 | |||
| 65500a66ea | |||
| a2c5c8a4d6 | |||
| 7d928a25ea | |||
| 4b6d506d7b | |||
| 05c46303c8 | |||
| bc21059ea6 | |||
| 3971799926 | |||
| d7823294b5 | |||
| 02593ec5f6 | |||
| 928cc915dd | |||
| 137efc71a6 | |||
| 98c74416e8 | |||
| 95b05d5944 | |||
| 34d1a0ea04 | |||
| e921e6b9eb | |||
| b399a9e2c9 | |||
| 6889755330 | |||
| 2beccaeeb3 | |||
| 8ad4d67d84 | |||
| abbcd76178 | |||
| f9a06756ca | |||
| 851dc77481 | |||
| f0f2a0f38d | |||
| 208ba7278a | |||
| 4fb7e6cf37 | |||
| 19b3701a95 | |||
| 6555d9d355 | |||
| 27a08fb402 | |||
| bb26b8ceff | |||
| ba9a776867 | |||
| 90c312e954 | |||
| e759f8c3cd | |||
| fb2773ca19 | |||
| 62fa34ca20 | |||
| d7977096a7 | |||
| e3812590a2 | |||
| 7ac31b295f | |||
| 3ea85786ce | |||
| 9b5159e705 | |||
| f636229f5c | |||
| 515a9f479a | |||
| 12a11b2435 | |||
| e602fc281c | |||
| d19e60cfc3 | |||
| 0ee1e7666e | |||
| c7845e62d9 | |||
| 2a57ce8837 | |||
| a529cd6560 | |||
| 589abb9e46 | |||
| 6df4a1e506 | |||
| 10c6e8e06c | |||
| f70bc8b9cd | |||
| dad6be889f | |||
| e979d1094c | |||
| ce1599466e | |||
| e5e8f309e5 | |||
| 8ff9c338b5 | |||
| 173bda9eb0 | |||
| 06bbc0c995 | |||
| f19e84e1a5 | |||
| 1a46964bd7 | |||
| 0e91857946 | |||
| bb31351404 | |||
| 7b031d3127 | |||
| c05131d38f | |||
| 418d1ae956 | |||
| e614936478 | |||
| 5bed58e55c | |||
| 6800f7ccc4 |
@@ -13,16 +13,20 @@ esac
|
||||
export PLATFORM=$platform
|
||||
export PLATFORM_OS=$platform_os
|
||||
|
||||
test -f "$HOME/.env.platform" && . "$HOME/.env.platform"
|
||||
os_lower="${platform_os,,}"
|
||||
test -f "$HOME/dotfiles/${os_lower}/env.platform" && . "$HOME/dotfiles/${os_lower}/env.platform"
|
||||
|
||||
test -f "$HOME/.env.common-pre" && . "$HOME/.env.common-pre"
|
||||
test -f "$HOME/.env.private" && . "$HOME/.env.private"
|
||||
test -f "$HOME/.env.common-post" && . "$HOME/.env.common-post"
|
||||
|
||||
test -f "$HOME/.aliases" && . "$HOME/.aliases"
|
||||
test -f "$HOME/.aliases.common" && . "$HOME/.aliases.common"
|
||||
test -f "$HOME/.aliases.private" && . "$HOME/.aliases.private"
|
||||
|
||||
if [[ $_MC_SET_ENV_PATH -ne 1 ]]; then
|
||||
test -d "$HOME/bin" && export PATH=$HOME/bin/:$PATH
|
||||
#TODO: remove this
|
||||
test -d "$HOME/.dotfiles/bin" && export PATH=$HOME/.dotfiles/bin/:$PATH
|
||||
fi
|
||||
|
||||
@@ -1,17 +1,33 @@
|
||||
[include]
|
||||
path = ~/.gitconfig.platform
|
||||
path = ~/.gitconfig.private
|
||||
# Shared config from private dotfiles
|
||||
path = ~/.private-dotfiles.common/gitconfig
|
||||
# Computer-specific config from private dotfiles (might not exist)
|
||||
path = ~/.private-dotfiles/gitconfig
|
||||
[init]
|
||||
defaultBranch = master
|
||||
[merge]
|
||||
summary = true
|
||||
tool = vimdiff
|
||||
[core]
|
||||
excludesfile = ~/.gitignore
|
||||
excludesfile = ~/.private-dotfiles.common/gitignore
|
||||
hookspath = ~/.git_hooks
|
||||
preloadindex = true
|
||||
fscache = true
|
||||
editor = vim
|
||||
# I used to have this set to true, which would result in checked out files
|
||||
# being converted to CRLF line endings and commits converting to LF. I'm
|
||||
# tired of this conversion shit though so I'm turning it off and will be
|
||||
# enforcing LF line endings via a combination of editorconfig and
|
||||
# gitattribute files on a per-project basis. This should make sure that
|
||||
# anyone contributing to my projects will be committing LF line endings.
|
||||
# The only exception is that the gitattributes files will commit batch
|
||||
# files with CRLF to avoid Windows glitches.
|
||||
#
|
||||
# I used these posts for reference:
|
||||
# https://markentier.tech/posts/2021/10/autocrlf-true-considered-harmful/
|
||||
# https://troyready.com/blog/git-windows-dont-convert-line-endings.html
|
||||
#
|
||||
autocrlf = false
|
||||
[push]
|
||||
default = upstream
|
||||
[pull]
|
||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,9 +1 @@
|
||||
vim/.netrwhist
|
||||
vim/bundle/*
|
||||
vim/plugged/*
|
||||
vim/undo
|
||||
vim/undo/*
|
||||
vim/autoload/plug.vim.old
|
||||
config/openbox/lxde-rc.xml
|
||||
*.pyc
|
||||
!bin
|
||||
*
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "vim/bundle/Vundle.vim"]
|
||||
path = vim/bundle/Vundle.vim
|
||||
url = https://github.com/VundleVim/Vundle.vim.git
|
||||
@@ -22,7 +22,7 @@
|
||||
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
||||
"
|
||||
" " On-demand loading
|
||||
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
||||
" Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
|
||||
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
||||
"
|
||||
" " Using a non-default branch
|
||||
@@ -15,7 +15,9 @@ endif
|
||||
|
||||
set background=dark
|
||||
hi clear
|
||||
syntax reset
|
||||
if exists("syntax_on")
|
||||
syntax reset
|
||||
endif
|
||||
|
||||
source $HOME/.vim/colors/utils
|
||||
let g:colors_name = "campo-dark-blue"
|
||||
@@ -33,6 +35,7 @@ let s:bg = "072730"
|
||||
let s:select = "546e8f"
|
||||
let s:window = "37474f"
|
||||
let s:comment = "5dea82"
|
||||
let s:annotated_note = "8dea82"
|
||||
let s:tab = "03404a"
|
||||
let s:error = "e40e0e"
|
||||
let s:proc = "0eefcb"
|
||||
@@ -83,7 +86,7 @@ call X("Identifier", s:grey, "", "none")
|
||||
call X("Statement", s:text, "", "") " 'return', 'goto', 'case', 'break', etc
|
||||
call X("Conditional", s:text, "", "")
|
||||
call X("Repeat", s:text, "", "") " 'for' and 'while'
|
||||
call X("Structure", "ae90ea", "", "")
|
||||
call X("Structure", "ae90ea", "", "") " enum, struct, union
|
||||
call X("Function", s:proc, "", "")
|
||||
call X("Constant", s:text, "", "") " Constants, e.g. SOME_CONST
|
||||
call X("Boolean", s:text, "", "") " true, false
|
||||
@@ -96,11 +99,12 @@ call X("Define", "a5bce4", "", "none")
|
||||
call X("Include", s:text, "", "") " #include in C/C++
|
||||
call X("Number", s:text, "", "")
|
||||
|
||||
" Notes
|
||||
call X("Todo", "b8fbb0", s:bg, "underline")
|
||||
call X("Bugs", "d8fbb0", s:bg, "standout")
|
||||
call X("Notes", "ffffff", s:bg, "standout")
|
||||
call X("Notices", s:warn, s:bg, "bold")
|
||||
" Notes and annotated comment text
|
||||
call X("MyTitle", s:text, "", "bold") " // # Some Title
|
||||
call X("MyAnnotatedNote", s:text, "", "bold") " // @incomplete
|
||||
call X("MyNote", s:annotated_note, "", "standout") " // NOTE:, IDEA:, TODO:
|
||||
call X("MyEmphasis", s:yellow, "", "bold") " // WARNING:, IMPORTANT:
|
||||
call X("MyBug", s:red, "", "standout") " // FIXME:, BUG:, DEPRECATED:
|
||||
|
||||
" Build markers
|
||||
call X("BuildError", s:error, s:bg, "bold")
|
||||
@@ -123,31 +127,6 @@ call X("cStorageClass", s:text, "", "")
|
||||
call X("cConditional", s:text, "", "")
|
||||
call X("cRepeat", s:text, "", "")
|
||||
|
||||
" Python Highlighting
|
||||
call X("pythonInclude", s:red, "", "")
|
||||
call X("pythonStatement", s:blue, "", "")
|
||||
call X("pythonConditional", s:purple, "", "")
|
||||
call X("pythonRepeat", s:purple, "", "")
|
||||
call X("pythonException", s:purple, "", "")
|
||||
call X("pythonFunction", s:proc, "", "")
|
||||
call X("pythonSelf", s:grey, "", "")
|
||||
call X("pythonOperator", s:purple, "", "")
|
||||
call X("pythonExtraOperator", s:purple, "", "")
|
||||
call X("pythonClass", s:proc, "", "")
|
||||
call X("pythonDecorator", s:orange, "", "")
|
||||
call X("pythonDocstring", s:comment, "", "")
|
||||
call X("pythonBuiltinObj", s:yellow, "", "")
|
||||
call X("pythonBuiltinType", s:orange, "", "")
|
||||
call X("pythonNumber", s:orange, "", "")
|
||||
|
||||
" JS Highlighting
|
||||
call X("javaScriptBraces", s:text, "", "")
|
||||
call X("javaScriptFunction", s:purple, "", "")
|
||||
call X("javaScriptConditional", s:purple, "", "")
|
||||
call X("javaScriptRepeat", s:purple, "", "")
|
||||
call X("javaScriptNumber", s:orange, "", "")
|
||||
call X("javaScriptMember", s:orange, "", "")
|
||||
|
||||
" HTML Highlighting
|
||||
call X("htmlTag", s:text, "", "")
|
||||
call X("htmlTagName", s:text, "", "")
|
||||
136
.vim/colors/campo-dark-earth.vim
Normal file
136
.vim/colors/campo-dark-earth.vim
Normal file
@@ -0,0 +1,136 @@
|
||||
" A simple dark earth-tone vim colorscheme.
|
||||
" Created by Michael Campagnaro (https://git.michael.is)
|
||||
|
||||
if has('termguicolors')
|
||||
" Supports 24-bit color range
|
||||
set termguicolors
|
||||
else
|
||||
echoerr "This theme requires 'termguicolors' support!"
|
||||
endif
|
||||
|
||||
if !has("gui_running") && &t_Co != 88 && &t_Co != 256
|
||||
echoerr "Don't have expected color support!"
|
||||
endif
|
||||
|
||||
set background=dark
|
||||
hi clear
|
||||
if exists("syntax_on")
|
||||
syntax reset
|
||||
endif
|
||||
|
||||
source $HOME/.vim/colors/utils
|
||||
let g:colors_name = "campo-dark-earth"
|
||||
|
||||
" Shared colors
|
||||
let s:blue = "3699cc"
|
||||
let s:purple = "ce93d8"
|
||||
let s:grey = "b0bec5"
|
||||
let s:orange = "ffb74d"
|
||||
let s:yellow = "fff176"
|
||||
let s:green = "88b888"
|
||||
let s:red = "ef2929"
|
||||
let s:text = "e5d8d0" " A majority of the syntax will use this.
|
||||
let s:bg = "24252a"
|
||||
let s:select = "614853"
|
||||
let s:window = "1f2126"
|
||||
let s:comment = "888984"
|
||||
let s:annotated_note = "aaaba6"
|
||||
let s:tab = "3d2a38"
|
||||
let s:error = "e40e0e"
|
||||
let s:proc = s:text
|
||||
let s:warn = "dcd53e"
|
||||
let s:spell = "aaf53e"
|
||||
let s:soft_red = "9a5d6e"
|
||||
let s:cursor_line = "2a2a2d"
|
||||
|
||||
" Vim
|
||||
call X("Normal", s:text, s:bg, "")
|
||||
call X("LineNr", s:comment, "", "")
|
||||
call X("NonText", s:text, "", "")
|
||||
call X("SpecialKey", s:blue, "", "")
|
||||
call X("Search", s:text, s:select, "")
|
||||
call X("TabLineSel", s:text, s:bg, "bold")
|
||||
call X("TabLine", "dddddd", s:tab, "none")
|
||||
call X("TabLineFill", "", s:tab, "none") " The tab line region that doesn't contain tab entries.
|
||||
call X("StatusLine", s:window, s:text, "reverse")
|
||||
call X("StatusLineNC", s:window, s:comment, "reverse")
|
||||
call X("VertSplit", s:window, s:window, "none")
|
||||
call X("Visual", "", s:select, "")
|
||||
call X("Directory", s:blue, "", "")
|
||||
call X("ModeMsg", s:green, "", "")
|
||||
call X("MoreMsg", s:green, "", "")
|
||||
call X("Question", s:green, "", "")
|
||||
call X("MatchParen", "", s:select, "")
|
||||
call X("Folded", s:comment, s:bg, "")
|
||||
call X("FoldColumn", s:comment, s:bg, "")
|
||||
call X("SpellBad", s:spell, s:bg, "bold")
|
||||
call X("SpellCap", s:text, s:bg, "") " A word that should start with a capital
|
||||
call X("SpellLocal", s:spell, s:bg, "bold") " Correctly spelled but used in another region.
|
||||
call X("SpellRare", s:text, s:bg, "") " A correctly spelled that is hardly ever used. Don't care about this.
|
||||
call X("ErrorMsg", s:error, s:bg, "bold")
|
||||
if version >= 700
|
||||
call X("PMenu", s:text, s:select, "none") " Autocompletion menu
|
||||
call X("PMenuSel", s:text, "926975", "bold") " Selected autocompletion item
|
||||
call X("SignColumn", "", s:bg, "none")
|
||||
call X("CursorLine", "", s:cursor_line, "none") " Horizontal line at the cursor.
|
||||
call X("CursorColumn", "", s:cursor_line, "none") " Vertical line at the cursor.
|
||||
end
|
||||
if version >= 703
|
||||
call X("ColorColumn", "", s:cursor_line, "none") " Vertical line set by colorcolumn option.
|
||||
end
|
||||
|
||||
" Standard Highlighting
|
||||
call X("Comment", s:comment, "", "")
|
||||
call X("Title", s:comment, "", "")
|
||||
call X("Cursor", "", s:text, "")
|
||||
call X("Identifier", s:soft_red, "", "none")
|
||||
call X("Statement", s:soft_red, "", "") " 'return', 'goto', 'case', 'break', etc
|
||||
call X("Conditional", s:soft_red, "", "")
|
||||
call X("Repeat", s:text, "", "") " 'for' and 'while'
|
||||
call X("Structure", s:soft_red, "", "") " enum, struct, union
|
||||
call X("Function", s:proc, "", "")
|
||||
call X("Constant", s:text, "", "") " Constants, e.g. SOME_CONST
|
||||
call X("Boolean", s:text, "", "") " true, false
|
||||
call X("String", "bba76a", "", "")
|
||||
call X("Special", s:text, "", "")
|
||||
call X("PreProc", s:text, "", "")
|
||||
call X("Operator", s:text, "", "none")
|
||||
call X("Type", s:text, "", "") " Data types
|
||||
call X("Define", s:text, "", "none")
|
||||
call X("Include", s:text, "", "") " #include in C/C++
|
||||
call X("Number", s:soft_red, "", "")
|
||||
|
||||
" Notes and annotated comment text
|
||||
call X("MyTitle", s:annotated_note, "", "bold") " // # Some Title
|
||||
call X("MyAnnotatedNote", s:annotated_note, "", "bold") " // @incomplete
|
||||
call X("MyNote", s:soft_red, "", "standout") " // NOTE:, IDEA:, TODO:
|
||||
call X("MyEmphasis", s:yellow, "", "bold") " // WARNING:, IMPORTANT:
|
||||
call X("MyBug", s:red, "", "standout") " // FIXME:, BUG:, DEPRECATED:
|
||||
|
||||
" Build markers
|
||||
call X("BuildError", s:error, s:bg, "bold")
|
||||
call X("BuildWarn", s:warn, s:bg, "bold")
|
||||
call X("BuildInfo", s:text, s:bg, "bold")
|
||||
|
||||
" Jai Highlighting
|
||||
call X("jaiVariableDeclaration", s:text, "", "")
|
||||
call X("jaiDirective", s:soft_red, "", "")
|
||||
|
||||
" airblade/vim-gitgutter
|
||||
call X("GitGutterAdd", s:green, "", "")
|
||||
call X("GitGutterDelete", s:red, "", "")
|
||||
call X("GitGutterChange", s:yellow, "", "")
|
||||
call X("GitGutterChangeDelete", s:orange, "", "")
|
||||
|
||||
" C Highlighting
|
||||
call X("cType", s:text, "", "")
|
||||
call X("cStorageClass", s:text, "", "")
|
||||
call X("cConditional", s:text, "", "")
|
||||
call X("cRepeat", s:text, "", "")
|
||||
|
||||
" Diff Highlighting
|
||||
call X("DiffAdd", s:window, s:green, "none")
|
||||
call X("DiffDelete", s:window, s:red, "none")
|
||||
call X("DiffChange", s:window, s:yellow, "none")
|
||||
call X("DiffText", s:bg, s:yellow, "none")
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
" The theme file original copied from the Tomorrow theme.
|
||||
" See https://github.com/chriskempson/vim-tomorrow-theme.git for it.
|
||||
" Hex color conversion functions borrowed from the theme "Desert256".
|
||||
"
|
||||
" @todo convert to new format (see campo-dark-blue.vim)
|
||||
|
||||
if has('termguicolors')
|
||||
" Supports 24-bit color range
|
||||
@@ -7,7 +7,8 @@
|
||||
" Hex color conversion functions borrowed from the theme "Desert256".
|
||||
|
||||
" @TODO port these colors over to a copy of campo-dark-greyscale so that I
|
||||
" have better control over the C syntax highlighting.
|
||||
" have better control over the C syntax highlighting. And use the improved
|
||||
" format used in campo-dark-blue.vim
|
||||
|
||||
|
||||
if has('termguicolors')
|
||||
@@ -3,6 +3,8 @@
|
||||
" Version: 1.0
|
||||
"
|
||||
" Hex color conversion functions borrowed from the theme "Desert256".
|
||||
"
|
||||
" @todo convert to new format (see campo-dark-blue.vim)
|
||||
|
||||
if has('termguicolors')
|
||||
" Supports 24-bit color range
|
||||
@@ -1,6 +1,7 @@
|
||||
" A very simple light colorscheme.
|
||||
" Maintainer: Michael Campagnaro <mikecampo@gmail.com>
|
||||
" Version: 1.0
|
||||
"
|
||||
|
||||
if has('termguicolors')
|
||||
" Supports 24-bit color range
|
||||
@@ -5,6 +5,8 @@
|
||||
" The theme file original copied from the Tomorrow theme.
|
||||
" See https://github.com/chriskempson/vim-tomorrow-theme.git for it.
|
||||
" Hex color conversion functions borrowed from the theme "Desert256".
|
||||
"
|
||||
" @todo convert to new format (see campo-dark-blue.vim)
|
||||
|
||||
let g:campo_theme_use_rainbow_parens = 1
|
||||
|
||||
@@ -13,7 +15,7 @@ let s:foreground = "263238"
|
||||
let s:background = "fbfbfb"
|
||||
let s:selection = "e3fc8d"
|
||||
let s:line = "d5d5d5"
|
||||
let s:comment = "7c7c7c"
|
||||
let s:comment = "4c4c4c"
|
||||
let s:red = "d62a28"
|
||||
let s:orange = "ff7800"
|
||||
let s:yellow = "eab700"
|
||||
@@ -294,13 +296,14 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
|
||||
call <SID>X("Number", s:black, "", "")
|
||||
"call <SID>X("Ignore", "666666", "", "")
|
||||
|
||||
" Custom TODO/NOTE colors
|
||||
call <SID>X("Todo", s:red, s:background, "underline")
|
||||
call <SID>X("Bugs", s:red, s:background, "standout")
|
||||
call <SID>X("Notes","666666", "ffffff","bold")
|
||||
call <SID>X("Notices","dcd53e",s:background,"bold")
|
||||
call <SID>X("ErrorMsg", s:error_msg_foreground, s:error_msg_background, "underline")
|
||||
" Notes and annotated comment text
|
||||
call <SID>X("MyTitle", s:foreground, "", "bold") " // # Some Title
|
||||
call <SID>X("MyAnnotatedNote", s:foreground, "", "bold") " // @incomplete
|
||||
call <SID>X("MyNote", "", s:black, "standout") " // NOTE:, IDEA:, TODO:
|
||||
call <SID>X("MyEmphasis", s:orange, "", "bold,standout") " // WARNING:, IMPORTANT:
|
||||
call <SID>X("MyBug", s:red, "", "standout") " // FIXME:, BUG:, DEPRECATED:
|
||||
|
||||
call <SID>X("ErrorMsg", s:error_msg_foreground, s:error_msg_background, "underline")
|
||||
|
||||
" Vim Highlighting
|
||||
call <SID>X("vimCommand", s:blue, "", "none")
|
||||
0
vim/scripts/scmindent.rkt → .vim/scripts/scmindent.rkt
Executable file → Normal file
0
vim/scripts/scmindent.rkt → .vim/scripts/scmindent.rkt
Executable file → Normal file
@@ -271,3 +271,7 @@ memcpy
|
||||
strlen
|
||||
u8
|
||||
s64
|
||||
Sculpey
|
||||
grey
|
||||
googly
|
||||
favour
|
||||
BIN
.vim/spell/en.utf-8.add.spl
Normal file
BIN
.vim/spell/en.utf-8.add.spl
Normal file
Binary file not shown.
1057
vimrc → .vimrc
1057
vimrc → .vimrc
File diff suppressed because it is too large
Load Diff
11
README.md
11
README.md
@@ -1,11 +0,0 @@
|
||||
# dotfiles
|
||||
|
||||
Various dotfiles and misc configs. Some of it is customized around my system setup
|
||||
(like aliases pointing to paths) but you should be able to easily remove that stuff.
|
||||
|
||||
## Installing
|
||||
|
||||
There is an `install` script that facilitates the setup, however it's been a while since I did a
|
||||
full system setup and this script may not be fully complete. An alternative method is to manually
|
||||
symlink files in the root directory. OS specific configs are in their respective folders.
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
error() {
|
||||
printf "${BOLD}${RED}$1${NORMAL}\n"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error "\nAborting...\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
bucket="$1"
|
||||
path="$2"
|
||||
output_file="$3"
|
||||
|
||||
if [[ $bucket == "" || $path == "" || $output_file == "" ]]; then
|
||||
error "Usage: aws-list-deep-glacier-files <bucket-name> <path-in-bucket> <output-file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
aws s3api list-objects-v2 --bucket $bucket --prefix $path --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text | LC_ALL=C awk '{print substr($0, index($0, $2))}' | awk '{NF-=3};3' > "$output_file"
|
||||
@@ -1,69 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Restores all files/folders inside a particular bucket path,
|
||||
# e.g. aws-restore-deep-glacier-folder mcampagnaro-deep-glacier images restored_images
|
||||
# will restore all files inside the images folder of the mcampagnaro-deep-glacier bucket, saving
|
||||
# temp restoration data in the local "restored_images" directory.
|
||||
#
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
error() {
|
||||
printf "${BOLD}${RED}$1${NORMAL}\n"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error "\nAborting...\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
bucket="$1"
|
||||
path="$2"
|
||||
temp_dir="$3"
|
||||
number_of_objects_per_file=100
|
||||
days_available=7
|
||||
restore_tier="Bulk" # Can also be "Standard"
|
||||
|
||||
if [[ $bucket == "" || $path == "" || $temp_dir == "" ]]; then
|
||||
error "Usage: aws-restore-deep-glacier-folder <bucket-name> <path-in-bucket> <local-temp-dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "${BOLD}Restoring ${GREEN}$bucket:$path${NORMAL}${BOLD} with local temp folder ${GREEN}$temp_dir${NORMAL}\n"
|
||||
|
||||
mkdir -p "$temp_dir"
|
||||
pushd "$temp_dir" &>/dev/null
|
||||
|
||||
aws s3api list-objects-v2 --bucket $bucket --prefix $path --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text | LC_ALL=C awk '{print substr($0, index($0, $2))}' | awk '{NF-=3};3' > all_objects_list.txt
|
||||
|
||||
# Generate the main script that will kick off the restoration.
|
||||
printf "while read x; do\n printf \"aws s3api restore-object --restore-request '{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}' --bucket $bucket --key \\\\\"\$x\\\\\"\\\\n\"\n aws s3api restore-object --restore-request \"{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}\" --bucket $bucket --key \"\$x\"\ndone < all_objects_list.txt\nprintf \"\\\\nDone! You can now delete this folder.\\\\n\"\n" > run.sh
|
||||
chmod +x run.sh
|
||||
|
||||
printf "${BOLD}You can now run ${GREEN}$temp_dir/run.sh${NORMAL}${BOLD} to start the restoration process.\n"
|
||||
|
||||
popd &>/dev/null
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is for reencoding an AVI video. I wasn't able to play the encoded videos
|
||||
# on my phone when using libx264 and libx265 encoders, but mpeg4 works. Also
|
||||
# I'm using the aac codec because some old avi's were using a codec that's not
|
||||
# supported in the mp4 container.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" || $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <bitrate, e.g. \"4000k\"> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
bitrate="$2"
|
||||
|
||||
output_name="$3"
|
||||
if [[ $output_name == "" ]]; then
|
||||
output="${filename}_CONVERTED-${bitrate}.mp4"
|
||||
else
|
||||
output="${output_name}.mp4"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' with target bitrate $bitrate | output: $output${NORMAL}\n"
|
||||
ffmpeg -i "$filename.$extension" -c:a aac -c:v mpeg4 -b:v $bitrate "$output"
|
||||
printf "\n${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output'${NORMAL}\n\n"
|
||||
@@ -1,64 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is for reencoding an FLV video to mp4 using an mpeg4 encoder.
|
||||
# Can optionally compress the video.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" || $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
compress="$1"
|
||||
|
||||
filename=$(basename -- "$2")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output="$3"
|
||||
if [[ $output == "" ]]; then
|
||||
output="${filename}_CONVERTED"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | compress: $compress | output: $output.mp4${NORMAL}\n"
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
temp_output="temp_$output.mp4"
|
||||
else
|
||||
temp_output="$output.mp4"
|
||||
fi
|
||||
|
||||
# convert first.
|
||||
# we convert then compress instead of compressing on first pass because this results in a slightly higher bitrate.
|
||||
ffmpeg -y -stats -loglevel level+error -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i "$filename.$extension" -c:a aac -c:v h264_nvenc -b:v 5M "$temp_output"
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
compress-video 1 "$temp_output" "$output"
|
||||
rm "$temp_output"
|
||||
else
|
||||
printf "\n"
|
||||
fi
|
||||
|
||||
printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output.mp4'${NORMAL}\n\n"
|
||||
@@ -1,64 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is for reencoding an mkv video to mp4 using an mpeg4 encoder.
|
||||
# Can optionally compress the video.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" || $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
compress="$1"
|
||||
|
||||
filename=$(basename -- "$2")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output="$3"
|
||||
if [[ $output == "" ]]; then
|
||||
output="${filename}_CONVERTED"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | compress: $compress | output: $output.mp4${NORMAL}\n"
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
temp_output="temp_$output.mp4"
|
||||
else
|
||||
temp_output="$output.mp4"
|
||||
fi
|
||||
|
||||
# convert first.
|
||||
# we convert then compress instead of compressing on first pass because this results in a slightly higher bitrate.
|
||||
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -vcodec copy -acodec copy "$temp_output"
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
compress-video 1 "$temp_output" "$output"
|
||||
rm "$temp_output"
|
||||
else
|
||||
printf "\n"
|
||||
fi
|
||||
|
||||
printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output.mp4'${NORMAL}\n\n"
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
transcode="$1"
|
||||
filename=$(basename -- "$2")
|
||||
format="$3"
|
||||
bitrate="$4"
|
||||
|
||||
if [[ $1 == "" || $2 == "" || $3 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <transcode? 0|1 (needed when container doesn't contain format)> <filename> <format (mp3, m4a, aac, etc)> <optional: bitrate. Uses 64k when not specified, 0 = variable (e.g. 0, 64, 128, etc)>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
output_name="$filename.$format"
|
||||
|
||||
if [[ $bitrate == "" ]]; then
|
||||
bitrate="64"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Extracting audio from '$filename.$extension' | bitrate: ${bitrate}k | output: $output_name${NORMAL}\n"
|
||||
|
||||
if [[ $transcode == "1" ]]; then
|
||||
# Transcode audio
|
||||
ffmpeg -i "$filename.$extension" -b:a ${bitrate}k -ac 2 -ar 44100 -map a "$output_name"
|
||||
else
|
||||
# Grab the audio stream from the video.
|
||||
ffmpeg -i "$filename.$extension" -vn -acodec copy "$output_name"
|
||||
fi
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done extracting audio from '$filename.$extension' | output name '$output_name'${NORMAL}\n\n"
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
@echo off
|
||||
|
||||
cd %DEV_TOOLS%\SysinternalsSuite
|
||||
if exist %1\* (
|
||||
echo Run on a file
|
||||
) else (
|
||||
if exist "%~1_Report.txt" (
|
||||
del "%~1_Report.txt"
|
||||
)
|
||||
sigcheck.exe /a "%~1" > "%~1_sigcheck_report.txt"
|
||||
start notepad "%~1_sigcheck_report.txt"
|
||||
)
|
||||
@@ -1,70 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Use this to normalize the audio of a video using the average loudness, or RMS-based normalization.
|
||||
# This does not re-encode the video.
|
||||
#
|
||||
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output_name="$2"
|
||||
|
||||
if [[ $output_name == "" ]]; then
|
||||
output="${filename}_normalized_audio.$extension"
|
||||
else
|
||||
output="${output_name}.$extension"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Normalizing audio in $filename.$extension | output: $output${NORMAL}\n"
|
||||
|
||||
# This is done in two passes. The first pass will compute the mean loudness and
|
||||
# the second pass will normalize the audio using the mean as the target.
|
||||
|
||||
# -vn, -sn, and -dn tells ffmpeg to ignore non-audio streams during the analysis. This speeds things up.
|
||||
ffmpeg -i "$filename.$extension" -af "volumedetect" -vn -sn -dn -f null /dev/null
|
||||
|
||||
#ffmpeg -i "$filename.$extension" -c:v copy -ac 1 "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done normalizing audio in $filename.$extension | output: $output${NORMAL}\n\n"
|
||||
|
||||
|
||||
|
||||
#---------------------------------------
|
||||
# This seems better. 2 pass using loudnorm filter.
|
||||
|
||||
# 1st pass: ffmpeg -i "$filename.$extension" -pass 1 -filter:a loudnorm=print_format=json -vn -sn -dn -f null /dev/null
|
||||
# 2nd pass: ffmpeg -i "$filename.$extension" -c:v copy -pass 2 -filter:a loudnorm=linear=true:measured_I=$input_i:measured_LRA=$input_lra:measured_tp=$input_tp:measured_thresh=$input_thresh "$output"
|
||||
|
||||
# TODO: extract the $input_i, input_lra, etc from the 1st pass output so that this can be automated.
|
||||
# TODO: stackoverflow said if there are subtitles or multiple vid streams then add "-map 0" before the output name. Test this.
|
||||
# TODO: disable the log file or just delete it after normalizing.
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
output_name="$2"
|
||||
start_time="$3"
|
||||
end_time="$4"
|
||||
|
||||
if [[ $filename == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
output="${output_name}.$extension"
|
||||
timing_args="-ss $start_time -to $end_time"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"
|
||||
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c:a copy -c:v copy "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
||||
|
||||
16
bin/vim-pull
16
bin/vim-pull
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copies vim data from the home directory to the dotfiles repo.
|
||||
|
||||
set -e
|
||||
|
||||
src="$HOME/.vim"
|
||||
dest="$HOME/.dotfiles/vim/"
|
||||
|
||||
if [ -d $src ]; then
|
||||
[ -d "$src/spell" ] && echo "Syncing user dictionary" && cp -r "$src/spell" $dest
|
||||
[ -d "$src/colors" ] && echo "Syncing user colors" && cp -r "$src/colors" $dest
|
||||
[ -d "$src/after" ] && echo "Syncing after directory" && cp -r "$src/after" $dest
|
||||
[ -d "$src/ftdetect" ] && echo "Syncing ftdetect" && cp -r "$src/ftdetect" $dest
|
||||
[ -d "$src/autoload" ] && echo "Syncing autoload" && cp -r "$src/autoload" $dest
|
||||
fi
|
||||
16
bin/vim-push
16
bin/vim-push
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copies vim data from the dotfiles repo to the home directory.
|
||||
|
||||
set -e
|
||||
|
||||
src="$HOME/.dotfiles/vim"
|
||||
dest="$HOME/.vim/"
|
||||
|
||||
if [ -d $src ]; then
|
||||
[ -d "$src/spell" ] && echo "Syncing user dictionary" && cp -r "$src/spell" $dest
|
||||
[ -d "$src/colors" ] && echo "Syncing user colors" && cp -r "$src/colors" $dest
|
||||
[ -d "$src/after" ] && echo "Syncing after directory" && cp -r "$src/after" $dest
|
||||
[ -d "$src/ftdetect" ] && echo "Syncing ftdetect" && cp -r "$src/ftdetect" $dest
|
||||
[ -d "$src/autoload" ] && echo "Syncing autoload" && cp -r "$src/autoload" $dest
|
||||
fi
|
||||
32
dotfiles/README.md
Normal file
32
dotfiles/README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# dotfiles
|
||||
|
||||
Various dotfiles and misc configs. Some of it is customized around my system
|
||||
setup (like aliases pointing to paths) but you should be able to easily remove
|
||||
that stuff.
|
||||
|
||||
This unpacks files one directory back, which is assumed to be your home
|
||||
directory. The gitignore ignores all files by default. If you want to add a new
|
||||
file this you need to add the `-f` flag to the git add command. This setup was
|
||||
inspired by Gary Bernhardt and https://gist.github.com/meleu/053275b6842646b95491bf1af4a6ca0e
|
||||
|
||||
## Installing
|
||||
|
||||
```bash
|
||||
# Go to your home directory.
|
||||
cd ~
|
||||
|
||||
# Clone the repo with the "--no-checkout" option (so we can checkout the files in our home directory)
|
||||
git clone --no-checkout <repo_url>/dotfiles.git
|
||||
|
||||
# Go to the created directory and change the worktree to the home direcory.
|
||||
cd dotfiles
|
||||
git config core.worktree '../../'
|
||||
|
||||
# Checkout the files. This will overwrite existing dotfiles with the same name.
|
||||
git reset --hard origin/master
|
||||
```
|
||||
|
||||
If you want to install optional OS specific stuff, like various packages, run the `install` script in this folder.
|
||||
|
||||
OS specific configs are in their respective folders.
|
||||
|
||||
58
dotfiles/bin/add-audio-to-video
Normal file
58
dotfiles/bin/add-audio-to-video
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Re-encodes the video with a new primary audio channel.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
vid_filename=$(basename -- "$1")
|
||||
audio_filename=$(basename -- "$2")
|
||||
output_name="$3"
|
||||
|
||||
if [[ $vid_filename == "" || $audio_filename == "" || $output_name == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: add-audio-to-video <video filename> <audio filename> <output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
vid_extension="${vid_filename##*.}"
|
||||
vid_filename="${vid_filename%.*}"
|
||||
|
||||
audio_extension="${audio_filename##*.}"
|
||||
audio_filename="${audio_filename%.*}"
|
||||
|
||||
output="${output_name}.$vid_extension"
|
||||
|
||||
audio_encoding_opts="-c:a copy"
|
||||
if [[ $audio_extension == "wav" ]]; then
|
||||
# Re-encode the audio.
|
||||
audio_encoding_opts="-c:a aac -b:a 192k"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Adding audio '$audio_filename.$audio_extension' to '$vid_filename.$vid_extension' | output: $output${NORMAL}\n"
|
||||
|
||||
# -shortest handles the inputs not being the same duration. Conversion will stop when the shortest input's end is reached.
|
||||
# Alternatively you can loop with "-stream_loop -1"
|
||||
ffmpeg -y -stats -loglevel level+error -i "$vid_filename.$vid_extension" -i "$audio_filename.$audio_extension" -c:v copy -map 0:v:0 -map 1:a:0 $audio_encoding_opts -shortest "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished adding audio${NORMAL}\n\n"
|
||||
|
||||
55
dotfiles/bin/analyze-volume
Normal file
55
dotfiles/bin/analyze-volume
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Use this to get a volume report from a video or audio file. You can use this
|
||||
# info manually normalize or increase/decrease the volume using the
|
||||
# change-volume script, supplying it the volume delta you want. Typically you
|
||||
# use the delta from the analysis report this script provides, e.g. if the
|
||||
# max_volume is -5 db then you would call change-volume with a value of 5. I
|
||||
# find that the two pass normalize-volume script works better than this
|
||||
# approach...but it will take longer to run!
|
||||
#
|
||||
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
|
||||
|
||||
source "$HOME/dotfiles/script_helpers/windows.sh"
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: analyze-volume <video or audio filename>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename="$1"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Analyzing audio in $filename${NORMAL}\n"
|
||||
|
||||
# -vn, -sn, and -dn tells ffmpeg to ignore non-audio streams during the analysis. This speeds things up.
|
||||
cmd="ffmpeg -i \"$filename\" -af volumedetect -vn -sn -dn -f null /dev/null"
|
||||
printf "\n${BOLD}Running: $cmd\n\n${NORMAL}"
|
||||
eval $cmd
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done analyzing audio in $filename\n${NORMAL}"
|
||||
printf "\n${YELLOW}${BOLD}Look at the reported max_volume value. If != 0 then call the change-volume script, passing it the filename, an output name and the delta to bring the volume to 0.\ne.g. if the max_volume is -5 db, then you would pass 5.${NORMAL}\n\n"
|
||||
|
||||
flash_taskbar
|
||||
@@ -1,23 +1,32 @@
|
||||
@setlocal enableextensions enabledelayedexpansion
|
||||
@echo off
|
||||
setlocal enableextensions enabledelayedexpansion
|
||||
|
||||
rem Make sure we're running as admin. Got this garbage from https://stackoverflow.com/a/40388766
|
||||
if not "%1"=="am_admin" (
|
||||
powershell -Command "Start-Process -Verb RunAs -FilePath '%0' -ArgumentList 'am_admin'"
|
||||
rem NOTE: Defender may see this file as malware, so you might need to exclude this before things can be disabled.
|
||||
|
||||
rem Modified version of:
|
||||
rem https://github.com/ggannann/win10_disable_defender
|
||||
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b (as of Jan 2026 this seems to have been deleted or made private)
|
||||
|
||||
rem ============================
|
||||
rem Self-elevate via UAC if needed
|
||||
rem - Detect admin by checking membership in Administrators (SID S-1-5-32-544)
|
||||
rem - Relaunch this script elevated using PowerShell Start-Process -Verb RunAs
|
||||
rem ============================
|
||||
rem Test for membership in Administrators group
|
||||
whoami /groups | find "S-1-5-32-544" >nul
|
||||
if errorlevel 1 (
|
||||
echo Requesting administrative privileges...
|
||||
rem Relaunch the same script elevated, preserving args and working directory
|
||||
powershell -NoProfile -Command ^
|
||||
"Start-Process -FilePath '%~f0' -ArgumentList '%*' -Verb RunAs -WorkingDirectory (Get-Location).Path"
|
||||
exit /b
|
||||
)
|
||||
|
||||
rem USE AT OWN RISK AS IS WITHOUT WARRANTY OF ANY KIND !!!!!
|
||||
rem NOTE: Defender may see this file as malware, so you will likely need to exclude this before things can be disabled.
|
||||
rem
|
||||
rem Modified version of
|
||||
rem https://raw.githubusercontent.com/mattreecebentley/win10_disable_defender/main/win10_enable_defender.bat
|
||||
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b
|
||||
echo Running with administrative privileges.
|
||||
echo.
|
||||
|
||||
reg query HKLM\SYSTEM\Setup /v DisabledDefenderServices | find "0x1"
|
||||
if %errorlevel% == 0 goto already_patched
|
||||
|
||||
echo.
|
||||
echo Please note that Defender can only be disabled in Win10 v2004 and upwards if Tamper Protection is disabled.
|
||||
echo This setting can be found in Window settings (hint: search for 'tamper'). Please do this now and then,
|
||||
pause
|
||||
@@ -94,7 +103,7 @@ reg add HKLM\SYSTEM\Setup /v DisabledDefenderServices /t REG_DWORD /d 1 /f
|
||||
|
||||
echo.
|
||||
echo Windows Defender has (hopefully) been disabled.
|
||||
echo You should still be able to scan files going forward. Also, the Antimalware Service Executable should immediately stop using CPU cycles.
|
||||
echo You might still be able to scan files going forward depending on your version of Windows. Also, the Antimalware Service Executable should immediately stop using CPU cycles.
|
||||
echo Please restart your computer to see all changes.
|
||||
|
||||
goto eof
|
||||
@@ -105,3 +114,4 @@ echo Defender has already been disabled by this script.
|
||||
:eof
|
||||
echo.
|
||||
pause
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
@setlocal enableextensions enabledelayedexpansion
|
||||
@echo off
|
||||
setlocal enableextensions enabledelayedexpansion
|
||||
|
||||
rem Make sure we're running as admin. Got this garbage from https://stackoverflow.com/a/40388766
|
||||
if not "%1"=="am_admin" (
|
||||
powershell -Command "Start-Process -Verb RunAs -FilePath '%0' -ArgumentList 'am_admin'"
|
||||
exit /b
|
||||
)
|
||||
rem NOTE: Defender may see this file as malware, so you might need to exclude this before things can be disabled.
|
||||
|
||||
rem USE AT OWN RISK AS IS WITHOUT WARRANTY OF ANY KIND !!!!!
|
||||
rem
|
||||
rem Modified version of
|
||||
rem https://raw.githubusercontent.com/mattreecebentley/win10_disable_defender/main/win10_enable_defender.bat
|
||||
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b
|
||||
rem Modified version of:
|
||||
rem https://github.com/ggannann/win10_disable_defender
|
||||
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b (as of Jan 2026 this seems to have been deleted or made private)
|
||||
rem
|
||||
rem Resources:
|
||||
rem https://docs.microsoft.com/en-us/powershell/module/defender/set-mppreference?view=win10-ps
|
||||
@@ -19,7 +13,23 @@ rem https://docs.microsoft.com/en-us/windows/threat-protection/windows-defender-
|
||||
rem https://github.com/AndyFul/ConfigureDefender
|
||||
rem https://github.com/AndyFul/Hard_Configurator
|
||||
|
||||
rem ============================
|
||||
rem Self-elevate via UAC if needed
|
||||
rem - Detect admin by checking membership in Administrators (SID S-1-5-32-544)
|
||||
rem - Relaunch this script elevated using PowerShell Start-Process -Verb RunAs
|
||||
rem ============================
|
||||
rem Test for membership in Administrators group
|
||||
whoami /groups | find "S-1-5-32-544" >nul
|
||||
if errorlevel 1 (
|
||||
echo Requesting administrative privileges...
|
||||
rem Relaunch the same script elevated, preserving args and working directory
|
||||
powershell -NoProfile -Command ^
|
||||
"Start-Process -FilePath '%~f0' -ArgumentList '%*' -Verb RunAs -WorkingDirectory (Get-Location).Path"
|
||||
exit /b
|
||||
)
|
||||
echo Running with administrative privileges.
|
||||
echo.
|
||||
|
||||
echo Enabling Windows Defender
|
||||
reg query HKLM\SYSTEM\Setup /v DisabledDefenderServices | find "0x0"
|
||||
if %errorlevel% == 0 goto already_patched
|
||||
@@ -106,3 +116,4 @@ echo Defender has already been enabled by this script.
|
||||
:eof
|
||||
echo.
|
||||
pause
|
||||
|
||||
72
dotfiles/bin/aws-check-restore-status
Normal file
72
dotfiles/bin/aws-check-restore-status
Normal file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Shows you the status of an object restore job.
|
||||
#
|
||||
# e.g. aws-check-restore-status my-deep-glacier-bucket object/path.png
|
||||
#
|
||||
# You know it's ready when ongoing-request is false and there's a date. If that field is null then the file isn't being restored.
|
||||
#
|
||||
# You'll need the aws cli tools. Download them from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
|
||||
#
|
||||
# If you see an error like along the lines of "'charmap' codec can't encode
|
||||
# character '\u200e' in position 42: character maps to <undefined>" then that
|
||||
# means a filename has a Unicode codepoint and the dumb aws Python code is
|
||||
# trying to read it using your system's locale, which is very likely not set to
|
||||
# use the Windows UTF-8 beta feature. This is an ongoing issue in this tool
|
||||
# that goes back to 2013!!! There's no way to fix it using environment
|
||||
# variables, at least nothing worked for me. The fix provided by the devs is
|
||||
# heavy handed: you change your system locale to use UTF-8... This has
|
||||
# consequences though like breaking legacy apps that don't have Unicode support
|
||||
# and I'm sure other weird things will happen, such as file corruption. Anyway,
|
||||
# if you're getting this charmap error then I suggest changing your system
|
||||
# locale, run this again, then switch back to your previous locale. If you
|
||||
# don't get the canonical file name then you won't be able to restore it.
|
||||
#
|
||||
# You can enable the UTF-8 locale with:
|
||||
#
|
||||
# win+r -> intl.cpl -> Administrative tab -> Change system locale -> Beta: Use Unicode UTF-8 box.
|
||||
#
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
error() {
|
||||
printf "${BOLD}${RED}$1${NORMAL}\n"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error "\nAborting...\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
bucket="$1"
|
||||
path="$2"
|
||||
|
||||
if [[ $bucket == "" || $path == "" ]]; then
|
||||
error "Usage: aws-check-restore-status <bucket-name> <path-in-bucket>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
aws s3api head-object --bucket $bucket --key "$path" --query "{Restore:Restore, StorageClass:StorageClass}" --output json
|
||||
86
dotfiles/bin/aws-list-deep-glacier-files
Normal file
86
dotfiles/bin/aws-list-deep-glacier-files
Normal file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Creates a file containing the names of all files in a specific bucket.
|
||||
#
|
||||
# e.g. aws-list-deep-glacier-files my-deep-glacier images image_list
|
||||
#
|
||||
# You'll need the aws cli tools. Download them from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
|
||||
#
|
||||
# If you see an error like along the lines of "'charmap' codec can't encode
|
||||
# character '\u200e' in position 42: character maps to <undefined>" then that
|
||||
# means a filename has a Unicode codepoint and the dumb aws Python code is
|
||||
# trying to read it using your system's locale, which is very likely not set to
|
||||
# use the Windows UTF-8 beta feature. This is an ongoing issue in this tool
|
||||
# that goes back to 2013!!! There's no way to fix it using environment
|
||||
# variables, at least nothing worked for me. The fix provided by the devs is
|
||||
# heavy handed: you change your system locale to use UTF-8... This has
|
||||
# consequences though like breaking legacy apps that don't have Unicode support
|
||||
# and I'm sure other weird things will happen, such as file corruption. Anyway,
|
||||
# if you're getting this charmap error then I suggest changing your system
|
||||
# locale, run this again, then switch back to your previous locale. If you
|
||||
# don't get the canonical file name then you won't be able to restore it.
|
||||
#
|
||||
# You can enable the UTF-8 locale with:
|
||||
#
|
||||
# win+r -> intl.cpl -> Administrative tab -> Change system locale -> Beta: Use Unicode UTF-8 box.
|
||||
#
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
error() {
|
||||
printf "${BOLD}${RED}$1${NORMAL}\n"
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
bucket="$1"
|
||||
path="$2"
|
||||
output_file="$3"
|
||||
|
||||
if [[ $bucket == "" || $path == "" || $output_file == "" ]]; then
|
||||
error "Usage: aws-list-deep-glacier-files <bucket-name> <path-in-bucket> <output-file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# .Key gives us just the object paths. If you want the other metadata then remove that from the query.
|
||||
|
||||
items="$(aws s3api list-objects-v2 --bucket $bucket --prefix "$path" --query "Contents[?StorageClass=='DEEP_ARCHIVE'].Key" --output text | tr '\t' '\n' | tr -d '\r')"
|
||||
|
||||
error=$?
|
||||
if [[ ! $error -eq 0 ]]; then
|
||||
error "Error: failed to run the aws command. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
if [[ $items == "None" ]]; then
|
||||
error "Didn't find any files. Check that your bucket name and path is correct."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mapfile -t lines_array <<< "$items"
|
||||
item_count="${#lines_array[@]}"
|
||||
|
||||
echo "$items" > "$output_file"
|
||||
|
||||
printf "Number of items: ${BOLD}${YELLOW}$item_count${NORMAL}\n"
|
||||
printf "Wrote file list to ${BOLD}${YELLOW}$output_file${NORMAL}\n"
|
||||
331
dotfiles/bin/aws-restore-deep-glacier-folder
Normal file
331
dotfiles/bin/aws-restore-deep-glacier-folder
Normal file
@@ -0,0 +1,331 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Restores all objects recursively from a specific bucket path. If want to
|
||||
# restore objects from an rclone crypt (encrypted remote), then you'll need to
|
||||
# do some manual steps first. See the `# Rclone Crypt` section for details.
|
||||
#
|
||||
# You can set how long restore files are available for download and the AWS
|
||||
# retrieval tier. The defaults are 7 days and the bulk tier respectively.
|
||||
#
|
||||
# Available tiers: bulk, standard, and expedited.
|
||||
#
|
||||
# Bulk retrievals are the lowest-cost retrieval option when restoring objects
|
||||
# from S3 Glacier Deep Archive. They typically finish within 48 hours for
|
||||
# objects stored in the S3 Glacier Deep Archive storage class or S3
|
||||
# Intelligent-Tiering Deep Archive tier.
|
||||
#
|
||||
# If you need faster access then use the `expedited` or `standard` tiers.
|
||||
#
|
||||
# Example usage:
|
||||
#
|
||||
# aws-restore-deep-glacier-folder my-deep-glacier-bucket path/to/images restored_images 14 expedited
|
||||
#
|
||||
# This will create a run.sh script in a folder called "restored_images". Run
|
||||
# that to restore all files inside the `path/to/images` folder from the
|
||||
# my-deep-glacier bucket. Restored objects will be available for 14 days and
|
||||
# retrieved using the expedited tier.
|
||||
#
|
||||
# After you run the generated script, you have to wait for AWS to make the
|
||||
# files available for download. You can check the status of a file with:
|
||||
#
|
||||
# aws s3api head-object --bucket my-deep-glacier-bucket --key "path/to/images/photo1.jpg" --query "{Restore:Restore, StorageClass:StorageClass}"
|
||||
#
|
||||
# (obviously change the bucket and path to suit your needs).
|
||||
#
|
||||
# Or use the aws-check-restore-status script.
|
||||
# You know it's ready when ongoing-request is false and there's a date. If that
|
||||
# field is null then the file isn't being restored.
|
||||
#
|
||||
# Once the files are restored you can download them on the S3 website or better
|
||||
# yet use RcloneBrowser. I'm sure there's also a way to do it over cli too, I
|
||||
# just haven't checked.
|
||||
#
|
||||
# You'll need the aws cli tools for this script. Download them from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
|
||||
# Once installed, open a new shell and verify that you can run the `aws` command.
|
||||
#
|
||||
# If you see an error like along the lines of "'charmap' codec can't encode
|
||||
# character '\u200e' in position 42: character maps to <undefined>" then that
|
||||
# means a filename has a Unicode codepoint and the dumb aws Python code is
|
||||
# trying to read it using your system's locale, which is very likely not set to
|
||||
# use the Windows UTF-8 beta feature. This is an ongoing issue in this tool
|
||||
# that goes back to 2013!!! There's no way to fix it using environment
|
||||
# variables, at least nothing worked for me. The fix provided by the devs is
|
||||
# heavy handed: you change your system locale to use UTF-8... This has
|
||||
# consequences though like breaking legacy apps that don't have Unicode support
|
||||
# and I'm sure other weird things will happen, such as file corruption. Anyway,
|
||||
# if you're getting this charmap error then I suggest changing your system
|
||||
# locale, run this again, then switch back to your previous locale. If you
|
||||
# don't get the canonical file name then you won't be able to restore it.
|
||||
#
|
||||
# You can enable the UTF-8 locale with:
|
||||
#
|
||||
# win+r -> intl.cpl -> Administrative tab -> Change system locale -> Beta: Use Unicode UTF-8 box.
|
||||
|
||||
##########################
|
||||
# Rclone Crypt
|
||||
##########################
|
||||
#
|
||||
# To restore an rclone crypt, you need to first find the encrypted name that
|
||||
# maps to the parent folder or the file you want to restore. To do this you
|
||||
# need to use rclone. There are two ways to go about this.
|
||||
#
|
||||
# 1. The simple way is to use `cryptdecode` to convert your object path to its
|
||||
# encrypted form.
|
||||
#
|
||||
# For example, say you have an rclone crypt called `s3-deep-glacier-encrypted`
|
||||
# that is stored in S3 at `my-deep-glacier-bucket:encrypted/` You have a folder
|
||||
# called `dev/fonts` that you want to restore. To get its path, run the following
|
||||
# command:
|
||||
#
|
||||
# rclone cryptdecode --reverse s3-deep-glacier-encrypted: dev/fonts
|
||||
#
|
||||
# This will give you the encrypted path, e.g. "44ildo3grlk44jmfr96nb5r56o/oatuh75ej3l4re96nvq2qbj8ik"
|
||||
#
|
||||
# You can now restore this by running:
|
||||
#
|
||||
# aws-restore-deep-glacier-folder my-deep-glacier-bucket 44ildo3grlk44jmfr96nb5r56o/oatuh75ej3l4re96nvq2qbj8ik restore_dev_fonts
|
||||
#
|
||||
# You should be able to simply download the dev/fonts folder after its
|
||||
# restored. The easiest way is using rclone browser because it'll decrypt them
|
||||
# for you. Alternatively you can download the encrypted files using whatever
|
||||
# method you want and then decrypt them locally with rclone.
|
||||
#
|
||||
# 2. You can also get the encrypted names by enabling the 'show_mapping' option
|
||||
# in the rclone remote config. This will log the encrytped names of folders and
|
||||
# files with the original name in the same log line. This makes it easy to
|
||||
# parse the output.
|
||||
#
|
||||
# To enable the option, edit your rclone config, edit the remote you want to
|
||||
# restore from, edit the advanced config and set `show_mapping` to true.
|
||||
#
|
||||
# Now you can list the directories and files with rclone and get the mapping
|
||||
# output on stderr. e.g. let's capture all folders and files in a txt file:
|
||||
#
|
||||
# rclone lsf s3-deep-glacier-encrypted: -R &> keys.txt
|
||||
#
|
||||
# If your rclone config has password protection then you'll be prompted for it
|
||||
# but won't see the output since it's being written to the file. Just paste it
|
||||
# and hit enter.
|
||||
#
|
||||
# Now you have a listing of all objects and the encrypted keys that they map
|
||||
# to. If you want to scope the output to a specific path in the crypt then add
|
||||
# it after the remote name, e.g. `s3-deep-glacier-encrypted:dev/fonts`
|
||||
#
|
||||
# If you scope it like that then be aware that the output won't contain the
|
||||
# mapping for the parent path, i.e. `dev/fonts`, but you can get that using
|
||||
# `cryptdecode` (see above) or with some non-recursive outputs of the parent
|
||||
# parts using `lsd`, e.g.
|
||||
#
|
||||
# // First call will include the dev/ key
|
||||
# rclone lsd s3-deep-glacier-encrypted:
|
||||
#
|
||||
# // Second call has the fonts key
|
||||
# rclone lsd s3-deep-glacier-encrypted:dev
|
||||
#
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
error() {
|
||||
printf "${BOLD}${RED}$1${NORMAL}\n"
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
bucket="$1"
|
||||
path="$2"
|
||||
temp_dir="$3"
|
||||
days_available=7
|
||||
restore_tier="bulk" # Can also be "standard" or "expedited"
|
||||
|
||||
if [[ $bucket == "" || $path == "" || $temp_dir == "" ]]; then
|
||||
error "Usage: aws-restore-deep-glacier-folder <bucket-name> <path-in-bucket> <local-temp-dir> <optional: days available> <optional: restore tier>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the days available.
|
||||
if [[ $4 != "" ]]; then
|
||||
days_available=$4
|
||||
fi
|
||||
|
||||
# Get the restore tier.
|
||||
if [[ $5 != "" ]]; then
|
||||
restore_tier="$5"
|
||||
fi
|
||||
if ! grep -qiE '\b(bulk|standard|expedited)\b' <<<"$restore_tier"; then
|
||||
error "Restore tier is invalid. Accepted values is \"bulk\", \"standard\" and \"expedited\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Normalize the tier; lowercase it then capitalize the first character.
|
||||
restore_tier="${restore_tier,,}"
|
||||
restore_tier="${restore_tier^}"
|
||||
|
||||
printf "Restoring ${BOLD}${YELLOW}$bucket:$path${NORMAL} for ${BOLD}${YELLOW}$days_available${NORMAL} days using the ${BOLD}${YELLOW}\"$restore_tier\"${NORMAL} restore tier.\nSaving the restoration script in ${BOLD}${YELLOW}$temp_dir${NORMAL}\n"
|
||||
|
||||
mkdir -p "$temp_dir"
|
||||
pushd "$temp_dir" &>/dev/null
|
||||
|
||||
# .Key gives us just the object paths. If you want the other metadata then remove that from the query.
|
||||
items="$(aws s3api list-objects-v2 --bucket $bucket --prefix "$path" --query "Contents[?StorageClass=='DEEP_ARCHIVE'].Key" --output text | tr '\t' '\n' | tr -d '\r')"
|
||||
|
||||
error=$?
|
||||
if [[ ! $error -eq 0 ]]; then
|
||||
error "Error: failed to run the aws command. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
if [[ $items == "None" ]]; then
|
||||
error "Didn't find any files. Check that your bucket name and path is correct."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mapfile -t lines_array <<< "$items"
|
||||
item_count="${#lines_array[@]}"
|
||||
|
||||
# Generate the main script that will kick off the restoration.
|
||||
printf "Number of items to restore: ${BOLD}${YELLOW}$item_count${NORMAL}\n"
|
||||
printf "${BOLD}${RED}Create the restore script?\n> ${NORMAL}"
|
||||
|
||||
read -e proceed
|
||||
if [[ $proceed == "1" || $proceed == "y" || $proceed == "Y" || $proceed == "yes" || $proceed == "YES" ]]; then
|
||||
echo "$items" > all_objects_list.txt
|
||||
|
||||
RUN_TEMPLATE=$(cat <<EOF
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=\$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "\$ncolors" ] && [ "\$ncolors" -ge 8 ]; then
|
||||
RED="\$(tput setaf 1)"
|
||||
GREEN="\$(tput setaf 2)"
|
||||
YELLOW="\$(tput setaf 3)"
|
||||
BLUE="\$(tput setaf 4)"
|
||||
MAGENTA="\$(tput setaf 5)"
|
||||
CYAN="\$(tput setaf 6)"
|
||||
BOLD="\$(tput bold)"
|
||||
NORMAL="\$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
# Open an output file.
|
||||
exec 3>>output.txt
|
||||
|
||||
fail_count=0
|
||||
failed_filename="failed_keys_\$(printf '%%04x' \$((RANDOM * RANDOM))).txt"
|
||||
|
||||
before_sleep_count=0
|
||||
sleep_every_n_requests=25
|
||||
sleep_duration=0.2
|
||||
|
||||
printf "Files are being restored for $days_available days using the $restore_tier tier\\\n\\\n"
|
||||
printf "Files are being restored for $days_available days using the $restore_tier tier\\\n\\\n" >&3
|
||||
|
||||
printf "\${BOLD}NOTE: Request failures will be saved to \${YELLOW}\$failed_filename\${NORMAL}\${BOLD} as they happen. If this script terminates prematurely then check this file for failures.\\\n\\\n"
|
||||
printf "NOTE: Request failures will be saved to \$failed_filename as they happen. If this script terminates prematurely then check this file for failures.\\\n\\\n" >&3
|
||||
|
||||
index=1
|
||||
while read key; do
|
||||
printf "* [\$index/$item_count] \${BOLD}\$key\${NORMAL}\\\n"
|
||||
printf "* [\$index/$item_count] \$key\\\n" >&3
|
||||
err=\$(
|
||||
aws s3api restore-object \\
|
||||
--bucket mcampagnaro-deep-glacier \\
|
||||
--key \\"\$key\\" \\
|
||||
--restore-request '{\\"Days\\":$days_available,\\"GlacierJobParameters\\":{\\"Tier\\":\\"$restore_tier\\"}}' \\
|
||||
2>&1 >/dev/null
|
||||
)
|
||||
index=\$((index + 1))
|
||||
before_sleep_count=\$((before_sleep_count + 1))
|
||||
|
||||
# strip newlines
|
||||
err="\${err//[$'\\\t\\\r\\\n']}"
|
||||
|
||||
if [[ \$err != "" ]]; then
|
||||
if ! grep -qE 'RestoreAlreadyInProgress|ObjectAlreadyInActiveTierError' <<<"\$err"; then
|
||||
printf "\${BOLD}\${RED}FAILED! \$err\${NORMAL}"
|
||||
printf "FAILED! \$err\" >&3
|
||||
|
||||
# Save the failure to a file now in case the script exits prematurely.
|
||||
fail_count=\$((fail_count + 1))
|
||||
printf "%%s\\\n" "\$key" >> \$failed_filename
|
||||
else
|
||||
if grep -qE 'RestoreAlreadyInProgress' <<<"\$err"; then
|
||||
printf "\${BOLD}\${YELLOW}SKIPPING! File restore is already in progress.\${NORMAL}"
|
||||
printf "SKIPPING! File restore is already in progress." >&3
|
||||
else
|
||||
printf "\${BOLD}\${YELLOW}SKIPPING! File is already restored. You can now download it.\${NORMAL}"
|
||||
printf "SKIPPING! File is already restored. You can now download it." >&3
|
||||
fi
|
||||
fi
|
||||
else
|
||||
printf "\${BOLD}\${GREEN}SUCCESS!\${NORMAL}"
|
||||
printf "SUCCESS!" >&3
|
||||
fi
|
||||
printf "\\\n\\\n"
|
||||
printf "\\\n\\\n" >&3
|
||||
|
||||
if [[ \$before_sleep_count -eq sleep_every_n_requests ]]; then
|
||||
printf "SLEEPING...\\\n\\\n"
|
||||
printf "SLEEPING...\\\n\\\n" >&3
|
||||
sleep \$sleep_duration
|
||||
before_sleep_count=0
|
||||
fi
|
||||
|
||||
done < all_objects_list.txt
|
||||
|
||||
printf "\${BOLD}\${GREEN}Done!\${NORMAL}\\\n\\\n"
|
||||
printf "Done!\\\n\\\n" >&3
|
||||
|
||||
if [[ \$fail_count > 0 ]]; then
|
||||
printf "\${BOLD}\${RED}There were \$fail_count failures!\\\nSee \${NORMAL}\${BOLD}\$filename\${RED} for the list. You can replace the contents of \${NORMAL}\${BOLD}all_objects_list.txt\${RED} with the list of failures and re-run this script to process them.\${NORMAL}\\\n\\\n"
|
||||
printf "There were \$fail_count failures!\\\nSee \$filename for the list. You can replace the contents of all_objects_list.txt with the list of failures and re-run this script to process them.\\\n\\\n" >&3
|
||||
else
|
||||
printf "There were no failures. All the files are being restored. You can now delete this folder.\\\n\\\n"
|
||||
printf "There were no failures. All the files are being restored. You can now delete this folder.\\\n\\\n" >&3
|
||||
fi
|
||||
|
||||
printf "(Note: the time it takes to restore an object can be found in the AWS docs - just look for the $restore_tier restore tier, which is what you used.\\\nOnce restored, download the files from the S3 site or better yet use RCloneBrowser.\\\n"
|
||||
printf "You can check the status of a file using the aws-check-restore-status script)\\\n"
|
||||
|
||||
exec 3>&-
|
||||
|
||||
EOF
|
||||
)
|
||||
|
||||
printf "$RUN_TEMPLATE" > run.sh
|
||||
|
||||
chmod +x run.sh
|
||||
|
||||
printf "${BOLD}You can now run ${GREEN}$temp_dir/run.sh${NORMAL}${BOLD} to start the restoration process.\n"
|
||||
else
|
||||
echo Aborting.
|
||||
fi
|
||||
|
||||
popd &>/dev/null
|
||||
62
dotfiles/bin/change-volume
Normal file
62
dotfiles/bin/change-volume
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Re-encodes the audio, modify the volume based on the supplied db delta. If
|
||||
# given a video file then the file is copied as-is. If you want to bring the
|
||||
# max_volume to 0 db then call analyze-volume prior to this and pass a delta
|
||||
# based on the reported max_volume.
|
||||
#
|
||||
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
|
||||
|
||||
source "$HOME/dotfiles/script_helpers/windows.sh"
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: change-volume <video or audio filename> <output name> <volume delta in db>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output_name="$2"
|
||||
delta_db="$3"
|
||||
|
||||
if [[ $output_name == "" ]]; then
|
||||
output="${filename}_normalized_audio.$extension"
|
||||
else
|
||||
output="${output_name}.$extension"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Modifying audio volume in $filename.$extension | output: $output | delta: $delta_db${NORMAL}\n"
|
||||
|
||||
# Since we're re-encoding the audio we have to specify a codec to use.
|
||||
cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -af \"volume=${delta_db}dB\" -c:v copy -c:a aac \"$output\""
|
||||
printf "\n${BOLD}Running: $cmd\n\n${NORMAL}"
|
||||
eval $cmd
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done modifying volume in $filename.$extension | output: $output | delta: $delta_db${NORMAL}\n"
|
||||
|
||||
flash_taskbar
|
||||
@@ -1,5 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Bigger crf values == bigger compression.
|
||||
|
||||
source "$HOME/dotfiles/script_helpers/windows.sh"
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
@@ -23,10 +27,13 @@ else
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
use_gpu=0
|
||||
use_gpu=1
|
||||
# Found the following to work best with vids containing text (e.g. programming vids). These give similar bitrates.
|
||||
cpu_crf=20
|
||||
gpu_crf=33
|
||||
|
||||
if [[ $# < 2 || $# > 3 ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> ${NORMAL}\n"
|
||||
if [[ $# < 2 || $# > 5 ]]; then
|
||||
printf "${BOLD}${RED}Usage: compress-video <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS> (NOTE: gpu crf is $gpu_crf and cpu crf is $cpu_crf - change it by calling compress-video-with-crf)${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -37,11 +44,12 @@ if [[ $# > 2 ]]; then
|
||||
use_gpu=$3
|
||||
fi
|
||||
|
||||
# Found the following to work best with vids containing text (e.g. programming vid): 25 for CPU encoding and 27 for GPU.
|
||||
use_crf=21
|
||||
use_crf=$cpu_crf
|
||||
if [[ $use_gpu -eq 1 ]]; then
|
||||
use_crf=25
|
||||
use_crf=$gpu_crf
|
||||
fi
|
||||
|
||||
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu
|
||||
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu $4 $5
|
||||
|
||||
flash_taskbar
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Bigger crf values == bigger compression.
|
||||
|
||||
source "$HOME/dotfiles/script_helpers/windows.sh"
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
@@ -23,10 +27,10 @@ else
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
use_gpu=0
|
||||
use_gpu=1
|
||||
|
||||
if [[ "$#" < 3 || "$#" > 6 ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <crf value> <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS>\n\nIf you want to encode a range of CRF values then use -1 as the crf value.${NORMAL}\n"
|
||||
printf "${BOLD}${RED}Usage: compress-video-with-crf <crf value> <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS>\n\nIf you want to encode a range of CRF values then use -1 as the crf value.${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -65,21 +69,25 @@ function encode() {
|
||||
fi
|
||||
|
||||
if [[ $use_gpu -eq 1 ]]; then
|
||||
# File will be slightly larger than CPU encoding, but it's much faster to transcode and doesn't max out the CPU cores.
|
||||
|
||||
# RTX 3080
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i "$filename.$extension" -c:a copy -c:v h264_nvenc -profile:v high -rc:v vbr_hq -cq:v $crf -b:v 5M -maxrate 5M -max_muxing_queue_size 9999 "$output"
|
||||
# vbr_hq is smaller file and less bitrate than vbr - strange!
|
||||
ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda $timing_args -accurate_seek -i "$filename.$extension" -c:v h264_nvenc -profile:v high -preset 3 -rc:v vbr -cq:v $crf -c:a copy -max_muxing_queue_size 9999 -movflags +faststart "$output"
|
||||
|
||||
# GTX 1070
|
||||
#ffmpeg -y -stats -loglevel level+error $timing_args -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i "$filename.$extension" -c:a copy -c:v h264_nvenc -profile:v high -rc:v vbr_hq -cq:v $crf -b:v 5M -maxrate 5M -max_muxing_queue_size 9999 "$output"
|
||||
# capped bitrate w/ crf is weird. gives a more compressed copy
|
||||
# ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda $timing_args -accurate_seek -i "$filename.$extension" -c:v h264_nvenc -profile:v high -preset 3 -cq:v $crf -b:v 1200K -maxrate:v 1200K -bufsize:v 2400K -c:a copy -max_muxing_queue_size 9999 -movflags +faststart "$output"
|
||||
else
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c:v libx264 -crf $crf -preset veryfast -profile:v high -level 3.0 -strict -2 "$output"
|
||||
fi
|
||||
printf "\n${GREEN}${BOLD}Finished encoding '$filename.$extension' (CRF $crf) | output name '$output'${NORMAL}\n\n"
|
||||
|
||||
original_size=$(wc -c <"$filename.$extension")
|
||||
new_size=$(wc -c <"$output")
|
||||
printf "${BOLD}Original size: $original_size${NORMAL}\n"
|
||||
printf "${BOLD}New size: $new_size${NORMAL}\n\n"
|
||||
}
|
||||
|
||||
if [[ $use_crf -ne -1 ]]; then
|
||||
encode $use_crf
|
||||
time encode $use_crf
|
||||
else
|
||||
printf "\n${YELLOW}${BOLD}Encoding using a range of CRF values.${NORMAL}\n"
|
||||
|
||||
@@ -89,3 +97,5 @@ else
|
||||
encode $crf
|
||||
done
|
||||
fi
|
||||
|
||||
flash_taskbar
|
||||
100
dotfiles/bin/convert-video-to-mp4
Normal file
100
dotfiles/bin/convert-video-to-mp4
Normal file
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is for reencoding a non-mp4 video to mp4 using an mpeg4 encoder.
|
||||
# Can optionally compress the video.
|
||||
|
||||
source "$HOME/dotfiles/script_helpers/windows.sh"
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
compress="$1"
|
||||
filename="$2"
|
||||
output_name="$3"
|
||||
bitrate="$4"
|
||||
|
||||
if [[ $compress == "" || $filename == "" || $output_name == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: convert-video-to-mp4 <compress 1|0> <filename> <output name> <optional: bitrate, e.g. \"4000k\", defaults to source>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
filename=$(basename -- "$filename")
|
||||
extension="${filename##*.}"
|
||||
extension="${extension,,}" # go lower-case
|
||||
filename="${filename%.*}"
|
||||
|
||||
output="$output_name.mp4"
|
||||
|
||||
bitrate_args=""
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
temp_output="temp_$output"
|
||||
else
|
||||
temp_output="$output"
|
||||
fi
|
||||
|
||||
# convert first.
|
||||
# we convert then compress instead of compressing on first pass because this results in a slightly higher bitrate.
|
||||
|
||||
cmd=""
|
||||
|
||||
if [[ $extension == "mkv" || $extension == "mpg" || $extension == "mov" ]]; then
|
||||
if [[ $bitrate != "" ]]; then
|
||||
bitrate_args="-b:v $bitrate"
|
||||
else
|
||||
bitrate="<source value>"
|
||||
fi
|
||||
|
||||
cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -vcodec copy -acodec copy $bitrate_args \"$temp_output\""
|
||||
|
||||
elif [[ $extension == "flv" ]]; then
|
||||
if [[ $bitrate == "" ]]; then
|
||||
bitrate="5M"
|
||||
fi
|
||||
bitrate_args="-b:v $bitrate"
|
||||
|
||||
cmd="ffmpeg -y -stats -loglevel level+error -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i \"$filename.$extension\" -c:a aac -c:v h264_nvenc $bitrate_args \"$temp_output\""
|
||||
|
||||
elif [[ $extension == "avi" || $extension == "wmv" ]]; then
|
||||
cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -c:a aac -c:v mpeg4 $bitrate_args \"$output\""
|
||||
|
||||
else
|
||||
printf "${BOLD}${RED}Don't know how to convert a '$extension' to mp4. Add support!${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | compress: $compress | output: $output | bitrate: $bitrate${NORMAL}\n"
|
||||
|
||||
eval "$cmd"
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
compress-video 1 "$temp_output" "$output"
|
||||
rm "$temp_output"
|
||||
else
|
||||
printf "\n"
|
||||
fi
|
||||
|
||||
printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output'${NORMAL}\n\n"
|
||||
|
||||
flash_taskbar
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Use this to fix the audio of a video that has audio in only the left or right
|
||||
# channel. This does not re-encode the video.
|
||||
# Use this to copy audio from the left channel to the right. This does not re-encode the video.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
@@ -27,7 +26,7 @@ else
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
||||
printf "${BOLD}${RED}Usage: copy-left-audio-channel-to-right <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -43,9 +42,9 @@ else
|
||||
output="${output_name}.$extension"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Repairing audio in $filename.$extension | output: $output${NORMAL}\n"
|
||||
printf "\n${YELLOW}${BOLD}Copy left audio channeel to right channel in $filename.$extension | output: $output${NORMAL}\n"
|
||||
|
||||
ffmpeg -i "$filename.$extension" -c:v copy -ac 1 "$output"
|
||||
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -af "pan=stereo|c0=c0|c1=c0" -map 0 "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done repairing audio in $filename.$extension | output: $output${NORMAL}\n\n"
|
||||
printf "\n${GREEN}${BOLD}Done copying left audio channel to right channel in $filename.$extension | output: $output${NORMAL}\n\n"
|
||||
|
||||
50
dotfiles/bin/copy-right-audio-channel-to-left
Normal file
50
dotfiles/bin/copy-right-audio-channel-to-left
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Use this to copy audio from the right channel to the left. This does not re-encode the video.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: copy-right-audio-channel-to-left <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output_name="$2"
|
||||
|
||||
if [[ $output_name == "" ]]; then
|
||||
output="${filename}_repaired_audio.$extension"
|
||||
else
|
||||
output="${output_name}.$extension"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Copy right audio channeel to left channel in $filename.$extension | output: $output${NORMAL}\n"
|
||||
|
||||
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -af "pan=stereo|c0=c1|c1=c1" -map 0 "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done copying right audio channel to left channel in $filename.$extension | output: $output${NORMAL}\n\n"
|
||||
|
||||
45
dotfiles/bin/create-gif-from-video
Normal file
45
dotfiles/bin/create-gif-from-video
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
output_name="$2"
|
||||
width="$3"
|
||||
|
||||
if [[ $filename == "" || $output_name == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: create-gif-from-video <filename> <output name> <optional width, defaults to 240>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
output="${output_name}.gif"
|
||||
if [[ $width == "" ]]; then
|
||||
width=240
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Creating a gif from '$filename' | output: $output | width: $width${NORMAL}\n"
|
||||
|
||||
ffmpeg -y -stats -loglevel level+error -i "$filename" -vf "fps=24,scale=$width:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished!${NORMAL}\n\n"
|
||||
|
||||
63
dotfiles/bin/embed-subtitles
Normal file
63
dotfiles/bin/embed-subtitles
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Adds subtitles to a video. You can pass multiple srt files in one go. This
|
||||
# preserves all existing streams, so if you've already added subtitle tracks to
|
||||
# the video then these new ones will be appended. I haven't extensively tested
|
||||
# appending yet (not sure if the mapping arg is correct), so I recommend adding
|
||||
# all of your tracks in one go.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output_name="$2"
|
||||
output="${output_name}.$extension"
|
||||
|
||||
shift 2
|
||||
subtitles=("$@")
|
||||
|
||||
if [[ $filename == "" || $output_name == "" || ${#subtitles[@]} -eq 0 ]]; then
|
||||
printf "${BOLD}${RED}Usage: embed-subtitles <video filename> <output name> <subtitle filenames>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Adding subtitles to $filename.$extension | output: $output${NORMAL}\n"
|
||||
|
||||
mapping="-map 0"
|
||||
tracks=""
|
||||
|
||||
map_index=1
|
||||
for track in "$@"; do
|
||||
tracks+="-i \"$track\" "
|
||||
mapping+=" -map $map_index"
|
||||
map_index=$((map_index+1))
|
||||
done
|
||||
|
||||
cmd="ffmpeg -i \"$filename.$extension\" $tracks $mapping -c copy -c:s mov_text \"$output\""
|
||||
printf "\n${BOLD}Running: $cmd\n\n${NORMAL}"
|
||||
eval $cmd
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done adding subtitles to $filename.$extension | output: $output\n${NORMAL}"
|
||||
66
dotfiles/bin/extract-audio-from-video
Normal file
66
dotfiles/bin/extract-audio-from-video
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Extracts audio from a video. It expects you to know what audio codecs the
|
||||
# video container has, e.g. it's an mp4 video with aac and m4a audio. Just set
|
||||
# the format to the appropriate extension.
|
||||
#
|
||||
# If you want to convert to a different format or you want to change the sample
|
||||
# rate, channel count, trim the audio, etc. then use transcode-audio.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
format="$2"
|
||||
start_time="$3"
|
||||
end_time="$4"
|
||||
|
||||
if [[ $1 == "" || $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: extract-audio-from-video <filename> <format (mp3, m4a, aac, etc)> <optional: start time HH:MM:SS, use empty string or 0 for start> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
output_name="$filename.$format"
|
||||
|
||||
timing_args=""
|
||||
if [[ $start_time != "" ]]; then
|
||||
timing_args="-ss $start_time "
|
||||
fi
|
||||
if [[ $end_time != "" ]]; then
|
||||
if [[ $start_time == "0" && $end_time == "0" ]]; then
|
||||
# We treat a start and end with 0 values as no op.
|
||||
timing_args=""
|
||||
elif [[ $end_time != "0" ]]; then
|
||||
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
|
||||
timing_args+="-to $end_time"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Extracting audio from $filename.$extension | output: $output_name | start: $start_time | end: $end_time${NORMAL}\n"
|
||||
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -vn -acodec copy "$output_name"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done extracting audio from $filename.$extension | output name '$output_name'${NORMAL}\n\n"
|
||||
|
||||
11
dotfiles/bin/file-checksum-md5.bat
Normal file
11
dotfiles/bin/file-checksum-md5.bat
Normal file
@@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
|
||||
if exist %1\* (
|
||||
echo Run on a file
|
||||
) else (
|
||||
if exist "%~1_checksum-md5.txt" (
|
||||
del "%~1_checksum-md5.txt"
|
||||
)
|
||||
certutil.exe -hashfile "%~1" MD5 > "%~1_checksum-md5.txt"
|
||||
start notepad "%~1_checksum-md5.txt"
|
||||
)
|
||||
11
dotfiles/bin/file-checksum-sha1.bat
Normal file
11
dotfiles/bin/file-checksum-sha1.bat
Normal file
@@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
|
||||
if exist %1\* (
|
||||
echo Run on a file
|
||||
) else (
|
||||
if exist "%~1_checksum-sha1.txt" (
|
||||
del "%~1_checksum-sha1.txt"
|
||||
)
|
||||
certutil.exe -hashfile "%~1" SHA1 > "%~1_checksum-sha1.txt"
|
||||
start notepad "%~1_checksum-sha1.txt"
|
||||
)
|
||||
11
dotfiles/bin/file-checksum-sha256.bat
Normal file
11
dotfiles/bin/file-checksum-sha256.bat
Normal file
@@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
|
||||
if exist %1\* (
|
||||
echo Run on a file
|
||||
) else (
|
||||
if exist "%~1_checksum-sha256.txt" (
|
||||
del "%~1_checksum-sha256.txt"
|
||||
)
|
||||
certutil.exe -hashfile "%~1" SHA256 > "%~1_checksum-sha256.txt"
|
||||
start notepad "%~1_checksum-sha256.txt"
|
||||
)
|
||||
11
dotfiles/bin/file-checksum-sha512.bat
Normal file
11
dotfiles/bin/file-checksum-sha512.bat
Normal file
@@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
|
||||
if exist %1\* (
|
||||
echo Run on a file
|
||||
) else (
|
||||
if exist "%~1_checksum-sha512.txt" (
|
||||
del "%~1_checksum-sha512.txt"
|
||||
)
|
||||
certutil.exe -hashfile "%~1" SHA512 > "%~1_checksum-sha512.txt"
|
||||
start notepad "%~1_checksum-sha512.txt"
|
||||
)
|
||||
13
dotfiles/bin/file-sigcheck.bat
Normal file
13
dotfiles/bin/file-sigcheck.bat
Normal file
@@ -0,0 +1,13 @@
|
||||
@echo off
|
||||
|
||||
cd /d %DEV_TOOLS%\SysinternalsSuite
|
||||
|
||||
if exist %1\* (
|
||||
echo Run on a file
|
||||
) else (
|
||||
if exist "%~1_sigcheck_report.txt" (
|
||||
del "%~1_sigcheck_report.txt"
|
||||
)
|
||||
sigcheck64.exe /a "%~1" > "%~1_sigcheck_report.txt"
|
||||
start notepad "%~1_sigcheck_report.txt"
|
||||
)
|
||||
69
dotfiles/bin/join-video
Normal file
69
dotfiles/bin/join-video
Normal file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Re-encodes the video to get a more accurate timeline. Same settings as trim-video-vbr.
|
||||
# If you want fast video joining at the expense of accuracy then use join-video-fast.
|
||||
|
||||
source "$HOME/dotfiles/script_helpers/windows.sh"
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
output="$2"
|
||||
target_crf="$3"
|
||||
max_bitrate_mb="$4"
|
||||
|
||||
default_crf="33" # if you want to compress then use the same gpu compression level from compress-video (i.e. 33, but verify it's still set to this)
|
||||
default_max_bitrate="6"
|
||||
|
||||
if [[ $filename == "" || $output == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: create a text file that lists the input video paths on separate lines using the format: file '/path/to/video'. Then call:\n\njoin-video <list filename> <output name> <optional: crf (quality, value = compression level) - defaults to $default_crf, use 0 for no value> <optional: max bitrate in MB - defaults to ${default_max_bitrate}M>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extension="${output##*.}"
|
||||
if [[ $extension == $output ]]; then
|
||||
printf "${BOLD}${RED}output arg should have an extension!\n\nUsage: join-video <list filename> <output name> <optional: crf (quality, value = compression level) - defaults to $default_crf, use 0 for no value> <optional: max bitrate in MB - defaults to ${default_max_bitrate}M>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $target_crf == "" || $target_crf == "0" ]] then
|
||||
target_crf=$default_crf
|
||||
fi
|
||||
|
||||
if [[ $max_bitrate_mb == "" ]] then
|
||||
max_bitrate_mb=$default_max_bitrate
|
||||
fi
|
||||
|
||||
# bufsize is typically double the maxrate
|
||||
bufsize=$((max_bitrate_mb * 2))
|
||||
bufsize="${bufsize}M"
|
||||
max_bitrate="${max_bitrate_mb}M"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Joining contents of '$filename' | output: $output | crf: $target_crf | max rate: $max_bitrate | buffer size: $bufsize ${NORMAL}\n"
|
||||
|
||||
time ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda -f concat -safe 0 -accurate_seek -i "$filename" -c:v h264_nvenc -profile:v high -preset 3 -rc:v vbr -cq:v $target_crf -maxrate:v $max_bitrate -bufsize:v $bufsize -c:a copy -movflags +faststart "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
|
||||
|
||||
flash_taskbar
|
||||
@@ -1,5 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# A fast way to join video clips that might result in some weird playback cursor timings,
|
||||
# e.g. video player might show negative seconds at the start of the vid or the
|
||||
# playback time might oscillate a bit. Use join-video for accurate joining at
|
||||
# the cost of a much slower processing time.
|
||||
|
||||
source "$HOME/dotfiles/script_helpers/windows.sh"
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
@@ -35,7 +42,8 @@ output="${output_name}.mp4"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Joining contents of '$filename'| output: $output${NORMAL}\n"
|
||||
|
||||
ffmpeg -f concat -safe 0 -i "$filename" -c copy "$output"
|
||||
ffmpeg -y -stats -loglevel level+error -f concat -safe 0 -i "$filename" -c copy "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
|
||||
|
||||
flash_taskbar
|
||||
83
dotfiles/bin/normalize-volume
Normal file
83
dotfiles/bin/normalize-volume
Normal file
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Use this to normalize the volume of a video or audio file using the average
|
||||
# loudness, or RMS-based normalization. It does a pretty good job!
|
||||
#
|
||||
# If you want to modify the volume manually then checkout the analyze-volume
|
||||
# and change-volume scripts.
|
||||
#
|
||||
# This does not re-encode video when given a video file.
|
||||
#
|
||||
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
|
||||
|
||||
source "$HOME/dotfiles/script_helpers/windows.sh"
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: normalize-volume <video or audio filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output_name="$2"
|
||||
|
||||
if [[ $output_name == "" ]]; then
|
||||
output="${filename}_normalized_audio.$extension"
|
||||
else
|
||||
output="${output_name}.$extension"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Normalizing audio in $filename.$extension | output: $output${NORMAL}\n"
|
||||
|
||||
# This is done in two passes. The first pass will compute the mean loudness and
|
||||
# the second pass will normalize the audio using the mean as the target.
|
||||
|
||||
temp_file="/tmp/_audio_info_$RANDOM"
|
||||
|
||||
# 1st pass:
|
||||
cmd="ffmpeg -i \"$filename.$extension\" -pass 1 -filter:a loudnorm=print_format=json -vn -sn -dn -f null /dev/null 2>&1 | sed -n '/{/,/}/p' > $temp_file"
|
||||
printf "\n${BOLD}Running 1st pass:\n$cmd\n\n${NORMAL}"
|
||||
eval "$cmd"
|
||||
|
||||
printf "${BOLD}${GREEN}Done.\n\n${NORMAL}"
|
||||
|
||||
ii=`grep \"input_i\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
|
||||
itp=`grep \"input_tp\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
|
||||
ilra=`grep \"input_lra\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
|
||||
it=`grep \"input_thresh\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
|
||||
to=`grep \"target_offset\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
|
||||
|
||||
# 2nd pass:
|
||||
cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -c:v copy -pass 2 -filter:a loudnorm=linear=true:I=-16:LRA=11:tp=-1.5:measured_I=$ii:measured_LRA=$ilra:measured_tp=$itp:measured_thresh=$it:offset=$to:print_format=summary \"$output\""
|
||||
printf "${BOLD}Re-encoding audio:\n$cmd\n\n${NORMAL}"
|
||||
eval "$cmd"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done normalizing volume in $filename.$extension | output: $output${NORMAL}\n"
|
||||
rm $temp_file
|
||||
|
||||
flash_taskbar
|
||||
@@ -24,7 +24,7 @@ else
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
||||
printf "${BOLD}${RED}Usage: remove-audio-from-video <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -43,7 +43,7 @@ fi
|
||||
printf "\n${YELLOW}${BOLD}Removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n"
|
||||
|
||||
# -an removes the audio.
|
||||
ffmpeg -i "$filename.$extension" -c:v copy -an "$output"
|
||||
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -an -map 0 "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n\n"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source "$HOME/.dotfiles/script_helpers/all.sh"
|
||||
source "$HOME/dotfiles/script_helpers/all.sh"
|
||||
|
||||
cwd=$PWD
|
||||
source_path=""
|
||||
71
dotfiles/bin/transcode-audio
Normal file
71
dotfiles/bin/transcode-audio
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Transcodes audio from a video or audio source into a new audio file. If you
|
||||
# just want the audio from a video as-is then use extract-audio-from-video
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename="$1"
|
||||
output_name="$2"
|
||||
sample_rate="$3"
|
||||
channel_count="$4"
|
||||
start_time="$5"
|
||||
end_time="$6"
|
||||
|
||||
output_base=$(basename -- "$output_name")
|
||||
output_extension="${output_base##*.}"
|
||||
|
||||
if [[ $filename == "" || $output_extension == "" || $output_extension == $output_base ]]; then
|
||||
printf "${BOLD}${RED}Usage: transcode-audio <filename> <output name w/ extension> <optional: sample rate. Defaults to 44100> <optional: channel count. Defaults to 2> <optional: start time HH:MM:SS, use empty string or 0 for start> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $sample_rate == "" ]]; then
|
||||
sample_rate="44100"
|
||||
fi
|
||||
|
||||
if [[ $channel_count == "" ]]; then
|
||||
channel_count="2"
|
||||
fi
|
||||
|
||||
timing_args=""
|
||||
if [[ $start_time != "" ]]; then
|
||||
timing_args="-ss $start_time "
|
||||
fi
|
||||
if [[ $end_time != "" ]]; then
|
||||
if [[ $start_time == "0" && $end_time == "0" ]]; then
|
||||
# We treat a start and end with 0 values as no op.
|
||||
timing_args=""
|
||||
elif [[ $end_time != "0" ]]; then
|
||||
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
|
||||
timing_args+="-to $end_time"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Extracting audio from '$filename' | output: '$output_name' | sample rate: $sample_rate | channels: $channel_count | start: $start_time | end: $end_time${NORMAL}\n"
|
||||
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename" -ar $sample_rate -ac $channel_count -map a "$output_name"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done extracting audio from '$filename' | output '$output_name'${NORMAL}\n\n"
|
||||
|
||||
104
dotfiles/bin/transcribe-audio
Normal file
104
dotfiles/bin/transcribe-audio
Normal file
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# The base model is pretty good overall. It has good punctuation inserting and catches most words.
|
||||
# Tiny is fast and often has correct grammar, but it misses a lot of words, especially when the
|
||||
# source isn't loud or is muffled.
|
||||
#
|
||||
# Small and medium models can do better word detection at times, but suffer from a lack of punctuation.
|
||||
# Medium is particularly bad and often excludes periods and commas.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
# Will return a symlink path in its expanded form. If the path's root is the
|
||||
# home directory symbol "~" then it'll be replaced by the full home path.
|
||||
expand_path() {
|
||||
local ret="$1"
|
||||
|
||||
IFS="/" read -ra parts <<< "$ret"
|
||||
if [[ "${parts[0]}" == "~" ]]; then
|
||||
ret="$HOME"
|
||||
for ((i=1; i < ${#parts[@]}; i++))
|
||||
do
|
||||
ret="$ret/${parts[$i]}"
|
||||
done
|
||||
fi
|
||||
ret=$(readlink -m "$ret")
|
||||
echo $ret
|
||||
}
|
||||
|
||||
input_wav="$1"
|
||||
output_name_without_ext="$2"
|
||||
model="$3"
|
||||
threads=$4
|
||||
|
||||
if [[ $input_wav == "" || $output_name_without_ext == "" || $model == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: transcribe-audio <input.wav> <output name without extension> <model name> <optional: thread count>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$input_wav" ]]; then
|
||||
printf "${RED}${BOLD}Input file \"$input_wav\" doesn't exist!\n${NORMAL}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
output_name="$output_name_without_ext.${model}"
|
||||
|
||||
# 1 core 31 threads has very fast pcm_to_mel conversion and then just one core doing most of the work. You get more accurate results this way.
|
||||
# 2 core 16 is about half the time but it can have errors where the two pieces come together. This only gets more likely as the core count is increased.
|
||||
# 8 threads, 4 cores is good too for tiny,small and 2 threads, 4 cores for medium.
|
||||
|
||||
|
||||
# 4 seems to be the sweet spot for most models, except medium might be faster with 8.
|
||||
# But on my 5950x, running 1 core with 31 threads is quite fast.
|
||||
#default_thread_count=4
|
||||
cores=1
|
||||
default_thread_count=31
|
||||
|
||||
if [[ $threads == "" ]]; then
|
||||
threads=$default_thread_count
|
||||
|
||||
# This is only useful when not setting the core count and defaulting to 4 threads.
|
||||
#if [[ $model == "medium" || $model == "large" ]]; then
|
||||
# threads=8
|
||||
#fi
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name ${NORMAL}\n"
|
||||
|
||||
whisper_fullname="$(expand_path $(which whisper.exe))"
|
||||
whisper_path="$(dirname $whisper_fullname)"
|
||||
models_path="$whisper_path/models"
|
||||
|
||||
if [[ $model != "large" ]]; then
|
||||
model="${model}.en"
|
||||
fi
|
||||
|
||||
whisper.exe --processors ${cores} --threads ${threads} -m "$models_path/ggml-${model}.bin" -otxt -osrt -f "$input_wav" -of "$output_name" --print-colors --print-progress
|
||||
|
||||
error=$?
|
||||
if [[ error -eq 0 ]]; then
|
||||
printf "${GREEN}${BOLD}Done transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name${NORMAL}\n"
|
||||
else
|
||||
printf "${GREEN}${BOLD}Error while transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name${NORMAL}\n"
|
||||
fi
|
||||
63
dotfiles/bin/transcribe-video
Normal file
63
dotfiles/bin/transcribe-video
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
input_video="$1"
|
||||
output_name_without_ext="$2"
|
||||
start_time="$3"
|
||||
end_time="$4"
|
||||
shift 4
|
||||
models=("$@")
|
||||
|
||||
if [[ $input_video == "" || $output_name_without_ext == "" || $start_time == "" || $end_time == "" || ${#models[@]} -eq 0 ]]; then
|
||||
printf "${BOLD}${RED}Usage: transcribe-video <input.mp4> <output name without extension> <start time HH:MM:SS, use 0 for start> <end time HH:MM:SS, use 0 for no value> <list of model names to use>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
model_csv=$(IFS=_ ; echo "${models[*]}")
|
||||
wav_name="${output_name_without_ext}_${model_csv}_${RANDOM}"
|
||||
|
||||
# Add extension if not provided.
|
||||
input_basename=$(basename -- "$wav_name")
|
||||
input_extension="${input_basename##*.}"
|
||||
if [[ input_extension != "wav" ]]; then
|
||||
wav_name="${wav_name}.wav"
|
||||
fi
|
||||
|
||||
channel_count=1
|
||||
sample_rate=16000
|
||||
transcode-audio "$input_video" "$wav_name" $sample_rate $channel_count $start_time $end_time
|
||||
if [[ $? == 1 ]]; then exit 1; fi
|
||||
|
||||
for model in "$@"; do
|
||||
transcribe-audio "$wav_name" "$output_name_without_ext" "${model}"
|
||||
|
||||
if [[ $? == 1 ]]; then
|
||||
printf "${RED}${BOLD}Saving the audio file \"$wav_name\" in case you want to reuse it for debugging.\n${NORMAL}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
rm "$wav_name"
|
||||
|
||||
37
dotfiles/bin/transcribe-video-base
Normal file
37
dotfiles/bin/transcribe-video-base
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: transcribe-video-base <input.mp4> <output name without extension> <optional: start time HH:MM:SS, use 0 for start> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
start_time="$3"
|
||||
end_time="$4"
|
||||
|
||||
if [[ $start_time == "" ]]; then start_time="0"; fi
|
||||
if [[ $end_time == "" ]]; then end_time="0"; fi
|
||||
|
||||
transcribe-video "$1" "$2" $start_time $end_time "base"
|
||||
37
dotfiles/bin/transcribe-video-medium
Normal file
37
dotfiles/bin/transcribe-video-medium
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: transcribe-video-medium <input.mp4> <output name without extension> <optional: start time HH:MM:SS, use 0 for start> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
start_time="$3"
|
||||
end_time="$4"
|
||||
|
||||
if [[ $start_time == "" ]]; then start_time="0"; fi
|
||||
if [[ $end_time == "" ]]; then end_time="0"; fi
|
||||
|
||||
transcribe-video "$1" "$2" $start_time $end_time "medium"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user