Make terminal demonstration video on mac and generate gif

original
2017/01/18 11:57
Reading number 597

Various schemes have been tried:

  1. Ttyrec+tty2gif/ttygif: after a long time, the generation of gif is too slow and the effect is not very good
  2. LICECap tool screen recording generation gif: the effect is not satisfactory and the image quality is too poor
  3. Ttystduio: The image quality is not very satisfactory, and the generated file is very large
  4. The qucktime video recording mov+ffmpeg to gif+convert provided with the mac optimizes the gif size: the final solution
  5. The qucktime provided with the Mac is very powerful. You can directly select the area where you want to record the screen and record it directly. Finally, you can generate a mov file..

But the default ffmpeg parameter is directly converted to gif, and the image quality is very poor. Finally, I searched a script from the foreigner's github (the original url cannot be found,==)..

 #!/ bin/sh palette="/tmp/palette.png" filters="fps=$4,scale=$3:-1:flags=lanczos" ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x];  [x][1:v] paletteuse" -y $2

In it, the ffmpeg pre generated palette is used to improve the image quality of gif, and the file size is compressed by setting the zoom ratio and frame rate..

Usage:

 mov2gif  xxx.mov xxx.gif 800 1

This is the parameter I set here. Since I record terminal video, the frame rate is set to 1fps, which is enough, otherwise the file is too large..

Then use convert to further compress the gif size:

 convert xxx.gif -fuzz 5% -layers Optimize xxx2.gif

If you do not add - fuzzy 5%, the optimization granularity is not large. This parameter can combine the similar colors in the vicinity of the image into the same value for compression. With this command, you can basically continue to compress 50% of the size (for terminal video, large blocks of colors are background colors)

Finally, I will show the recording effect of my side (along with a small advertisement:)

 demo

Expand to read the full text
Loading
Click to lead the topic 📣 Post and join the discussion 🔥
Reward
zero comment
two Collection
zero fabulous
 Back to top
Top