7

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?

1 Answer 1

13

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)
Sign up to request clarification or add additional context in comments.

5 Comments

Hello and thank you for your answer --enable-librsvg does not appear in configuration by default. It has been a while since I have compile anything on window but will give it a go. Would you happen to have a compile version for window with --enable-librsvg enabled so I can give it a try? I just want to see whether it is actually possbile to create an Mp4 video with a serie of SVG as input.
Hello, I have finally compiled ffmpeg on Window with --enable-librsvg as you suggested. And I was able to convert a set of Svg to an Mp4 which is really cool. Thanks a lot for your precious advice LordNeckbeard!
I'm having trouble compiling FFmpeg with --enable-librsvg on windows 10 64. Any suggestion of a tutorial to follow or the method that worked for you?
@AhmedHawary Sorry, but I'm not a Windows user. Maybe github.com/rdp/ffmpeg-windows-build-helpers can help.
@Olivier Etienne could you be so kind as to link your build or the instructions you used?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.