In my latest side-project, I'm generating pretty animated pictures as a side effect. I want to show them off to a larger public, but publishing animated GIFs is somewhat disappointing as the GIFs are unreasonably large, weighing in at 10 MB or so.

I'm already using Prima and Imager or ScreenToGif to get the single frames for the animation, mostly as separate PNG images, and I'm looking for a good Perl API to combine the single frames into a .webm and .mp4 video to get vast gains of quality while vastly reducing file size at the same time. A quick test showed me a file size of 80kb for .webm with a file that was 7MB as a .gif.

Writing a script or module that runs ffmpeg over a set of frames is easy to do.

My main question is if there are known and used APIs for converting multiple still frames into an animation. Imager has the ->write_multi() API to write multiple frames to an animated .gif, and I could shim my "run-ffmpeg" module as another file type for Imager. But maybe there is a better API out there already?

What module do you use to combine multiple image frames into another file?

What module do you use to access single frames of a video?

Is somebody aware of ffmpeg as a statically linkable library so that instead of shelling out to ffmpeg, the black magic happens within Perl?

If there are no suggestions, I will likely try to implement the ffmpeg-writer as a filetype for Imager, much in the way that ImageMagick calls out to other modules.


In reply to Searching for an API for writing sequential images into a file ("Movie") by Corion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.