[HN Gopher] FFmpeg by Example
       ___________________________________________________________________
        
       FFmpeg by Example
        
       Author : piyushsthr
       Score  : 93 points
       Date   : 2025-01-14 09:58 UTC (13 hours ago)
        
 (HTM) web link (ffmpegbyexample.com)
 (TXT) w3m dump (ffmpegbyexample.com)
        
       | dheera wrote:
       | I just use LLMs to help me with ffmpeg (and many other similarly
       | complex tools) commands:
       | https://github.com/dheera/scripts/blob/master/helpme
       | $ helpme ffmpeg capture video from /dev/video0 every 1 second and
       | write to .jpg files like img00000.jpg, img00001.jpg, ...
       | $ helpme ffmpeg assemble all the .jpg files into an .mp4
       | timelapse video at 8fps         $ helpme ffmpeg recompress
       | myvideo.mp4 for HTML5-friendly use and save the result as
       | myvideo_out.webm
       | 
       | I know there are full blown AI terminals like Warp but I didn't
       | like the idea of a terminal app requiring a login, possibly
       | sending all my commands to a server, etc. and just wanted a
       | script that only calls the cloud AI when I ask it to.
        
         | trevor-e wrote:
         | Yea agreed, these kinds of websites feel obsolete now with
         | LLMs. I just tried a couple in ChatGPT and it worked
         | flawlessly.
        
           | dmonitor wrote:
           | Where do you think the LLMs get their ffmpeg commands from?
        
       | hbn wrote:
       | I've enjoyed using ffmpeg 1000% more since I was able to stop
       | doing manually the tedious task of Googling for Stack Overflow
       | answers and cobbling them into a command and got Chat GPT to
       | write me commands instead.
        
         | levocardia wrote:
         | For the longest time I had ffmpeg in the same bucket as regex:
         | "God I really need to learn this but I'm going to hate it so
         | much." Then ChatGPT came along and solved both problems!
        
           | hackingonempty wrote:
           | CSS has entered the ChatGPT.
        
         | juancroldan wrote:
         | Same here, it's one of these things were AI has taken over
         | completely and I'm just a broker that copy-pastes error traces.
        
         | magarnicle wrote:
         | My experience got even better once I learned how complex
         | filters worked.
        
       | ge96 wrote:
       | ffmpeg is so goated, I used it to merge video/audio from a mic on
       | a camera I made ha
       | 
       | there was one time I didn't use pyaudio correctly so I was using
       | this process where ffmpeg can stitch multiple audio files
       | together into one passed in as an array cli argument, crazy
        
       | jazzyjackson wrote:
       | This reminds me I need to publish my write up on how I've been
       | converting digitized home video tapes into clips using scene
       | detection, but in case anyone is googling for it, here's a gist I
       | landed on that does a good job of it [0] but sometimes it's
       | fooled by e.g. camera flashes or camera shake so I need to give
       | it a start and end file and have ffmpeg concatenate them back
       | together [1]
       | 
       | Weird thing is I got better performance without "-c:v
       | h264_videotoolbox" on latest Mac update, maybe some performance
       | regression in Sequoia? I don't know. The equivalent flag for my
       | windows machine with Nvidia GPU is "-c:v h264_nvenc" . I wonder
       | why ffmpeg doesn't just auto detect this? I get about 8x
       | performance boost from this. Probably the one time I actually
       | earned my salary at work was when we were about to pay out the
       | nose for more cloud servers with GPU to process video when I
       | noticed the version of ffmpeg that came installed on the machines
       | was compiled without GPU acceleration !
       | 
       | [0]
       | https://gist.githubusercontent.com/nielsbom/c86c504fa5fd61ae...
       | 
       | [1]
       | https://gist.githubusercontent.com/jazzyjackson/bf9282df0a40...
        
         | rahimnathwani wrote:
         | -c:v h264_nvenc
         | 
         | This is useful for batch encoding, when you're encoding a lot
         | of different videos at once, because you can get better
         | encoding throughput.
         | 
         | But in my limited experiments a while back, I found the output
         | quality to be slightly worse than with libx264. I don't know if
         | there's a way around it, but I'm not the only one who had that
         | experience.
        
           | xnx wrote:
           | Co-signing. Encode time was faster with nvenc, but quality
           | was noticeably worse even to my untrained eye.
        
             | jazzyjackson wrote:
             | Fascinating, it didn't occur to me quality could take a
             | hit, I thought the flag merely meant "perform h264 encoding
             | over here"
             | 
             | Edit: relevant docs from ffmpeg, they back up your
             | perception, and now I'm left to wonder how much I want to
             | learn about profiles in order to cut up these videos. I
             | suppose I'll run an overnight job to reencode them from Avi
             | to h264 at high quality, and make sure the scene detect
             | script is only doing copys, not reencoding, since that's
             | the part I'm doing interactively, there's no real reason I
             | should be sitting at the computer while its transcoding.
             | 
             |  _Hardware encoders typically generate output of
             | significantly lower quality than good software encoders
             | like x264, but are generally faster and do not use much CPU
             | resource. (That is, they require a higher bitrate to make
             | output with the same perceptual quality, or they make
             | output with a lower perceptual quality at the same
             | bitrate.)_
             | 
             | [0] https://trac.ffmpeg.org/wiki/HWAccelIntro
        
       | cb321 wrote:
       | While it does have a rather unusual/bespoke command syntax
       | (strongly motivating TFA), lately ffmpeg works my webcam more
       | reliably than Google chrome. Too bad my other-side conversations
       | don't have things set up to negotiate a session with it!
        
       | nickdothutton wrote:
       | FFmpeg is one of those tools I need to use so infrequently that
       | he exact syntax never seems to stick. I've resorted to using an
       | LLM to give me the command line I need. The only other tool that
       | I ever had trouble with was 1990s-era MegaCLI from LSI Logic,
       | also something I barely used from one year to the next (but one
       | where you really need to get it right under pressure).
        
         | daveslash wrote:
         | Same. The only thing that sticks is converting from format X to
         | .mp4. Everything else I need to look up every single time.
         | 
         | Relevant XKCD https://xkcd.com/1168/
        
         | escapecharacter wrote:
         | I've just maintained my own note doc, going on 15 years now, of
         | my most commonly used syntax. When that fails, I grep my bash
         | history.
        
         | pseudosavant wrote:
         | I've been using FFMPEG for 15+ years, and still can't remember
         | almost any commands. LLMs have been amazing for using FFMPEG
         | though. ChatGPT and Claude do wonders with "give me an ffmpeg
         | command that will remux a video into mkv, include subtitle.srt
         | in the file, and I only want it between 0:00:05 and 0:01:00."
         | It produced this in case you were wondering: `ffmpeg -i
         | input.mp4 -i subtitle.srt -ss 00:00:05 -to 00:01:00 -map 0 -map
         | 1 -c copy -c:s mov_text output.mkv`
         | 
         | I wonder how small of an LLM you could develop if you only
         | wanted to target creating ffmpeg commands. Perhaps it could be
         | small enough to be hosted on a static webpage where it is run
         | locally?
        
           | porterde wrote:
           | Perhaps small enough to include in ffmpeg itself so you can
           | just write commands `ffmpeg do this thing I want`.
           | 
           | Now I say this, it seems like there should already be a shell
           | that is also an LLM where you can mix bits of commands you
           | vaguely remember and natural language a bit like Del Boy
           | speaking French...
        
       | fastily wrote:
       | Nice! This reminds me of my own ffmpeg cheatsheet; I would
       | imagine that everyone who uses ffmpeg frequently has a similar
       | set of notes
       | 
       | https://github.com/fastily/cheatsheet/blob/master/ffmpeg.md
        
         | efortis wrote:
         | FWIW, mine: https://github.com/ericfortis/quick-
         | reference/blob/main/ffmp...
        
       | mahdihabibi wrote:
       | Now I know what to read over the next weekend!
        
       | bugglebeetle wrote:
       | Somebody please pay people to create sites like this so LLMs can
       | train on them and I never have to spend time thinking about
       | arcane FFMPEG commands ever again. I remember losing whole days
       | in the before times trying to figure out how to make FFMPEG do
       | some highly specific set of things.
        
       | merksoftworks wrote:
       | ffmpeg has always felt like a gui application crammed into tui
       | format. I've had the displeasure of using the C api a few times,
       | while it's straight forward in many respects, it makes invalid
       | states extremely easy to represent. I would love a realtime AV1
       | encoding framework that "just works".
        
       | alpb wrote:
       | I love "X by Example" sites! But if you don't work with a tool
       | like ffmpeg imagemagick day in and out, there's no way you'll
       | remember their unintuitive syntax or will want to spend the time
       | to get your one-time job done. I'd still probably not use this
       | site to scan a dozen of examples and try to put together the
       | pieces of the puzzle; instead, I'd probably just use an LLM who
       | already scanned the entire web corpus and can probably get me to
       | a solution faster, right? At that point, I wonder what folks get
       | out of this site?
        
       ___________________________________________________________________
       (page generated 2025-01-14 23:00 UTC)