问题描述
FFmpeg现在支持librsvg对SVG栅格化的支持.
FFmpeg now support librsvg support for SVG rasterization.
我尝试了以下命令:
ffmpeg -i test.svg test.png
但是出现以下错误:
Decoder (codec svg) not found for input stream #0:0
我已经搜索了文档,但是没有给出示例.有人可以告诉我如何使用ffmpeg在命令行中从SVG文件生成PNG吗?
I have search the doc but there is no examples given. Can someone tell me how to a command line using ffmpeg to generate a PNG from a SVG file?
推荐答案
您的ffmpeg需要使用--enable-librsvg
进行编译.如果要编译ffmpeg,则需要安装提供librsvg头文件的任何软件包.例如,在Arch Linux中,它是 librsvg ,而在Ubuntu中,它是 librsvg2-dev .
Your ffmpeg needs to be compiled with --enable-librsvg
. If you're compiling ffmpeg then you need to install whatever package provides the librsvg header files. For example, in Arch Linux it is librsvg, and in Ubuntu it is librsvg2-dev.
用法类似于将栅格图像用作图像解复用器的输入 .例如,一系列名为vector-001.svg
,vector-002.svg
,vector-003.svg
等的图像:
Usage is similar to using raster images as inputs with the image demuxer. For example, a series of images named vector-001.svg
, vector-002.svg
, vector-003.svg
, etc:
ffmpeg -i vector-%03d.svg -vf format=yuv420p output.mp4
单张图片
ffmpeg -i input.svg output.png
使用自定义尺寸:
ffmpeg -width 600 -i input.svg output.png
-keep_ar true
是默认设置,因此在此示例中,它将自动计算高度以保留宽高比.
-keep_ar true
is the default, so it will automatically calculate height in this example to preserve the aspect ratio.
解码器librsvg有一些输入选项:
The decoder librsvg has a few input options:
$ ffmpeg -h decoder=librsvg
[…]
-width <int> .D.V...... Custom width to render to (0 for default) (from 0 to INT_MAX) (default 0)
-height <int> .D.V...... Custom height to render to (0 for default) (from 0 to INT_MAX) (default 0)
-keep_ar <boolean> .D.V...... Keep aspect ratio with custom width/height (default true)
这篇关于ffmpeg支持svg栅格化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!