3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【asciinema】アイドル(無入力)時間を自動で削除する方法(オート編集)

Last updated at Posted at 2020-10-25

タイピングのタイミングをクォンタイズ(均一化)したい

コンソールの録画ツール「asciinema」で作業を録画すると、こ・ん・な・かん・じ・に、人差し指タイピングのような「変な間」が出来てしまいます。しかし、録画データの JSON ファイルを編集するのが面倒です。簡単に「カタカタカタッターン」系(俺できる風)にできないかしら。

[「asciinema 時間 短縮 編集」でググって]("asciinema" 時間 短縮 編集)も「.cast ファイルの JSON を編集するべし」くらいしか出てこなかったので、自分のググラビリティとして。

TL; DR

asciinema の CLI エディタ「asciinema-edit」の quantize コマンドを使う。

  • ビルド済みバイナリを手動インストール
    macOS と Linux ユーザ向けにビルド済みのバイナリがリリースされているので、最新のリリースからバイナリをダウンロードして使います。
    • Releases | asciinema-edit @ GitHub
      • macOS ユーザは Darwin、Linux ユーザは Linux をダウンロード
  • go を使ってインストール
    go がインストールされている環境であれば、OS や CPU を問わず asciinema-edit をインストールできます。gogit がインストールされた状態で以下を実行してください。
    • go install "github.com/cirocosta/asciinema-edit@latest"
    • go アプリのアップデートには gup を使うと便利です。

以下は asciinema で録画したファイル hoge.cast を、0.2〜1 秒の(無操作時間)を 0.2 秒に、1〜2 秒の間を 1 秒に、2 秒以上の間を 2 秒に均一化する例です。

asciinema-editコマンド使用例
asciinema-edit quantize \
       --range 0.2,1 \
       --range 1,2 \
       --range 2 \
       ./hoge.cast > ./fuga.cast

TS; DR

asciinema-edit quantize --range 0.1,4 --range 4 ./before.cast > ./after.cast の例。OS は macOS です。

$ # リリース情報の確認
$ gh release view --repo cirocosta/asciinema-edit
0.0.6
cirocosta released this about 2 years ago

  ## Changelog                                                                
                                                                              
  28a7d76 Validates cast before applying transformation (#12) e550d5c Updates 
  flags in README 2e8cd97 Bumps version in README                             
                                                                              
  --------                                                                    
                                                                              
  Automated with GoReleaser https://github.com/goreleaser Built with go       
  version go1.10.3 darwin/amd64                                               


Assets
asciinema-edit_0.0.6_darwin_amd64.tar.gz  952.08 KiB
asciinema-edit_0.0.6_linux_amd64.tar.gz   904.26 KiB
asciinema-edit_checksums.txt              213 B

View on GitHub: https://github.com/cirocosta/asciinema-edit/releases/tag/0.0.6

$ # 最新バージョンは 0.0.6、Assets に darwin と linux 用のバイナリが確認できます。ダウンロードします。
gh release download --repo cirocosta/asciinema-edit 0.0.6

$ # ダウンロードされたファイルを確認
$ ls -l
total 3736
-rw-r--r--  1 admin  staff  974930 10 25 21:17 asciinema-edit_0.0.6_darwin_amd64.tar.gz
-rw-r--r--  1 admin  staff  925969 10 25 21:17 asciinema-edit_0.0.6_linux_amd64.tar.gz
-rw-r--r--  1 admin  staff     213 10 25 21:17 asciinema-edit_checksums.txt

$ # ファイルが破損していないかチェックサムで確認
$ shasum --check asciinema-edit_checksums.txt
asciinema-edit_0.0.6_linux_amd64.tar.gz: OK
asciinema-edit_0.0.6_darwin_amd64.tar.gz: OK

$ # macOS 用(darwin)を解凍
tar -zxvf asciinema-edit_0.0.6_darwin_amd64.tar.gz
x LICENSE
x LICENSE
x README.md
x README.md
x asciinema-edit

$ # Smoke test
$ ./asciinema-edit --version
asciinema-edit version 0.0.6 - 28a7d761cd7cb112f23e43e2f2f948542cc0fc9f

$ # asciinema と同じディレクトリにコピーしてインストールします
cp ./asciinema-edit "$(dirname $(which asciinema))/asciinema-edit"

$ # インストールされたか確認
$ asciinema-edit --version
asciinema-edit version 0.0.6 - 28a7d761cd7cb112f23e43e2f2f948542cc0fc9f

参考文献

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?