markdown将webm文件转换为gif(使用ffmpeg和gifsicle)(代码片段)

author author     2022-12-15     211

关键词:

## Introduction

Sometimes I want to make a screencapture of a websites behaviour.

In Chrome, I am quite happy doing this with the [Awesome Screenshot: Screen Video Recorder][1] extension.

Besides screenshots, the extension offers the ability to make a recording. (Limited to 30 seconds in the free version).

The recording can be uploaded to Youtube or Google Drive. It can also be downloaded as WebM file.

Often, I want to share the recording with co-workers on Slack.

Besides the fact that Slack does not support WebM, I dislike uploading several MBs of recording.

To remedy this, I convert the recording to a (smaller) GIF and share that on Slack.

## Converting

To convert the WebM to GIF, I use [FFmpeg][2]. I then use [Gifsicle][3] to resize and optimize the created GIF.

I've found that 600 pixels height is a nice compromise between size and readablility (when text is involved).

The command I use for this is:

```bash
sInput='/path/to/file.webm';
sOutput="$(basename $sInput%.*)";
ffmpeg -i "$sInput" -pix_fmt rgb8 "$sOutput.gif" \
    && gifsicle --optimize=3 --output "$sOutput-optimized.gif" --resize-height 600 "$sOutput.gif"
```

This will easily turn a 2.5M WebM file to a 600K GIF. Without optimization it would be roughly 3.5M.

I'm sure more optimizations are possible, I might add these later.

It would also be simple to turn the command into a function. I might do _that_ later as well.

<!-- TODO:
## Explaining the command

`--optimize[=level]` Optimize output GIF animations for space. Level determines how much optimization is done; higher levels take longer, but may have better results. There are currently three levels: 

- `-O1` Stores only the changed portion of each image. This is the default.
- `-O2` Also uses transparency to shrink the file further.
- `-O3` Try several optimization methods (usually slower, sometimes better results).
-->

[1]: https://chrome.google.com/webstore/detail/awesome-screenshot-screen/nlipoenfbbikpbjkfpfillcgkoblgpmj
[2]: https://www.ffmpeg.org
[3]: https://www.lcdf.org/gifsicle/

当我将透明度添加到 gif 并将其转换为 webm 时出现故障

】当我将透明度添加到gif并将其转换为webm时出现故障【英文标题】:GlitchinesswhenIaddtransparencytoagifandconvertittowebm【发布时间】:2017-08-3009:19:41【问题描述】:从谷歌图片开始,我有这个gif:然后我将蓝色转换为透明:convertoctopus.g... 查看详情

使用 Python 将 WEBM 文件转换为 WAV 文件 [关闭]

】使用Python将WEBM文件转换为WAV文件[关闭]【英文标题】:ConvertWEBMfiletoWAVfilewithPython[closed]【发布时间】:2021-11-0116:55:32【问题描述】:我想用Python将webm文件转换为wav文件进行分析。有没有简单的方法在Python中进行webm到wav的转换... 查看详情

markdown将视频转换为gif(代码片段)

查看详情

使用PHP将视频文件转换为mp4、flv、webgl、webm、ogv等

】使用PHP将视频文件转换为mp4、flv、webgl、webm、ogv等【英文标题】:UsingPHPtoconvertvideofilestomp4,flv,webgl,webm,ogv,etc【发布时间】:2012-01-2915:01:08【问题描述】:是否有任何可用的功能或脚本允许将视频(在文件夹中或上传时)转换... 查看详情

如何将画布动画保存为 gif 或 webm?

】如何将画布动画保存为gif或webm?【英文标题】:Howtosavecanvasanimationasgiforwebm?【发布时间】:2018-11-1320:29:51【问题描述】:我已经编写了这个函数来捕获GIF的每一帧,但是输出非常滞后并且在数据增加时崩溃。有什么建议吗?... 查看详情

sh将gif简单地转换为mp4(h264/h265),webm(vp8/vp9)和webp(代码片段)

查看详情

将 GIF 转换为 CUR 文件 [关闭]

