zoukankan      html  css  js  c++  java
  • 如何在linux下录制terminal操作?

    相关包:

    • ttyrec:
      ttyrec is a tty recorder. Recorded data can be played back with the included ttyplay command.
      ttyrec is just a derivative of script command for recording timing information with microsecond accuracy as well.
      It can record emacs -nw, vi, lynx, or any programs running on tty.

    • imagemagick:
      Use ImageMagick to create, edit, compose, or convert bitmap images.
      It can read and write images in a variety of formats (over 200).
      Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

    • python-opster:
      Opster is a command line options parser, intended to make writing command line applications easy and painless.

    安装方法:

    sudo apt-get install ttyrec
    
    sudo apt-get install imagemagick
    
    sudo apt-get install python-opster
    

    tty2gif.py

    下载地址:https://bitbucket.org/antocuni/tty2gif/raw/61d5596c916512ce5f60fcc34f02c686981e6ac6/tty2gif.py

    注意:运行的python环境为python2(此为第一个坑)

    执行过程

    • 运行命令ttyrec(不是ttyprec参考文章中写错了,此为第二个坑)
    • 回车开始录制,后台会运行记录工具
    • exit或ctrl+d停止录制
    • ttyrec 默认会在主目录下创建一个ttyrecord的文件

    后续处理

    • 回放
      终端输入: ttyplay ttyrecord

    • 转成gif

    python tty2gif.py typing ttyrecord
    

    如果有错误,检查一下你是否有安装 python-opster 包

    sudo apt-get install xdotool
    export WINDOWID=$(xdotool getwindowfocus)
    
    • 将所有gif整合成一个example.gif
    convert -delay 25 -loop 0 *.gif example.gif
    

    注: convert有很多参数,在下一篇文章中详细分析,通过修改参数可以定制我们的转换出来的效果。

    参考文章:
    1、ttyrec & ttyplay - Linux记录播放终端会话
    2、如何在 Linux 上录制你的终端操作

  • 相关阅读:
    进程和线程
    关于offer对比
    CVTE面经
    重定向
    奇虎360面试经验
    百纳信息(海豚浏览器)面经
    携程网面经
    百度面经
    位运算
    Cracking the Coding Interview 4.8
  • 原文地址:https://www.cnblogs.com/everfight/p/ttyrec.html
Copyright © 2011-2022 走看看