Remix.run Logo
Culonavirus 4 days ago

> incantation

FFmpeg arguments, the original prompt engineering

mrandish 4 days ago | parent | next [-]

I'd also include Regex in the list of dark arts incantations.

RedShift1 4 days ago | parent | next [-]

I'm ok with regex, but the ffmpeg manpage, it scares me...

quectophoton 4 days ago | parent [-]

Ffmpeg was designed to be unusable if it falls into enemy hands.

falloon 2 days ago | parent [-]

I defer understanding FFMPEG arguments to the LLMs.

zvr 4 days ago | parent | prev | next [-]

I am perfectly at home with regexp, but ffmpeg, magick, and jq are still on the list to master.

lukeschlather 3 days ago | parent | prev [-]

Regex is only difficult because it's complicated, the primitives are all sensibly arranged and predictable. FFmpeg is layers of dark magic where the primitives are often inscrutable before you compose them.

Keyframe 4 days ago | parent | prev | next [-]

with gemini-cli and claude-cli you can now prompt while it prompts ffmpeg, and it does work.

conradev 4 days ago | parent | next [-]

Yeah, you can give an LLM queries like “make this smaller with libx265 and add the hvc1 tag” or “concatenate these two videos” and it usually crushes it. They have a similar level of mastery over imagemagick, too!

turnsout 4 days ago | parent | next [-]

Yeah, LLMs have honestly made ffmpeg usable for me, for the first time. The difficulty in constructing commands is not really ffmpeg's fault—it's just an artifact of the power of the tool and the difficulties in shoehorning that power into flags for a single CLI tool. It's just not the ideal human interface to access ffmpeg's functionality. But keeping it CLI makes it much more useful as part of a larger and often automated workflow.

lukeschlather 3 days ago | parent | prev [-]

It's funny because GPU stuff like what this article is about is where the LLMs totally fall apart. I can make any LLM produce volumes hallucinations at the drop of a hat by asking it how to construct ffmpeg commands that use hardware acceleration.

profsummergig 4 days ago | parent | prev | next [-]

Just seeking a clarification on how this would be done:

One would use gemini-cli (or claude-cli),

- and give a natural language prompt to gemini (or claude) on what processing needs to be done,

- with the correct paths to FFmpeg and the media file,

- and g-cli (or c-cli) would take it from there.

Is this correct?

logicalmind 4 days ago | parent | next [-]

Another option is to use a non-cli LLM and ask it to produce a script (bash/ps1) that uses ffmpeg to do X, Y, and Z to your video files. If using a chat LLM it will often provide suggestions or ask questions to improve your processing as well. I do this often and the results are quite good.

RedShift1 4 days ago | parent | prev [-]

Yes. It works amazingly well for ffmpeg.

profsummergig 4 days ago | parent [-]

Thank you.

NSUserDefaults 4 days ago | parent | prev [-]

Curious to see how quickly each LLM picks up the new codecs/options.

stevejb 4 days ago | parent | next [-]

I use the Warp terminal and I can ask it to run —-help and it figures it out

baq 4 days ago | parent | prev [-]

