olive-editor / olive

Free open-source non-linear video editor
https://olivevideoeditor.org/
GNU General Public License v3.0
8.22k stars 556 forks source link

[CODEC] Import SVG as vector image #458

Closed ghost closed 3 years ago

ghost commented 5 years ago

Is it possible import SVG as vector graphics image?

DaniSeeh commented 5 years ago

This feature would be awesome! As far as I know no NLE supports vector graphics.

itsmattkc commented 5 years ago

This would definitely be interesting, but I'm not sure how effective it would be. FFmpeg's SVG support is spotty, but Qt's isn't so I'd probably hook into that. However the bigger issue is that - from what I've read - there aren't great ways to convert SVGs to OpenGL without just rasterizing them into a texture, which might defeat the point. But at the very least, you'd be able to change the rasterization size within Olive with this paradigm.

DaniSeeh commented 5 years ago

If it had to be rasterized, I wonder if you could make it dynamically generate the size based on the Scale property. That way you'd still be dealing with raster images, but no matter how big or small you made it, it would still be equally clear and not pixelated at all.

itsmattkc commented 5 years ago

@DaniSeeh I think that would be the ideal solution, it's composited as a raster image behind the scenes, but the user still gets the benefits of vector graphics. I think that could probably be done fairly simply.

ghost commented 5 years ago

it's composited as a raster image behind the scenes, but the user still gets the benefits of vector graphics.

And this is what I expect ;-)

Corruptinator commented 5 years ago

Nice idea. Could save trouble going into paint programs to upscale/repaint title cards. Also

it's composited as a raster image behind the scenes, but the user still gets the benefits of vector graphics.

I'm assuming it means that whenever the vector graphics are resized it regenerates the raster image right?

itsmattkc commented 5 years ago

@Corruptinator Indeed, the SVG handling code will need to regenerate the raster (and probably the OpenGL texture too) whenever the SVG is resized. Could be slow on larger SVGs, but the result is more or less true vector scaling.

alcomposer commented 5 years ago

@itsmattkc there is alwasy: https://github.com/memononen/nanosvg for converting SVG into raster.

Corruptinator commented 5 years ago

@itsmattkc, Maybe give the regenerated Vector a "Proxy/Low-Res" option? Have it set on the lowest settings to compensate for playback purposes. (Potentially useful for animation/keyframe purposes.) Then have it on high res upon exporting.

Corruptinator commented 5 years ago

I also didn't think about this but Regenerated Vector Image could be useful for Scrolling Credits at the end of movies or videos.

Edit: Using Inkscape or Vector painting program to put down the fonts and the tags of certain graphics like proprietary stuff you see at the end of movie credits.

alcomposer commented 5 years ago

@Corruptinator on the larger scale this also feeds into a 'resolution independent' workflow. Edit once, distribute to anything.

Corruptinator commented 5 years ago

This was found in my radar: https://github.com/RazrFalcon/resvg A new SVG library of some sort.

From its own Readme it says,

One of the major differences from other rendering libraries is that resvg does a lot of preprocessing before rendering. It converts shapes to paths, resolves attributes, removes groups and invisible elements, fixes a lot of issues in malformed SVG files. Then it creates a simple render tree with all elements and attributes resolved. And only then it starts to render. So it's very easy to implement a new rendering backend.

Just figured I give heads up that could become of relevance to this feature request.

DaniSeeh commented 5 years ago

Looks like that would make implementation of all this easy. Good find. I doubt it makes sense to do prior to the rendering engine rewrite being completed though. Any implementation would just mean more stuff to rewrite later presumably if it didn't fit with the new paradigm.

enzogianvittorio commented 5 years ago

Wonderful idea, Kdenlive has already this feature though does not render properly when exporting the video. The feature would be a great plus for OLIVE as we can complement the creative flow using Inkscape for logos shapes in layers etc in order to do great jobs of video compositing ... ;)

Corruptinator commented 5 years ago

Or scrolling credits, @enzogian.

enzogianvittorio commented 5 years ago

Has someone reported before that .SVG files are not able to be imported when working in Windows ? I've heard it does work fine in Linux but Windows does not.

ghost commented 5 years ago

Has someone reported before that .SVG files are not able

Olive NOT support import SVG yet, so for now this is not "Windows issue" ;-)

enzogianvittorio commented 5 years ago

Has someone reported before that .SVG files are not able

Olive NOT support import SVG yet, so for now this is not "Windows issue" ;-)

Ok, thanks a lot for your reply, then I think I got confused by this post in fb where someone used a SVG but not sure if he has tweaked the imported file somehow.... (he later mentioned something like a "plain svg"... ) https://www.facebook.com/100012237887371/videos/684900745261182/?query=svg&epa=SEARCH_BOX

Simran-B commented 5 years ago

Well, I just tried the following: renamed a PNG file to have an .svg extension, import it into Olive and drag it onto the timeline. It shows up as image.svg and displays corrects. Maybe the flag he imported is actually a raster image file but with an .svg extension?

ghost commented 5 years ago

Maybe the flag he imported is actually a raster image file but with an .svg extension?

FTR, raster image could be bundled into SVG-file. Maybe, that is what mentioned as "plain svg".

Simran-B commented 5 years ago

SVG files can reference and embed raster images, but they will still be SVG files. Examples:

Reference to local file

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   version="1.1"
>
    <image
       xlink:href="sample.jpg"
       y="10.947623"
       x="-58.6619"
       id="image4515"
       preserveAspectRatio="none"
       height="171.45"
       width="304.79999" />
</svg>

Embedded image

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   version="1.1"
>
    <image
       y="30.073215"
       x="34.565918"
       id="image4526"
       xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAMCAYAAAC5tzfZAAAABHNCSVQICAgIfAhkiAAAAMpJREFU
KJFj/P///38GJPDn6nWG/58+MTDy8TGwaGsyYAX/oeDfx4//P8Uk/X8rowLHH/1C/v+5ffc/OmCE
2fTR2ZPh7607GIYyqygx8O3YxMDIzg4XY2JgYGD4c+4CVg0MDAwMf+/cY/h94BCKGFwTPvD36nVM
Tf9//sSrCR0wMTAw4A4lmCJZGSyaLM0xJGCAkZ2dgdXBFlMTIzs7A8+UfgYmUVEMDVx9HZjiyJH7
/9Mnhp+r1sEjl83fG0MDhiZiAROpGhgYGBgAduJnjyAHslMAAAAASUVORK5CYII=
"
       preserveAspectRatio="none"
       height="3.175"
       width="3.4395833" />
</svg>

I tried both types but they do not work in Olive, they can't be dragged onto the timeline.

image

ghost commented 5 years ago

FTR, "SVG Native" coming

Simran-B commented 5 years ago

Do not use SVG Native for web content or as an interchange format between applications unless it is going to be processed by underlying platforms only.

So SVG Native is mostly meant for user interfaces. For example, if you want to display some vector shapes like an icon, e.g. a custom arrow head for a scrollbar widget. Performance is critical for UIs, but what we want in Olive is to be able to import arbitrary SVGs and render them correctly. I don't think that SVG Native cuts it, because it supports a small subset of SVG features only.

itsmattkc commented 3 years ago

Merging into #1054