logoalt Hacker News

utopiah11/04/20258 repliesview on HN

Have to admit, ffmpeg syntax is not trivial... but also the project is 24 years old and is basically the defacto industry standard. If you believe you will still be editing videos in 20 years with the CLI (or any other tool or any programming language) wrapping it then it's probably worth few hours learning how it actually works.


Replies

esperent11/04/2025

The syntax isn't too bad. The problem is that I have to use it a couple of times a year, on average. So every time I've forgotten and have to relearn. This doesn't happen with GUIs nearly as much, and it's why I prefer them over CLI tools for anything that I don't do at least once every week or two.

show 1 reply
Sean-Der11/04/2025

My question/curiosity is why do so many people use ffmpeg (frustrated by the syntax) when GStreamer is available?

`gst-launch-1.0 filesrc ! qt4demux ! matroskamux ! filesink...` people would be less frustrated maybe?

People would also learn a little more and be less frustrated when conversation about container/codec/colorspace etc... come up. Each have a dedicated element and you can better understand its I/O

show 3 replies
jack_pp11/04/2025

I agree, I suggest using this instead : https://github.com/kkroening/ffmpeg-python . While not perfect once you figure it out it is far easier to use and you can wrap more complicated workflows and reuse them later.

show 1 reply
artpar11/04/2025

I think that goes with almost every tool you want to use with llm. User should already know the tool ideally so mistakes by llm can be prevented before they happen.

Here making ffmpeg as "just another capability" allows it to be stitched together in workflows

shardullavekar11/04/2025

true, companies like Descript, Veed, or Kapwing exist because no coders find this syntax intimidating. Plus, a CLI tool stands out of a workflow. We wanted to change that.

show 1 reply
javier211/04/2025

ffmpeg is pretty complicated, but at least it actually works.

somat11/04/2025

The thing that helped me get over that ffmpeg bump, where you go from copying stack overflow answers to actually sort of understanding what you are doing is the fairly recent include external file syntax. On the surface it is such a minor thing, but mentally it let me turn what was a confusing mess into a programing language. There are a couple ways to evoke it but the one I used was to load the whole file as an arg. Note the slash, it is important "-/filter_complex filter_file"

https://ffmpeg.org/ffmpeg-filters.html#toc-Filtergraph-synta...

"A special syntax implemented in the ffmpeg CLI tool allows loading option values from files. This is done be prepending a slash ’/’ to the option name, then the supplied value is interpreted as a path from which the actual value is loaded."

For how critical that was to getting over my ffmpeg hump, I wish it was not buried halfway through the documentation, but also, I don't know where else it would go.

And just because I am very proud of my accomplishment here is the ffmpeg side of my project, motion detection using mainly ffmpeg, there is some python glue logic to watch stdout for the events but all the tricky bits are internal to ffmpeg.

The filter(comments are added for audience understanding):

    [0:v]
    split  #split the camera feed into two parts, passthrough and motion
        [vis],
    scale=   #scale the motion feed way down, less cpu and it works better
        w=iw/4:
        h=-1,
    format= #needed because blend did not work as expected with yuv
        gbrp,
    tmix= #temporial blur to reduce artifacts
        frames=2,
    [1:v]  #the mask frame
    blend= #mask the motion feed
        all_mode=darken,
    tblend= #motion detect actual, the difference from the last frame
        all_mode=difference,
    boxblur= #blur the hell out of it to increase the number of motion pixels
        lr=20,
    maskfun= #mask it to black and white
        low=3:
        high=3,
    negate, #make the motion pixels black
    blackframe= #puts events on stdout when too many black pixels are found
        amount=1
        [motion]; #motion output
    [vis] 
    tpad= #delay pass through so you get the start of the event when notified
        start=30
        [original]; #passthrough output
and the ffmpeg evocation:

    ff_args = [
      'ffmpeg',
      '-nostats',
      '-an',
      '-i',
      camera_loc, #a security camera
      '-i',
      'zone_all.png', # mask as to which parts are relavent for motion detection
      '-/filter_complex',
      'motion_display.filter', #the filter doing all the work
      '-map',  #sort out the outputs from the filter
      '[original]',
      '-f',
      'mpegts', #I feel a little weied using mpegts but it was the best "streaming" of all the formats I tried
      'udp://127.0.0.1:8888',  #collect the full video from here
      '-map',
      '[motion]',
      '-f',
      'mpegts',
      'udp:127.0.0.1:8889', #collect the motion output from here, mainly for debugging
      ]
sexyman4811/04/2025

[dead]