News for hackers. Stuff that matters.
Re:FFmpeg by Example by hbn on Tuesday January 14, 2025 @04:37PM (#42704234)
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.
Re:FFmpeg by Example by simonw on Tuesday January 14, 2025 @06:53PM (#42705589)
I use ffmpeg multiple times a week thanks to LLMs. It's my top use-case for my "llm cmd" tool:

  uv tool install llm
  llm install llm-cmd

  llm cmd use ffmpeg to extract audio from myfile.mov and save that as mp3
https://github.com/simonw/llm-cmd
Re:FFmpeg by Example by resonious on Tuesday January 14, 2025 @07:31PM (#42705897)
I tried this (though with a different tool called aichat) for extremely simple stuff like just "convert this mov to mp4" and it generated overly complex commands that failed due to missing libraries. When I removed the "crap" from the commands, they worked.

So much like code assistance, they still need a fair amount of baby sitting. A good boost for experienced operators but might suck for beginners.

Re:FFmpeg by Example by Philpax on Tuesday January 14, 2025 @08:11PM (#42706157)
Hate to be that guy, but which LLM was doing the generation? GPT-4 Turbo / Claude 3.x have not really let me down in generating ffmpeg commands - especially for basic requests - with most of their failures resulting from domain-specific vagaries that an expert would need to weigh in on m
Re:FFmpeg by Example by th0ma5 on Tuesday January 14, 2025 @08:52PM (#42706419)
Hate to be that guy, but which model works without fail for any task that ffmpeg can do?
Re:FFmpeg by Example by iameli on Tuesday January 14, 2025 @09:04PM (#42706483)
"Writing working commands first try for every single ffmpeg feature that exists" is the highest bar I've ever heard of, I love it. I'm gonna start listing it as a requirement on job postings. Like an ffmpeg speedrun.
Re:FFmpeg by Example by MzxgckZtNqX5i on Wednesday January 15, 2025 @03:48AM (#42708777)
Obligatory xkcd: https://xkcd.com/1168/.
Re:FFmpeg by Example by hk__2 on Wednesday January 15, 2025 @04:11AM (#42708927)
To be fair `tar` is quite easy to use once you understand the grammar of the options.
Re:FFmpeg by Example by th0ma5 on Wednesday January 15, 2025 @01:59PM (#42715410)
Yes and every failure of a product turns into a support ticket.
Re:FFmpeg by Example by Philpax on Tuesday January 14, 2025 @09:09PM (#42706515)
I don't think there's a single human on or outside of this planet that can meet that requirement, but Claude has been pretty good to me. It's certainly a much better starting point than pouring over docs and SO posts.
Re:FFmpeg by Example by th0ma5 on Wednesday January 15, 2025 @02:00PM (#42715420)
In my experience you still get a lot of stuff that used to work or stuff that it just makes up.
Re:FFmpeg by Example by bloqs on Tuesday January 14, 2025 @09:17PM (#42706563)
This doesnt exist in reality so in one sense, you could challenge the relevance
Re:FFmpeg by Example by th0ma5 on Wednesday January 15, 2025 @02:01PM (#42715443)
I think in the non LLM world though you at least have the trail of documentation you can unwind once you're in a bind. I don't care for prompt-a-mole fighting.
Re:FFmpeg by Example by AuryGlenz on Wednesday January 15, 2025 @03:02AM (#42708504)
I know I struggled on getting a good command to “simply” make the videos from my Z8 smaller (in file size).

Usually the color was wrong and I don’t care enough to learn about colorspaces to figure out how to fix it and it’s utterly insane how difficult it is even with LLMs.

Just reencode it as is but a little more lossy. Is that so hard?

Re:FFmpeg by Example by latexr on Wednesday January 15, 2025 @05:44AM (#42709493)
Handbrake may be a better option for you. I find that for some tasks it’s not only simpler but straight up works better than FFmpeg.

https://handbrake.fr/docs/en/latest/cli/cli-options.html

Re:FFmpeg by Example by resonious on Tuesday January 14, 2025 @09:39PM (#42706688)
GPT-4
Re:FFmpeg by Example by Philpax on Tuesday January 14, 2025 @10:23PM (#42706955)
Fair enough. If you remember what you were testing with, I'd love to try it again to see if things are better now.
Re:FFmpeg by Example by Over2Chars on Tuesday January 14, 2025 @10:34PM (#42707018)
You have a fair point. Some LLMs are better at some tasks, and prompts can make a difference no doubt.

Perhaps at some point there will be a triage LLM to slurp up the problem and then decide which secondary LLM is most optimal for that query, and some tertiary LLMs that execute and evaluate it in a virtual machine, etc.

Maybe someday

Re:FFmpeg by Example by NavinF on Tuesday January 14, 2025 @11:02PM (#42707185)
Oh I talked to some guys who started a company that does that. This was at an AI meetup in SF last year. They were mainly focused on making $/token cheaper by directing easy/dumb queries to smaller dumber models, but it also increases output quality because some models are just better at certain things. I'm sure all the big companies already have implementations of this by now even if they don't use it everywhere
Re:FFmpeg by Example by Over2Chars on Tuesday January 14, 2025 @11:47PM (#42707425)
I was suggesting optimizing for answer quality, but optimizing for cost might be useful too I suppose for "business innovation" purposes.
Re:FFmpeg by Example by jazzyjackson on Friday January 17, 2025 @02:24PM (#42742233)
Yes they are called routers. One is https://withmartian.com/
Re:FFmpeg by Example by sdesol on Tuesday January 14, 2025 @09:29PM (#42706638)
> "convert this mov to mp4"

Did any of the commands look like the ones in the left window:

https://beta.gitsense.com/?chats=12850fe4-ffb1-4618-9215-c13...

The left window contains a summary of all the LLMs asked, including all commands. The right window contains the individual LLM responses.

I asked about gotchas with missing libraries as well, and Sonnet 3.5 said there were. Were these the same libraries that were missing for you?

Re:FFmpeg by Example by resonious on Tuesday January 14, 2025 @09:40PM (#42706702)
Looking at this, I am pretty sure I also received a "libx264" clause. Removing it made the command work for me.
Re:FFmpeg by Example by sdesol on Tuesday January 14, 2025 @10:23PM (#42706952)
I don't disagree that we need to be cautious with LLMs, but I've personally stopped asking GPT-4/GPT-4 mini for technical answers. Sonnet 3.5 and DeepSeek V3 (which is much cheaper but still not as good as Sonnet) are your best bet for technical questions.

Where I find GPT to perform better than Sonnet is with text processing. GPT seems to better understand what I want when it comes to processing documents.

I'm convinced that no LLM provider has created or will create a moat, and that we will always need to shop around for an answer.

Re:FFmpeg by Example by wegfawefgawefg on Wednesday January 15, 2025 @12:10AM (#42707545)
everyone stopped using 4/4mini because theyre old.

4o replaced 4 back in April 2024. 01/01mini replaced 4o in Fall 2024.

stop using 4. use 01mini always. its cheaper, faster, and better.

o1/o1mini will be replaced by o3/o3mini in a couple months.

Re:FFmpeg by Example by sdesol on Wednesday January 15, 2025 @12:43AM (#42707712)
Unfortunately you need to be tier 2 to use o1-mini. The only time I really use GPT is to summarize documents and for that, GPT-4o mini works well enough and it is significantly cheaper than other high quality models, so I never really rack up an OpenAI bill.
Re:FFmpeg by Example by mistercheph on Wednesday January 15, 2025 @07:26AM (#42710124)
o1 is such a joke, worse than 4o in some ways like multiturn,

The months old sonnet feels a generation ahead of any OAI product I've used, I'll believe the hype on o3 when I see it, remember the sora and voice roll out?

Re:FFmpeg by Example by Philpax on Wednesday January 15, 2025 @10:22AM (#42711868)
o1 is not a general-purpose model, and it's not very good at multi-turn; it should instead be given all the context upfront: https://www.latent.space/p/o1-skill-issue
Re:FFmpeg by Example by wegfawefgawefg on Wednesday January 15, 2025 @11:47AM (#42713350)
You may want to reconsider this position.

I had this bizarre bug in rust networking code where packets were getting dropped.

i dumped all 20k lines into o1pro. it thought for about ten minutes and came back telling me that my packets had a chance of being merged if set in quick succession and i needed to send the length before each message and scan packets in a loop for subdivisions on the client. this bug hadnt happened before, only when running locally on a newer faster machine, and was frequent but hard to replicate.

it was correct, and provided detailed pseudo code to solve it.

the second case involved some front end code where during an auth flow ios would force refresh on returning to the browser causing authentication state to be lost. o1pro thought for about 5 minutes before telling me ios has a heuristic with which it decides to close an app on context switch based on available ram, etc, and that i needed to conditionally check for ios and store partial state in local store on leave assuming the app could be deloaded without my control.

it was correct. with some more back and forth we fixed the bug.

these are not the kinds of problems that claude and gpt<4 have been able to help with at all.

I also used voice, and video voice extensively for translation tasks in korea, japan, and taiwan, and for controlling japanese interfaces and forms for tax documents and software.

These are very good tools.

Re:FFmpeg by Example by jack_pp on Tuesday January 14, 2025 @11:26PM (#42707290)
libx264 is the best encoder for h264 ffmpeg has to offer so it's pretty important you bundle it in your ffmpeg install. Those commands are perfectly standard, I've been using something like that for 10+ years
Re:FFmpeg by Example by Over2Chars on Tuesday January 14, 2025 @10:31PM (#42707008)
My feelings exactly, but I think that's OK!

It's another tool and one that might actually improve with time. I don't see GNU's man pages getting any better spontaneously.

Whoa, what if they started to use AI to auto-generate man pages...

Re:FFmpeg by Example by BlaDeKke on Wednesday January 15, 2025 @04:34AM (#42709048)
> Whoa, what if they started to use AI to auto-generate man pages...

That’s the time to start my career in woodworking.

Re:FFmpeg by Example by johnisgood on Wednesday January 15, 2025 @09:03AM (#42710866)
I already generate man pages (and POD) with Claude for my new projects. :D

It works really well.

Re:FFmpeg by Example by Over2Chars on Wednesday January 15, 2025 @06:47PM (#42718898)
Any links you wanna share? I've never seen an AI generated man page.
Re:FFmpeg by Example by johnisgood on Thursday January 16, 2025 @12:47PM (#42728425)
They are not public projects, but man pages and their README.md is generated albeit refined through prompts.

It is not simply a "generate man page" without context.

Re:FFmpeg by Example by michaelcampbell on Thursday January 16, 2025 @08:01AM (#42724574)
> what if they started to use AI to auto-generate man pages...

Then they'd be wrong about 20% of the time, and still no one would read them. ;-)

(NB: I'm of the age that I do read them, but I think I'm in the minority.)

Re:FFmpeg by Example by BiteCode_dev on Wednesday January 15, 2025 @02:49AM (#42708428)
Reading this feels like seing a guy getting his first car in 1920 and complaining he still has to drive it himself.
Re:FFmpeg by Example by pbhjpbhj on Wednesday January 15, 2025 @03:07AM (#42708528)
Pony & trap could be largely self-driving, after an initial training period. That would have been a distinct negative to "upgrading" for some, I'd imagine.
Re:FFmpeg by Example by nine_k on Wednesday January 15, 2025 @09:19AM (#42711029)
It's speed and load capacity vs self-driving.

If we could imagine wiring a pony to control a car, its brain, while good at navigation, would likely be inadequate at the speed that a car attains.

Re:FFmpeg by Example by atoav on Wednesday January 15, 2025 @02:53AM (#42708463)
Sell that guy probably got carried home by his horse after drinking half a bottle of whiskey, so maybe he had a point.
Re:FFmpeg by Example by LeoWattenberg on Wednesday January 15, 2025 @04:57AM (#42709190)
The beer brewers in my home town used to have a self-driving horse and cart which knew the daily delivery route going by all pubs and didn't really need a human to steer it or indeed be conscious during the trip. Expectedly, the delivery guy would get drunk first thing in the morning and just get carted about collecting the money.
Re:FFmpeg by Example by imiric on Wednesday January 15, 2025 @09:15AM (#42710989)
To me it's more like a guy getting his first car and complaining that the car is driving him in a direction that may or may not be correct, despite his best efforts to steer it where he wants to go. And the only way to know whether he ends up in the right place is to get out of the car, look around, and maybe ask more experienced drivers. Failing that, his only option is to get back in and hope to be luckier in the next trip.

Or he can just ditch the car and walk. Sure, it's slower and requires more effort, but he knows exactly how to do that and where it will take him.

Re:FFmpeg by Example by shriek on Wednesday January 15, 2025 @10:28AM (#42711971)
Or maybe calling a cab and telling the cab driver each direction to get to the destination instead of the cab driver just taking you there.
Re:FFmpeg by Example by cm2187 on Wednesday January 15, 2025 @02:57AM (#42708480)
Plus you need to know the format of your source file to design the command correctly. How many audio tracks, is the first video track a thumbnail or the video, are the subtitles tracks forced, etc.

And in some situations ffmpeg has some warts you have to go around. Like they introduced recently a moronic change of behaviour where the first sub tracks becomes forced/default irrespective of the original forced/default flag of the source. You need to add "-default_mode infer_no_subs" to counter that.

Re:FFmpeg by Example by Philpax on Wednesday January 15, 2025 @10:19AM (#42711818)
I usually just paste the output of `ffprobe` into Claude when it's ambiguous. Works a treat.
Re:FFmpeg by Example by assimpleaspossi on Wednesday January 15, 2025 @06:40AM (#42709827)
My experience exactly.

I no longer check with these AI tools after a number of attempts. Unrelated, a friend thought there was a NFL football game last Saturday at noon. Checking with Google's Gemini, it said "no", but there was one between two teams whose season had ended two weeks before at 1:00 Eastern Time and 2:00 Central. (The times are backwards.)

Re:FFmpeg by Example by bityard on Wednesday January 15, 2025 @08:51AM (#42710714)
Do LLMs have knowledge of current events?
Re:FFmpeg by Example by johnisgood on Wednesday January 15, 2025 @09:02AM (#42710855)
I mean, some are capable of searching the web.

Ask them about the fire in LA in 2025 January.

Re:FFmpeg by Example by assimpleaspossi on Wednesday January 15, 2025 @08:24PM (#42719808)
Meta.ai got it right. The free chatGPT only has data up till 2021 or something like that.
Re:FFmpeg by Example by hulitu on Friday January 17, 2025 @04:49AM (#42735819)
> Do LLMs have knowledge of current events?

I don't think the notion of "current" has been explained to them. Thay just define it out of context.

Re:FFmpeg by Example by keeganpoppen on Wednesday January 15, 2025 @03:28PM (#42716466)
what exactly do you want the llm to do here? if the ask was so unambiguous and simple that it could be reliably generated, then the interface wouldn't be so complicated to use in the first place! LLMs are not in any way best suited for one-shot prompt => perfect output, and expectations to that effect are extremely unreasonable. the reason why LLMs are still hard for beginners to use is because the software is hard to use correctly. as with LLM output goes life itself: the results you get from using a tool can only ever be as good as the (mental) model used to choose that tool & the inputs to begin with. if all the information required to generate the output were contained by the initial prompt, then there would be absolutely no need to use the LLM at all in the first place.
Re:FFmpeg by Example by dekhn on Tuesday January 14, 2025 @07:01PM (#42705653)
"The future is already here. It's just not very well distributed"

(honestly, the work you share is very inspiring)

Re:FFmpeg by Example by zahlman on Tuesday January 14, 2025 @07:46PM (#42705995)
>This will then be displayed in your terminal ready for you to edit it, or hit <enter> to execute the prompt. If the command doesnt't look right, hit Ctrl+C to cancel.

I appreciate the UI choice here. I have yet to do anything with AI (consciously and deliberately, anyway) but this sort of thing is exactly what I imagine as a proper use case.

Re:FFmpeg by Example by hnuser123456 on Tuesday January 14, 2025 @08:12PM (#42706163)
Just like all other code. There will be user-respecting open source code and tools, and there's user-disrespecting profitable closed code that makes too many decisions for you.
Re:FFmpeg by Example by th0ma5 on Tuesday January 14, 2025 @08:51PM (#42706415)
You should figure out what went wrong for the other commenter and fix your tool.
Re:FFmpeg by Example by Waterluvian on Tuesday January 14, 2025 @08:59PM (#42706462)
I think I’m finally sold on actually attempting to add some LLM to my toolbelt.

As a helper and not a replacement, this sounds grand. Like the most epic autocomplete. Because I hate how much time I waste trying to figure out the command line incantation when I already know precisely what I want to do. It’s the weakest part of the command line experience.

Re:FFmpeg by Example by Over2Chars on Tuesday January 14, 2025 @10:41PM (#42707060)
But possibly the most rewarding. The struggle is its own reward that pays off later many times over.
Re:FFmpeg by Example by Waterluvian on Wednesday January 15, 2025 @12:05AM (#42707512)
Not for me. It’s a tool I don’t care to use any more than I have to. I’m much more interested in what I’m using the tool to accomplish.
Re:FFmpeg by Example by Over2Chars on Wednesday January 15, 2025 @01:20AM (#42707938)
I am not talking about the tool per se. I am talking about the skill of persistence and creativity in the face of a problem.

Learning a tool is useful, even invaluable, but if you don't have the persistence to use it, it's useless.

And many tools are just partially useful under some conditions. So creativity in using them is also useful.

So it's not about the tools, its about not giving up and trying different things, which makes all tools more effective, and problem-solving more likely.

Re:FFmpeg by Example by Philpax on Wednesday January 15, 2025 @10:23AM (#42711886)
Yeah, and I'll do that with all of the tools and problems I actually care about :p
Re:FFmpeg by Example by Over2Chars on Wednesday January 15, 2025 @06:46PM (#42718891)
There's something to be said for that approach.

It's not the only approach, and definitely as someone once said, premature optimization is the root of all evil, and maybe you are optimizing at exactly the right time.

Who can tell?

Re:FFmpeg by Example by hbn on Wednesday January 15, 2025 @08:23AM (#42710499)
There are times I feel minor guilt for using an LLM to relieve brainwork, like figuring out an algorithm. That's probably a skill I should continue practicing for my own sake.

ffmpeg commands though? It's really not a practical skill outside of using ffmpeg. There's nothing really rewarding to me about memorizing awkwardly designed CLI incantations. It's all arbitrary.

Re:FFmpeg by Example by Over2Chars on Wednesday January 15, 2025 @07:28PM (#42719308)
memorization is not what I'm talking about.

I'm talking about

1. you have a problem, you try something and it doesn't work. 2. you find an LLM and it "gives" you the answer with one or two tries 3. problem solved! what have you learned? How to have answers given to you when you ask.

or 2. you look for an answer in a dizzying haze of man pages, quacks, and website Q&As. 3. you try and try again and eventually problem solved. you have learned not only how to solve a particular problem but your overall ability to solve similar problems has done up. You've learned how to fish, not just ask an LLM for a fish.

Re:FFmpeg by Example by chriscappuccio on Monday January 20, 2025 @09:49AM (#42769288)
after well more than three decades of ice fishing, i am absolutely delighted to ask an LLM for an ffmpeg fish

and yet, i too know that it is perhaps not quite as good for me as finding the fish on my own lake

at least i can keep these fish in my own warm pond, and go back to them whenever i like

after decades of ice fishing, i think the LLM fish are quite good... and even when they are no good, that fishing experience makes it so easy to go back to the LLM and get the exact right fish for my pond

it will continue to be helpful for everyone in the future if we keep publishing the contents of our ponds, whether it's a web site like this, or in a repository

Re:FFmpeg by Example by atoav on Wednesday January 15, 2025 @02:51AM (#42708452)
Did you just invent the LLM-equivalent of curl-piping unread shell scripts into sh?

I am sure that will never cause any problems.

Re:FFmpeg by Example by ykonstant on Wednesday January 15, 2025 @03:56AM (#42708830)
> Did you just invent the LLM-equivalent of curl-piping unread shell scripts into sh?

Many such cases.

Re:FFmpeg by Example by bspammer on Wednesday January 15, 2025 @06:37AM (#42709813)
It displays the generated command to you, there's an additional step to confirm.
Re:FFmpeg by Example by atoav on Wednesday January 15, 2025 @08:58AM (#42710800)
Ah good to clarify, thanks
Re:FFmpeg by Example by mvonballmo on Wednesday January 15, 2025 @03:16AM (#42708585)
Re:FFmpeg by Example by mrweasel on Wednesday January 15, 2025 @04:35AM (#42709060)
While I love that that works, I still feel like just maybe ffmpeg needs a better interface. Not necessarily a GUI, just a better designed command line.
Re:FFmpeg by Example by Beijinger on Wednesday January 15, 2025 @07:00AM (#42709945)
uv?
Re:FFmpeg by Example by phrotoma on Wednesday January 15, 2025 @07:23AM (#42710107)
like pip but written in rust
Re:FFmpeg by Example by pmarreck on Wednesday January 15, 2025 @01:21PM (#42714876)
A while back I simply wrote my own bash function for this called `please`

as in

    bash> please "use ffmpeg to extract audio from myfile.mov and save it as mp3"
It will then courteously show you the command it wants to run before you agree to do it.

Here is the whole thing, with its two dependent functions, so that people stop writing their own versions of this lol. All it needs is an OPENAI_API_KEY, feel free to modify for other LLMs

EDIT: Moved to a gist: https://gist.github.com/pmarreck/9ce17f7996347dd532f3e20a2a3...

Suggestions welcome- for example I want to add a feature that either just copies it (for further modification) or prepopulates the command line with it somehow (possibly for further modification, or even for skipping the approval step)

Re:FFmpeg by Example by smusamashah on Wednesday January 15, 2025 @04:56PM (#42717687)
please is such an appropriate name. Will rename my ChatGPT alias to please.
Re:FFmpeg by Example by levocardia on Tuesday January 14, 2025 @04:58PM (#42704483)
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!
Re:FFmpeg by Example by earnestinger on Tuesday January 14, 2025 @06:44PM (#42705520)
Not sure about ffmpeg, but you should definitely try memorising regexp. Casual Search&replace that becomes possible is worth it.
Re:FFmpeg by Example by sergiotapia on Tuesday January 14, 2025 @07:04PM (#42705683)
in 15 years it never sticks and by the time i need it again i've forgotten it! :D
Re:FFmpeg by Example by kevin_thibedeau on Tuesday January 14, 2025 @07:41PM (#42705960)
Don't learn the Perl influenced extensions. You just need POSIX EREs (and BREs for some older utilities) which are simple enough to keep in the head.
Re:FFmpeg by Example by ziml77 on Tuesday January 14, 2025 @09:04PM (#42706488)
And with the POSIX EREs, everything except the syntax for character classes will carry over to other common Regex dialects.
Re:FFmpeg by Example by Over2Chars on Tuesday January 14, 2025 @10:43PM (#42707070)
I'll just leave this here

"The Insanity Of Linux's Regular Expressions " https://www.youtube.com/watch?v=ys7yUyyQA-Y

Re:FFmpeg by Example by earnestinger on Wednesday January 15, 2025 @04:55AM (#42709177)
Many loosely compatible (so, not compatible if we are strict..) implementations are a problem, but awareness and testing helps.

All in all, my life would be miserable if I would not have regexp available in grep/sed/editor/ide/java/python, their usefulness trump any such inconveniences.

Re:FFmpeg by Example by teaearlgraycold on Tuesday January 14, 2025 @06:33PM (#42705434)
Gotta be honest, years of configuring automod on Reddit have honed me into a regex God.
Re:FFmpeg by Example by hackingonempty on Tuesday January 14, 2025 @05:15PM (#42704675)
CSS has entered the ChatGPT.
Re:FFmpeg by Example by kccqzy on Tuesday January 14, 2025 @06:58PM (#42705632)
My rule for using LLMs is that anything that's one off is okay. Anything that's more permanent and committed to a repo needs a human review. I strongly suggest you have an understanding of the basics (at least the box model) so that you are competent at reviewing CSS code before using LLM for that.
Re:FFmpeg by Example by permo-w on Tuesday January 14, 2025 @06:25PM (#42705340)
I've been looking for a good guide on prompting LLMs for CSS.

does anyone know of any?

Re:FFmpeg by Example by johnisgood on Wednesday January 15, 2025 @09:48AM (#42711374)
I have no set of rules when prompting LLMs for CSS, it does seem to work more or less for me though.

What are your current issues or what limitations have you ran into?

Re:FFmpeg by Example by permo-w on Thursday January 16, 2025 @12:01AM (#42721452)
mainly with trying to impart a particular art style.
Re:FFmpeg by Example by zxvkhkxvdvbdxz on Tuesday January 14, 2025 @08:24PM (#42706228)
Interesting. Being able to use regexps for text processing through my career has probably saved me a few thousand hours of programming one-off solutions so far. It is one of those skills that really pays off to learn proper.

And speaking of ffmpeg, or tooling in general, I tend to make notes. After a while you end up with a pretty decent curated reference.

Re:FFmpeg by Example by codetrotter on Tuesday January 14, 2025 @09:32PM (#42706654)
I use regexes a lot. The main thing that always trips me up is dealing with escaping, because different tools I use – vim, sed, rg, and so on – sometimes have different meanings for when to escape or not.

In one tool you’ll use + to match one or more times, and \+ to mean literal plus sign.

In another tool you’ll use \+ to match one or more time, and + to mean literal plus sign.

In one tool you’ll use ( and ) to create a match group, and \( and \) to mean literal open and close parentheses.

In another tool you’ll use \( and \) to create a match group, and ( and ) to mean literal open and close parentheses.

This is basically the only problem I have when writing regexes, for the kinds of regexes I write.

Also, one thing that’s not a problem per se but something that leads me to write my regexes with more characters than strictly necessary is that I rarely use shorthand for groups of characters. For example the tool might have a shorthand for digit but I always write [0-9] when I need to match a digit. Also probably because the shorthand might or might not be different for different tools.

Regexes are also known to be “write once read never”, in that writing a regex is relatively easy, but revisiting a semi-complicated regex you or someone else wrote in the past takes a little bit of extra effort to figure out what it’s matching and what edits one should make to it. In this case, tools like https://regex101.com/ or https://www.debuggex.com/ help a lot.

Re:FFmpeg by Example by nuancebydefault on Wednesday January 15, 2025 @04:02AM (#42708879)
The problem with escaping (like with using quotes) is often that you need to know through how many parsers the string goes. The shell or editor, the language you are programming in and the regexp engine each time can strip off an escape character or a set of outer quotes. That and of course different dialects of regexp makes things complicated.
Re:FFmpeg by Example by account42 on Thursday January 16, 2025 @03:58AM (#42723046)
This is like saying that words have different meaning if you talk to someone in english or french. Most tools have a switch to inform them that you're going to talk in english (perl-compatible regular expressions).
Re:FFmpeg by Example by mystified5016 on Tuesday January 14, 2025 @10:15PM (#42706924)
No one doubts the power or utility of regexes or ffmpeg, but they are both complicated beasts that really take a lot of skill.

They're both tools where if they're part of your daily workflow you'll get immense value out of learning them thoroughly. If instead you need a regex once or twice a week, the benefit is not greater than the cost of learning to do it myself. I have a hundred other equally complicated things to learn and remember, half the job of the computer is to know things I can't put in my brain. If it can do the regex for me, I suddenly get 70% of the value at no cost.

Regex is not a tool I need often enough to justify the hours and brain space. But it is still an indespensible tool. So when I need a regex, I either ask a human wizard I know, or now I ask my computer directly.

Re:FFmpeg by Example by imp0cat on Wednesday January 15, 2025 @02:06AM (#42708185)
It's self-reinforcing though. If you invest the time to learn, then you may find yourself (i a beafutiful house :)) using it a lot more than two times a week.
Re:FFmpeg by Example by nuancebydefault on Wednesday January 15, 2025 @04:09AM (#42708920)
I think this way of thinking is an uphill battle.

My kid uses wifi, google classroom tools, youtube, games,... I can tell him if only you knew command.com, ipconfig, doom.wad formats, lateg,... you could be so much more proficient. I already know this will never happen, just like I never learned x86 assembly.

The same goes for tools like LLMs, once you are used to them, your knowledge shifts.

Re:FFmpeg by Example by skydhash on Wednesday January 15, 2025 @09:55AM (#42711462)
I learned a bit of assembly and it was a god send to understand linkers and how FFI works. Also make it easier to have a good model on using a debugger. Not that useful on a tactical level, but really great when faced with some errors in your compiled programs.
Re:FFmpeg by Example by shlomo_z on Tuesday January 14, 2025 @09:59PM (#42706815)
... Then ChatGPT came along and I had 3 problems! https://regex.info/blog/2006-09-15/247
Re:FFmpeg by Example by jmb99 on Wednesday January 15, 2025 @03:35AM (#42708706)
For me, it wasn’t so much learning ffmpeg, as it was understanding containers/codecs/encoders/streams/etc. Learning all of the intricacies there made ffmpeg make a lot more sense.
Re:FFmpeg by Example by skydhash on Wednesday January 15, 2025 @10:00AM (#42711542)
Almost no one cares to understand the domain of the tool anymore, they only want result and expect a simplified interface that already does the unique thing they want to do, but can’t accept that a power tool can only be used with training.
Re:FFmpeg by Example by juancroldan on Tuesday January 14, 2025 @05:47PM (#42705000)
Same here, it's one of these things where AI has taken over completely and I'm just a broker that copy-pastes error traces.
Re:FFmpeg by Example by magarnicle on Tuesday January 14, 2025 @05:48PM (#42705006)
My experience got even better once I learned how complex filters worked.
Re:FFmpeg by Example by dylan604 on Tuesday January 14, 2025 @06:12PM (#42705223)
learning how to use splits to do multiple things all in one command is a god send. the savings of only needed to read the source and convert to baseband video once is a great savings.

i started with avisynth, and it took time for my brain to switch to ffmpeg. i don't know how i could function without ffmpeg at this point

Re:FFmpeg by Example by urda on Tuesday January 14, 2025 @09:53PM (#42706779)
For me it was using a container of it, instead of having to install all the things FFmpeg needs on a machine.
Re:FFmpeg by Example by Over2Chars on Tuesday January 14, 2025 @10:26PM (#42706971)
I think you're onto something. I've had hit or miss experiences with code from LLMs but it definitely makes the searching part different.

I had a problem I'd been thinking about for some time and I thought "Ill have some LLM give me an answer" and it did - it was wrong and didn't work but it got me to thinking about the problem in a slightly different way and my quacks after that got me an exact solution to this problem.

So I'm willing to give the AI more than partial credit.

Re:FFmpeg by Example by pdyc on Tuesday January 14, 2025 @11:41PM (#42707387)
I ended up creating my own tool to generate ffmpeg commands https://newbeelearn.com/tools/videoeditor/
Re:FFmpeg by Example by skirge on Wednesday January 15, 2025 @01:05AM (#42707845)
llm - Clippit of 202x, but for the original Pentium was enough.
Re:FFmpeg by Example by bambax on Wednesday January 15, 2025 @01:47AM (#42708088)
Basic syntax for re-encoding a video file did take me some time to memorize, but isn't in fact too hard:

  ffmpeg <Input file(s)> <Codec(s)> <MAPping of streams> <Video Filters> output_file
- input file: -i, can be repeated for multiple input files, like so:

  ffmpeg -i file1.mp4 -i file2.mkv
If there is more than one input file then some mapping is needed to decide what goes out in the output file.

- codec: -c:x where x is the type of codec (v: video, a: audio or s:subtitles), followed by its name, like so:

  -c:v libx265
I usually never set the audio codec as the guesses made by ffmpeg, based on output file type, are always right (in my experience), but deciding the video codec is useful, and so is the subtitles codec, as not all containers (file formats) support all codecs; mkv is the most flexible for subtitles codecs.

- mapping of streams: -map <input_file>:<stream_type>:<order>, like so:

  -map 0:v:0 -map 1:a:1 -map 1:a:0 -map 1:s:4
Map tells ffmpeg what stream from the input files to put in the output file. The first number is the position of the input file in the command, so if we're following the same example as above, '0' would be 'file1.mp4' and '1' would be 'file2.mkv'. The parameter in the middle is the stream type (v for video, a for audio, s for subtitles). The last number is the position of the stream IN THE INPUT FILE (NOT in the output file).

The position of the stream in the output file is determined by the position of the map command in the command line, so for example in the command above we are inverting the position of the audio streams (taken from 'file2.mkv'), as audio stream 1 will be in first position in the output file, and audio stream 0 (the first in the second input file) will be in second position in the output file.

This map thing is for me the most counter-intuitive because it's unusual for a CLI to be order-dependent. But, well, it is.

- video filters: -vf

Video filters can be extremely complex and I don't pretend to know how to use them by heart. But one simple video filter that I use often is 'scale', for resizing a video:

  -vf scale=<width>:<height>
width and height can be exact values in pixels, or one of them can be '-1' and then ffmpeg computes it based on the current aspect ratio and the other provided value, like this for example:

  -vf scale=320:-1
This doesn't always work because the computed value should be an even integer; if it's not, ffmpeg will raise an error and tell you why; then you can replace the -1 with the nearest even integer (I wonder why it can't do that by itself, but apparently, it can't).

And that's about it! ffmpeg options are immense, but this gets me through 90% of my video encoding needs, without looking at a manual or ask an LLM. (The only other options I use often are -ss and -t for start time and duration, to time-crop a video.)

Re:FFmpeg by Example by izacus on Wednesday January 15, 2025 @03:49AM (#42708786)
> This doesn't always work because the computed value should be an even integer; if it's not, ffmpeg will raise an error and tell you why; then you can replace the -1 with the nearest even integer (I wonder why it can't do that by itself, but apparently, it can't).

It's not about integer, but some of the sizes need to be even. You can use `-vf scale=320:-2` to ensure that.

Re:FFmpeg by Example by bambax on Wednesday January 15, 2025 @06:49AM (#42709872)
It's hard for a number to be even without first being an integer, no? ;-)

But thanks for '-2', didn't know about that! It's the exact default option I needed! Will be using that always from now on.

https://stackoverflow.com/questions/71092347/ffmeg-option-sc...

Re:FFmpeg by Example by jmb99 on Wednesday January 15, 2025 @03:38AM (#42708730)
> then you can replace the -1 with the nearest even integer (I wonder why it can't do that by itself, but apparently, it can't).

Likely because the aspect ratio will no longer be the same. There will either be lost information (cropping), compression/stretching, or black bars, none of which should be default behaviour. Hence, the warning.

Re:FFmpeg by Example by 0x38B on Monday January 20, 2025 @05:45AM (#42767278)
A practical example of mapping streams:

    ffmpeg -i <movie-with-many-tracks.mkv> -map 0:0 -map 0:5 -map 0:12 -vcodec copy -acodec copy -scodec copy "output-movie.mkv"
Use: sometimes I have a file with a lot of audio and or subtitle streams but only want one or two of each – here, 0:0 is the video, 0:5 is English audio, and 0:12 was the subtitle track I wanted. Setting the codecs to “copy” means nothing gets reencoded.
Re:FFmpeg by Example by sathishvj on Wednesday January 15, 2025 @02:30AM (#42708319)
I would like to throw in a tool that I built into the ring: gencmd - https://gencmd.com/. There is a web version and also a CLI version.

If the CLI is installed, you can do: gencmd -c ffmpeg extract first 1 minute of video

Or you can just search for the same in the browser page.

Re:FFmpeg by Example by jjcm on Wednesday January 15, 2025 @02:38AM (#42708362)
In addition to the many others mentioned, here's a script I just threw together that simplifies a lot of these chained commands - llmpeg: https://github.com/jjcm/llmpeg

If you have ffmpeg installed and an OpenAI env api key set, it should work out of the box.

Demo: https://image.non.io/1c7a92ef-0917-49ef-9460-6298c7a9116c.we...

Re:FFmpeg by Example by NetOpWibby on Wednesday January 15, 2025 @04:52AM (#42709156)
Truly, a net positive to my life. Just a few days ago I asked my AI buddy (Claude) to create a zsh script to organize my downloads folder according to the Johnny Decimal system. I’ve since modified it to move the files to a JD setup on my desktop.

The sense of elation I get when I wonder aloud to my digital friend and they generate what I thought was too much to expect. Well worth the subscription.

Re:FFmpeg by Example by archerx on Wednesday January 15, 2025 @07:02AM (#42709954)
Why not just use Handbrake? It’s just FFMpeg but with a GUI.
Re:FFmpeg by Example by wildzzz on Wednesday January 15, 2025 @09:34AM (#42711194)
That's fine for encoding but Handbrake doesn't let you do video streaming to my knowledge.
Re:FFmpeg by Example by nine_k on Wednesday January 15, 2025 @09:27AM (#42711110)
I do it the old way: I write down the commands as a shell script, and reuse later.

But really what ffmpeg is missing is an expressive language to describe its operation. Something well-structured, like what jq does for JSON.

Re:FFmpeg by Example by skydhash on Wednesday January 15, 2025 @10:03AM (#42711589)
It already does. It’s the cli flags. What you’re missing is the semantic which you can get with learning about containers, codecs, and other stuff. You don’t use grep and sed with no understanding of what a text file is.
Re:FFmpeg by Example by michaelcampbell on Thursday January 16, 2025 @07:59AM (#42724565)
ffmpeg and jq are 2 commands I've about given up trying to "use" with any facility and am more than happy to pawn that off to one of the Gippity's; chat, claude, etc.