Had a novel (to me) idea for an application, want to build it in Rust, what are the steps?

Hi Guys,

So I had an idea to help me make videos, I want to build a command line app where I feed it some text and it produces for me a video. It would be great if I had some control over the formatting too, maybe I could just input a html file or something similar with <h1> style tags, etc.

I want it to be in rust because I know it, I like it, and since this is a personal project, It can be, and later I can make modifications to my tastes, for example an algorithm that counts words, and increases decreases the video length based on number of words, etc.

But I'm a little lost as to what the steps are from conception to production.

I guess I need to have a look at what kind of crates are available to me already, and then fill in the blanks. Any guidance from the more experienced computer wizards around here?

I can’t give much Rust-centric advice here, but I have done a bit of graphics programming before. Generally, you want to start with the simplest possible “working” program. Then add capabilities one at a time, verifying that each works before moving on to the next. These steps will feel excruciatingly small at first. If this were my project, I’d look at something like this for the initial series of goals:

  1. Produce a 1-frame video file with a completely black picture
  2. Produce a 1-second video with a black picture
  3. Make the color something other than black
  4. Make different frames different colors
  5. Make the frame black on the left half and colored on the right half
  6. Animate the two-tone picture above so the dividing line wipes across the screen
  7. Draw some simple geometric shapes
  8. Put a photo from a file into the video
  9. (and onwards) Learn about fonts and text rendering
1 Like

That was actually surprisingly helpful, thank you! Last night it felt like such an easy idea when I was telling it to myself, now I actually began to sit down with the task, i feel lost!

I also like the idea of beginning at the end (the outputted video file) and working backwards.

Speaking of which, how do I produce a video file!?

That’s the Rust-specific part that I can’t give much advice on. Generally speaking, you’ll produce a picture in memory for each frame, hand them to a video encoder that turns them into something like H.264, and then wrap that in some kind of container format. The encoder, and probably the container format, will almost certainly be provided by some external library (often ffmpeg). Hopefully you can find one that already has Rust bindings.

Audio is a separate world that I haven’t worked with much. It gets processed by a different encoder, and then the encoded audio data goes in the same container as the video data.

hmmm, I did see an ffmpeg bindings library on crates.io.

ffmpeg can also make videos from images.. So I guess I want to just make an image from text now :slight_smile:

Turning "text" into a video is a little vague, can you articulate what sort of textual input the user would give this tool and what the result should look like?

A big part of creating a project is gathering requirements and nailing down the scope so you know what you are aiming for. Once you know that, you can go down @2e71828's list implementing small pieces one step at a time.


I don't know what by textual types you mean, i'm thinking something like $ text2image --text "hello world" -w 720 -h 460

Although now I'm thinking (you're right, my thoughts are premature), what would really be badass would be to supply html/css and it outputs the webpage as an image (maybe a video where the page scrolls or paginates if the text overflows). Maybe one of the browsers can already do that? Maybe i can hack webview or electron or something like that to do it.

I know fantoccini, an implementation of the WebDriver protocol, can spin up a browser and tell it to open a particular page, then ask for a screenshot of whatever is in view.

Maybe that could help.

1 Like

Have you by chance seen the xscreensaver font_glide? This is what came into my mind when I read your description.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.