the canonical (if that's the right word for a 2-year-old technique) solution is to paste the whole manual into the context before asking questions

xnx 4 days ago | parent [-]

Gemini can now load context from a URL in the API (https://ai.google.dev/gemini-api/docs/url-context), but I'm not sure if that has made it to the web interfaces yet.

agos 4 days ago | parent | prev | next [-]

OT, but yours has to be the best username on this site. Props.

bobsmooth 4 days ago | parent [-]

Culón is Spanish for big-bottomed, for anyone else wondering.

jeanlucas 4 days ago | parent | prev [-]

nope, that would be handling tar balls

ffmpeg right after

beala 4 days ago | parent | next [-]

Tough crowd.

fwiw, `tar xzf foobar.tgz` = "_x_tract _z_e _f_iles!" has been burned into my brain. It's "extract the files" spoken in a Dr. Strangelove German accent

Better still, I recently discovered `dtrx` (https://github.com/dtrx-py/dtrx) and it's great if you have the ability to install it on the host. It calls the right commands and also always extracts into a subdir, so no more tar-bombs.

If you want to create a tar, I'm sorry but you're on your own.

diggan 4 days ago | parent | next [-]

I used tar/unzip for decades I think, before moving to 7z which handles all formats I throw at it, and have the same switch for when you want to decompress into a specific directory, instead of having to remember which one of tar and unzip uses -d, and which one uses -C.

"also always extracts into a subdir" sounds like a nice feature though, thanks for sharing another alternative!

mkl 3 days ago | parent | prev [-]

> tar xzf foobar.tgz

You don't need the z, as xf will detect which compression was used, if any.

Creating is no harder, just use c for create instead, and specify z for gzip compression:

  tar czf archive.tar.gz [filename(s)]
Same with listing contents, with t for tell:

  tar tf archive.tar.gz
porridgeraisin 4 days ago | parent | prev | next [-]

Personally I never understood the problem with tar balls.

The only options you ever need are tar -x, tar -c (x for extract and c for create). tar -l if you wanna list, l for list.

That's really it, -v for verbose just like every other tool if you wish.

Examples:

  tar -c project | gzip > backup.tar.gz
  cat backup.tar.gz | gunzip | tar -l
  cat backup.tar.gz | gunzip | tar -x
You never need anything else for the 99% case.
BeepInABox 4 days ago | parent | next [-]

For anyone curious, unless you are running a 'tar' binary from the stone ages, just skip the gunzip and cat invocations. Replace .gz with .xz or other well known file ending for different compression.

  Examples:
    tar -cf archive.tar.gz foo bar  # Create archive.tar.gz from files foo and bar.
    tar -tvf archive.tar.gz         # List all files in archive.tar.gz verbosely.
    tar -xf archive.tar.gz          # Extract all files from archive.tar.gz
mkl 3 days ago | parent [-]

> tar -cf archive.tar.gz foo bar

This will create an uncompressed .tar with the wrong name. You need a z option to specify gzip.

Intermernet 3 days ago | parent [-]

Apparently this is now automatically determined by the file name, but I still habitually add the flag. 30 years of muscle memory is hard to break!

mkl 3 days ago | parent [-]

I tried it to check before making the comment. In Ubuntu 25.04 it does not automatically enable compression based on the filename. The automatic detection when extracting is based on file contents, not name.

BenjiWiebe 3 days ago | parent [-]

If you add a for auto, it will choose the right compression based on the file name.

tar -caf foo.tar.xz foo

Will be an xz compressed tarball.

sdfsdfgsdgg 4 days ago | parent | prev | next [-]

> tar -l if you wanna list, l for list.

Surely you mean -t if you wanna list, t for lisT.

l is for check-Links.

     -l, --check-links
             (c and r modes only) Issue a warning message unless all links to each file are archived.
And you don't need to uncompress separately. tar will detect the correct compression algorithm and decompress on its own. No need for that gunzip intermediate step.
porridgeraisin 4 days ago | parent [-]

> -l

Whoops, lol.

> on its own

Yes.. I'm aware, but that's more options, unnecessary too, just compose tools.

sdfsdfgsdgg 4 days ago | parent [-]

That's the thing. It’s not more options. During extraction it picks the right algorithm automatically, without you needing to pass another option.

tombert 4 days ago | parent | prev | next [-]

Yeah I never really understood why people complain about tar; 99% of what you need from it is just `tar -xvf blah.tar.gz`.

CamperBob2 4 days ago | parent | next [-]

What value does tar add over plain old zip? That's what annoys me about .tar files full of .gzs or .zips (or vice versa) -- why do people nest container formats for no reason at all?

I don't use tape, so I don't need a tape archive format.

diggernet 4 days ago | parent | next [-]

A tar of gzip or zip files doesn't make sense. But gzipping or zipping a tar does.

Gzip only compresses a single file, so .tar.gz lets you bundle multiple files. You can do the same thing with zip, of course, but...

Zip compresses individual files separately in the container, ignoring redundancies between files. But .tar.gz (and .tar.zip, though I've rarely seen that combination) bundles the files together and then compresses them, so can get better compression than .zip alone.

beagle3 4 days ago | parent | prev | next [-]

The zip directory itself is uncompressed, and if you have lots of small files with similar names, zipping the zip makes a huge difference. IIRC in the HVSC (C64 SID music archive), the outer zip used to save another 30%.

fullstop 4 days ago | parent | prev | next [-]

zip doesn't retain file ownership or permissions.

diggernet 4 days ago | parent [-]

Good point. And if I remember right, tar allows longer paths than zip.

dns_snek 3 days ago | parent | prev [-]

Plain old zip is tricky to parse correctly. If you search for them, you can probably find about a dozen rants about all the problems of working with ZIP files.

aidenn0 4 days ago | parent | prev [-]

You for got the -z (or -a with a recent gnutar).

adastra22 4 days ago | parent [-]

It’s no longer needed. You can leave it out and it auto-detects the file format.

drivers99 4 days ago | parent | prev | next [-]

Except it's tar -t to list, not -l

porridgeraisin 4 days ago | parent [-]

Whoops, lol. Well that's unfortunate.

themafia 3 days ago | parent | prev | next [-]

    gzip -dc backup.tar.gz | tar -x
You can skip a step in your pipeline.
bigstrat2003 4 days ago | parent | prev | next [-]

The problem is it's very non-obvious and thus is unnecessarily hard to learn. Yes, once you learn the incantations they will serve you forever. But sit a newbie down in front of a shell and ask them to extract a file, and they struggle because the interface is unnecessarily hard to learn.

encom 4 days ago | parent [-]

It's very similar to every other CLI program, I really don't understand what kind of usability issue you're implying is unique to tar?

mrguyorama 4 days ago | parent [-]

As has been clearly demonstrated in this very thread, why is "Please list what files are in this archive" the option "-t"?

Principle of least surprise and all that.

encom 4 days ago | parent [-]

And why is -v the short option for --invert-match in grep, when that's usually --verbose or --version in lots of other places. These idiosyncrasies are hardly unique to tar.

jeanlucas 4 days ago | parent | prev [-]

it was just a reference to xkcd#1168

I wasn't expecting the downvotes for an xkcd reference

fullstop 4 days ago | parent | prev | next [-]

I have so much of tar memorized. cpio is super funky to me, though.

fuzztester 3 days ago | parent [-]

cpio is not that hard.

A common use case is:

  $ cpio -pdumv args 
See:

  $ man cpio 
and here is an example from its Wikipedia page, under the "Operation and archive format" section, under the Copy subsection:

Copy

Cpio supports a third type of operation which copies files. It is initiated with the pass-through option flag (p). This mode combines the copy-out and copy-in steps without actually creating any file archive. In this mode, cpio reads path names on standard input like the copy-out operation, but instead of creating an archive, it recreates the directories and files at a different location in the file system, as specified by the path given as a command line argument.

This example copies the directory tree starting at the current directory to another path new-path in the file system, preserving files modification times (flag m), creating directories as needed (d), replacing any existing files unconditionally (u), while producing a progress listing on standard output (v):

$ find . -depth -print | cpio -p -dumv new-path

fullstop 2 days ago | parent [-]

I think that it's the fact that it requires a pipe to work and that you add files by feeding stdin that throw me for a loop.

I also use it very infrequently compared to tar -- mostly in conjunction with swupdate. I've also run into file size limits, but that's not really a function of the command line interface to the tool.

sho_hn 4 days ago | parent | prev [-]

nope, it's using `find`.