錄制終端視頻
[root@localhost ~]# asciinema rec first.cast [root@localhost ~]# asciinema rec /www/wwwroot/first.cast # rec后面跟錄制文件的保存位置 [root@localhost ~]# asciinema rec /www/wwwroot/first.cast --append # 追加錄制
播放終端視頻
[root@localhost ~]# asciinema play first.cast # 正常速度播放 [root@localhost ~]# asciinema play -s 2 first.cast # 以2倍速重播 [root@localhost ~]# asciinema play -i 2 first.cast # 正常速度播放,但空閑時間限制為2秒
上傳錄制到asciinema.org
這是一個默認的asciinema-server 實例,並打印一個秘密鏈接,您可以使用它來在Web瀏覽器中觀看您的錄制內容。輸入exit,結束錄制后,就會彈出視頻保存的地址。
[root@localhost ~]# asciinema upload first.cast # 方式1:將錄制好的放上去 [root@localhost ~]# asciinema rec # 方式2:直接在錄制的時候,不加文件名,就會直接上傳了
https://mp.weixin.qq.com/s/oqZqGiQ3uNrNuT-nGrh9lg
https://www.cnblogs.com/dggsec/p/9216112.html
三、瀏覽器播放
asciinema錄制文件在web端(瀏覽器)播放是通過asciinema-player組件來實現的,還需要借助兩個庫文件 asciinema-player.css 和 asciinema-player.js 。首先分別引入css和js文件,添加一個asciinema-player的標簽即可播放標簽內文件的錄像。
下載 asciinema-player.js 文件: wget -q https:
//github
.com
/asciinema/asciinema-player/releases/download/v2
.4.0
/asciinema-player
.js
下載 asciinema-player.css文件:wget -q https:
//github
.com
/asciinema/asciinema-player/releases/download/v2
.4.0
/asciinema-player
.css
示例 HTML 代碼(注意新增的 asciinema-player 標簽)如下:
<html> <head> <link rel="stylesheet" type="text/css" href="asciinema-player.css" /> </head> <body> <asciinema-player src="demo.cast"></asciinema-player> <script src="asciinema-player.js"></script> </body> </html>
四、另一種終端錄制(script 命令)
script 命令是 Linux 系統自帶一個的終端錄制工具,功能與 asciinema 類似,可以將終端交互內容保存在本地的文本文件中,再使用 scriptreplay 命令進行播放。
[root@localhost ~]# script -t 2>time.file -a output.file # 錄制 [root@localhost ~]# scriptreplay time.file output.file # 播放
其中 time.file 用於保存時間信息,output.file 則用於記錄終端輸出的內容及光標的移動等。錄制完成時使用 exit 命令或者 Ctrl+D 終止錄制。
https://ops-coffee.cn/s/pcstabodjds8d15arwafza