Some years ago I made a ffmpeg filter for using shadertoys in a libre software video pipeline. I use it extensively in my video essays and my video generation from text software, and given that from time to time ffmpeg’s API changes, once a year or so I do some mainteinance to my filter’s code in order for it to be still usable with newer ffmpeg versions. Today is one of those days, and just now I realize I never did a blog post about it. So, better late than never: here’s the blog post about the filter.
Most of the details about building or how to use it are already in the repo’s README file, so I’m not going to cover that here: just know you gotta build ffmpeg yourself, adding my code and some extra opengl libs.
What the readme doesn’t give you are proper examples of what you can do, which is the juicy part. Consider for example this command:
./ffmpeg -hide_banner -y -f lavfi -i "testsrc=1920x1080:r=30,format=yuv420p" \
-map 0 -vf "shadertoy=shadertoy_file=downloaded_shadertoy_code.glsl:start=5:duration=15" \
-c:v h264 -preset slow -b:v 8M -t 30 test_shadertoy_01.mp4
Which renders the following 30 seconds video:
That shadertoy in the example is “Protean Clouds”, by nimitz. You can just select all the shadertoy code, copy it, and save it inside a “downloaded_shadertoy_code.glsl” file. That’s it: that’s how you’re able to use a shadertoy with this filter.
That particular shadertoy is one of the many that renders some cool animation. In case you didn’t yet, please do browse shadertoy’s site and you’ll find some absolutely amazing work from many extremely talented people all around the world. There you’ll see lots and lots of “render shadertoys” (my terminology), and using my filter you can render them yourself as a video file or even some stream. I use that kind of shadertoys as backgrounds for my videos. And as a side note, take a look at the previous command and you’ll see that it adds the “start” and “duration” parameters to the filtergraph definition; that’s the reason the render starts at second 5 and ends at second 20, while the rest of the time the output simply shows the input video (the test screen instead of the clouds).
However, there are other kind of shadertoys around, with the role of applying…
continuar leyendo