Live data from Hacker News

StreamPot: Run FFmpeg as an API with fluent-FFmpeg compatibility, queues and S3

github.com

31–37 of 37 posts

Re: StreamPot: Run FFmpeg as an API with fluent-FFmpeg compatibility, queues and S3

#31

I see there's a paid version of Streampot. My understanding is the ffmpeg license is pretty restrictive, and doesn't allow for any commercial use unless you sign a contract with them. Is that something Streampot has done? Just wondering because I have looked into using ffmpeg in a commercial project and the license stopped me from doing so.

Its not ffmpeg, its the codecs you have to worry about - if your posting the video publicly that is.

Re: StreamPot: Run FFmpeg as an API with fluent-FFmpeg compatibility, queues and S3

#32
post #24

Earlier quoted context omitted.

That will also eventually be polling, within a kernel subsystem or library function that one has merely chosen to perceive as a black box for convenience of reasoning. Seriously, unless you know we’re delivering an interrupt or a signal, assume it’s polling all the way down. And I’m not so sure about the signals.

When my program is waiting to read from a network stream, or from a USB device, it uses 0% CPU and responds instantly when the signal comes in. That is how software should be. Maybe there's cases in the kernel where polling is unavoidable. But polling should happen as little as possible - for the sake of both latency and efficiency. I don't spend much time thinking about the kernel. In userland, polling is almost nev…

It isn’t.

Re: StreamPot: Run FFmpeg as an API with fluent-FFmpeg compatibility, queues and S3

#33

Specification of ffmpeg commands can get quite complex, especially once you get to filters. I never understood why it hasn't grown a DSL to specify the input/output/transformation. Could be JSON-based for what I care. Then we could have nice things like easy programmatic generation of these scripts and schema verification (for each particular ffmpeg version). Also, when I looked at how LosslessCut (an Electron app) d…

What do you mean? FFMpeg supports filters via its own DSL; see https://ffmpeg.guide/ or https://ffmpeg.org/ffmpeg-filters.html

It's not quite JSON and I have to look up the syntax every time I use it, but it's well-defined.

The general syntax is:

    [input1][input2]... filterchain [output1];
    [input3] filterchain [output2];
    ...
to specify chains of filters that link input streams to output streams.

For example, the following:

    ffmpeg -i INPUT -vf "
      split [main][tmp];
      [tmp] crop=iw:ih/2:0:0, vflip [flip];
      [main][flip] overlay=0:H/2
    " OUTPUT
is doing something like this (python pseudocode):

    main,tmp = input.split(2)
    flip = (tmp
       .crop(iw, ih/2, 0, 0)
       .vflip())
    out = overlay([main, flip], 0, H/2)
Here's a more complicated example (visualization on https://ffmpeg.guide/graph/demo ):

    ffmpeg -i ./long-video.mp4 
    -i ./background-music.mp3
    -filter_complex "[0:v]trim=duration=30[out0];
      [0:a]atrim=duration=15[out1];
      [out1][1:a]
         amix=inputs=2:duration=longest:
         dropout_transition=2:weights=1 1:
         normalize=1
      [out2]"
     -map "[out0]" -map "[out2]"
    ./shorter-video.mp4
Pseudocode:

    # input files (-i options)
    in0 = read("./long_video.mp4")
    in1 = read("./background_music.mp3")
    # filter graph
    out0 = in0.video.trim(duration=30)
    out1 = in0.audio.trim(duration=15)
    out2 = amix([out1, in1.audio],
        duration="longest", dropout_transition=2, 
        weights=[1,1], normalize=1)
    # output stream mapping
    out_stream[0] = out0
    out_stream[1] = out2

Re: StreamPot: Run FFmpeg as an API with fluent-FFmpeg compatibility, queues and S3

#34

Specification of ffmpeg commands can get quite complex, especially once you get to filters. I never understood why it hasn't grown a DSL to specify the input/output/transformation. Could be JSON-based for what I care. Then we could have nice things like easy programmatic generation of these scripts and schema verification (for each particular ffmpeg version). Also, when I looked at how LosslessCut (an Electron app) d…

Seems like writing a script wrapper around ffmpeg could easily solve the first problem. All it needs to do is to read in JSON/YAML/TOML/etc. then parse them into command line equivalents and call ffmpeg. That is a kind of script pretty much any coding LLM could generate.

I was watching a streamer trying to use ffmpeg in a streaming configuration and it didn't seem to work very well in that case. However, if someone was belligerent enough, I would guess it would be possible to use libavformat/libavcodec directly to parse out frames from video. For example, the streamer "sphaerophoria" posted a short series where he built a video editor from scratch [1]. I believe the code he wrote could be used as the basis for a custom-built editor to extract thumbnails from videos.

1. https://www.youtube.com/watch?v=l_hD99zpPBY&ab_channel=sphae...

Re: StreamPot: Run FFmpeg as an API with fluent-FFmpeg compatibility, queues and S3

#35

Specification of ffmpeg commands can get quite complex, especially once you get to filters. I never understood why it hasn't grown a DSL to specify the input/output/transformation. Could be JSON-based for what I care. Then we could have nice things like easy programmatic generation of these scripts and schema verification (for each particular ffmpeg version). Also, when I looked at how LosslessCut (an Electron app) d…

If they are such a heavy user why don't they just use libavcodec directly?

Re: StreamPot: Run FFmpeg as an API with fluent-FFmpeg compatibility, queues and S3

#36
post #28

I see there's a paid version of Streampot. My understanding is the ffmpeg license is pretty restrictive, and doesn't allow for any commercial use unless you sign a contract with them. Is that something Streampot has done? Just wondering because I have looked into using ffmpeg in a commercial project and the license stopped me from doing so.

I didn't even look at the website to see they offered a paid service. Looking now -- even aside from potential license issues -- at risk of making yet another HN Dropbox comment, I'm curious how viable that is as a business model. What's being offered here? Running ffmpeg on their servers? You'd figure anyone with a project with enough throughput for their "most popular" tier (5TB/month, 1000 requests/minute) and a b…

You're missing the fact that video encoding is a whole different ballgame when it comes to what kind of CPU or VM you need. Any crappy oversubscribed cloud VM can host a website. Meanwhile ffmpeg wants at least dedicated cores, preferably entire dedicated servers.

Streampot lets you send 300 requests per minute for the cost of the cheapest dedicated server instance on hetzner.

Re: StreamPot: Run FFmpeg as an API with fluent-FFmpeg compatibility, queues and S3

#37

This is great, I don't have a concrete use-case right now but can definitely see myself returning to this in the future. One thing that would be handy is having a way to either accept a ffmpeg cli command, or convert from a cli command to the typescript syntax. My experience with ffmpeg if you often do a lot of copying and pasting of commands from documentation or random guides, it'd save a bit of time if you didn't…

Thank you! We'll add it on our roadmap
Post reply on HN