FFMPEG input/output as an abstraction

I am currently working on writing code to support the usage pattern that I have used in the past for making animations using ffmpeg to encode video. Really though, how complex does it need to be?

Well, let’s put together a wish-list:

  1. It should always shut down the pipe at the end of execution
    It’s really easy to leave the pipes, and that makes it really easy to end up with empty animations, or, possibly, more substantial resource leaks.
  2. It should not require thinking about ffmpeg as a process, we’re writing lisp code, not shell.
  3. It shouldn’t be included in the base installation since it can’t reasonably install ffmpeg (I mean, it could, but, that’s a lot of work that’ll still leave people out in the cold in situations where none of the binaries available are appropriate)
  4. It should terminate gracefully if there’s no more input

There’s a bunch of problems here that make me wonder if it’s worth encapsulating this functionality, as I can’t think of any way to prevent the user from breaking it. Ultimately this is calling out to a shell, and thus it suffers from all the ways that shells fail in the user experience, but this one is presumed to be isolated in the semantics of common lisp, rather than shells.

The ‘correct’ way, would be to provide an abstraction that cannot be used to assemble incorrect commands. But at that point I might as well just get around to learning how to use sb-grovel and write the structures to interface with the library.

But that would be excessive for a simple use case, and it could easily be way less simple to use just by having to learn how to handle the structures that the library would provide.

So anyway, with the limitations that I have outlined in mind, I’m going to go with what I have so far, with-ffmpeg-input provides a way to get that png stream working from a single file parameter, handling closing down the process and the general housekeeping best kept in mind in a world with finite resources(but then I suppose we’re using lisp so who am I to speak on the costs of things 😉)

But I’m not sure that I like the abstraction enough to write a corresponding with-ffmpeg-output or some combination of the two.


Posted

in

,

by

Comments

Leave a Reply

Only people in my network can comment.