Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ffmpeg support for svg rasterization

Tags:

ffmpeg

svg

FFmpeg now support librsvg support for SVG rasterization.

I have tried the following command:

ffmpeg -i test.svg test.png

But I get the following error:

Decoder (codec svg) not found for input stream #0:0

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?

like image 613
Olivier Etienne Avatar asked Jul 21 '26 17:07

Olivier Etienne


1 Answers

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.

Series of images

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

Single image

ffmpeg -i input.svg output.png

With custom size:

ffmpeg -width 600 -i input.svg output.png

-keep_ar true is the default, so it will automatically calculate height in this example to preserve the aspect ratio.

Decoder specific options

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)
like image 74
llogan Avatar answered Jul 23 '26 10:07

llogan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!