如何录制并播放SSH轻视频

先来看下面的视频:


是不是很神奇?可以看到,我录制了一个SSH session的所有操作与反馈,并完全还原在这里播放了。今天,我们就来介绍一下如何录制SSH轻视频,并整合在博客里播放。本文作者为香菇肥牛,原文链接为https://qing.su/article/155.html, 转载需注明原文链接。谢谢!

我们先来介绍SSH轻视频的录制。

SSH视频录制需要软件asciinema. 可以用下面的命令安装。

1
apt-get install asciinema

安装完毕后,即可开始录制。

1
asciinema rec your-file.cast

录制完毕后按下Ctrl + D结束录制,程序会自动在当前目录下生成your-file.cast的录屏文件。

然后,我们再来介绍一下如何在自己的博客中播放这样的轻视频。

如果您的网站面对的是国外访客,您可以直接上传生成的cast录屏文件,调用asciinema.org官方的嵌入链接来播放。很遗憾,他们官方的播放器在国内加载非常慢,因此我们不得不在自己的服务器上提供播放服务。幸好这非常简单。

SSH轻视频的播放仅需要两个文件,我把他们放在Github上,通过JSDelivr的CDN调用,在国内的访问速度就非常快了。Github链接在这里https://github.com/Har-Kuun/sshsharer, 上面有详细的调用链接。

您只要在文章中需要插入播放器的地方插入下面这几行:

1
2
3
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/Har-Kuun/sshsharer@1.0/sshsharer-player.css" />   
<sshsharer-player src="https://link-to-your.cast"></sshsharer-player>
<script src="https://cdn.jsdelivr.net/gh/Har-Kuun/sshsharer@1.0/sshsharer-player.js"></script>

将第二行的link-to-your.cast替换为您自己的.cast文件位置即可。是不是非常方便呢?

录制并播放SSH轻视频的方法就介绍到这里,如果您还有什么疑问,欢迎在这里留言,我将尽力解答。本文作者为香菇肥牛,原文链接为https://qing.su/article/155.html, 转载需注明原文链接。谢谢!

12 thoughts on “如何录制并播放SSH轻视频”

  1. Amazing things here. I am very happy to look your article.
    Thank you a lot and I’m taking a look forward to touch you.
    Will you please drop me a e-mail?

    Reply
  2. whoah this blog is magnificent i really like reading your
    posts. Stay up the good work! You understand, lots of people
    are looking round for this information, you could aid them
    greatly.

    Reply
  3. I just like the valuable info you provide to your articles.
    I will bookmark your blog and take a look at again right here frequently.
    I’m slightly certain I will be told many new stuff right here!
    Best of luck for the following!

    Reply
  4. Hmm it looks like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I wrote and
    say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but
    I’m still new to the whole thing. Do you have any tips for newbie blog writers?

    I’d really appreciate it.

    Reply

Leave a Comment