】将GIF转换为CUR文件[关闭]【英文标题】:ConvertaGIFintoaCURfile[closed]【发布时间】:2010-09-3009:28:25【问题描述】:如何从GIF图像文件创建.cur(用于鼠标光标)?我可以使用什么工具或流程?【问题讨论】:【参考方案1】:您需要... 查看详情

使用 PHP 快速将 (.rtf|.doc) 文件转换为 Markdown 语法

】使用PHP快速将(.rtf|.doc)文件转换为Markdown语法【英文标题】:QuicklyConvert(.rtf|.doc)FilestoMarkdownSyntaxwithPHP【发布时间】:2010-11-0520:07:05【问题描述】:我这几天一直在手动将文章转换为Markdown语法,而且变得相当乏味。其中一些是3... 查看详情

如何将 Markdown 文件转换为 PDF

】如何将Markdown文件转换为PDF【英文标题】:HowtoconvertaMarkdownfiletoPDF【发布时间】:2013-07-1121:58:06【问题描述】:我有一个想要转换为PDF的Markdown文件,以便我可以将它上传到Speakerdeck。我正在使用Pandoc从Markdown转换为PDF。我的问... 查看详情

如何将word文件转换为markdown文件

...。7.中间定位来解决Tidy和Pandoc的缺点。8.使用Pandoc转换为Markdown。9.清理和最后修复Markdown。但是应该注意,您需要购买MicrosoftWord才能工作。希望这可以作为一个更可靠的转换Word文档的起点! 参考技术B它由9个连续步骤组成:1.使... 查看详情

shrecursivelybash将所有html转换为markdown文件(使用pandoc)(代码片段)

查看详情

使用脚本将多个目录中的多个 Markdown 文件转换为 HTML

】使用脚本将多个目录中的多个Markdown文件转换为HTML【英文标题】:ConvertingMultipleMarkdownFilesinMultipleDirectoriesintoHTMLwithaScript【发布时间】:2012-01-2010:06:49【问题描述】:我目前有一个很大的目录,里面有很多子目录,每个子目录... 查看详情

将 PNG 转换为具有透明度的 webm 视频

】将PNG转换为具有透明度的webm视频【英文标题】:ConvertPNGstowebmvideowithtransparency【发布时间】:2016-04-3016:18:44【问题描述】:我想使用avconv将一系列PNG图像转换为WebM视频,同时保留透明度。我了解输出视频中使用的像素格式必... 查看详情

windows使用pandoc将markdown转换为pdf文件

pandoc下载:https://github.com/jgm/pandoc/releases/tag/1.19.2.1//windows下载msi文件miktex下载:https://miktex.org/download//下载对应的版本下载完成后进行安装在cmd下进行转换pandoctest.md-otest.pdf--latex-engine=xelatex-Vmainfont="SimS 查看详情

如何把markdown文件转化为pdf

参考技术A试试这个利用Pandoc将markdown文件转化为pdf准备工作安装pandoc安装MiKTeX将markdown文件转换为pdf准备工作安装pandocWindows下安装pandoc很容易,直接从pandoc官网上下载最新安装包安装即可。Linux下的安装可以参考阳志平的博文1。... 查看详情

如何把markdown文件转化为pdf

试试这个利用Pandoc将markdown文件转化为pdf准备工作安装pandoc安装MiKTeX将markdown文件转换为pdf准备工作安装pandocWindows下安装pandoc很容易,直接从pandoc官网上下载最新安装包安装即可。Linux下的安装可以参考阳志平的博文1。安装MiKTeXp... 查看详情

markdown前端渲染

参考技术Ahttps://www.jianshu.com/p/b932f305b1ec使用CDN加载js文件:marked([markdown内容])可以将Markdown源码转换为html示例: 查看详情

有没有办法将 gif 添加到 Markdown 文件?

】有没有办法将gif添加到Markdown文件?【英文标题】:IsthereawaytoaddagiftoaMarkdownfile?【发布时间】:2016-03-2408:20:29【问题描述】:我想将此gif添加到GitHub风格的降价文件中。如果在GitHub中做不到,是否可以在其他版本的markdown中做... 查看详情