Live data from Hacker News

FFmpeg lands CLI multi-threading as its "most complex refactoring" in decades

phoronix.com

41–50 of 186 posts

Re: FFmpeg lands CLI multi-threading as its "most complex refactoring" in decades

#41

Earlier quoted context omitted.

I'm dying.

https://www.youtube.com/watch?v=9kaIXkImCAM

I'm glad we've reached a point where there is quality parody content online for our industry.

Re: FFmpeg lands CLI multi-threading as its "most complex refactoring" in decades

#42
post #36

Earlier quoted context omitted.

Because refactoring requires understanding, which LLMs completely lack.

> Because refactoring requires understanding, which LLMs completely lack. Interesting. Here's a sample question I just asked the AI: We are working on a React mapping application. I am going to give you two components from this application. Our goal is to extract functionality to deduplicate code We can make a single base component, extract code to hooks, or any other strategy which you think is appropriate Here is t…

Eliminating duplication and cleaning code is a different type of refactoring than supporting concurrency, which is much much harder.

Cleaning up code also follows some well established patterns, performance work is much less pattern-y.

Codebases like FFMPEG are one of the kind. I bet you need 10 or 100 times more understanding than the react thing you mentioned above.

One day maybe AI can do it, but it probably won't be LLM. It would be something which can understand symbols and math.

Re: FFmpeg lands CLI multi-threading as its "most complex refactoring" in decades

#43
post #3

It’s nuts to think that in the near future LLM will be able to do that refactoring in seconds. All we need is enough context window.

Why would you think this is possible?

based on my current experience with gpt-4. Have you tried some sort of refactoring in it? Because I have been routinely turning serial scripts into parallel ones with success.

Couldn't do the same with larger codebases because the context is not enough for the input code and output refactoring.

Re: FFmpeg lands CLI multi-threading as its "most complex refactoring" in decades

#44

Meanwhile, I've been enjoying threaded filter processing in VapourSynth for nearly a decade. Not that this isn't great. Its fantastic. But TBH its not really going to change my workflow of VapourSynth preprocessing + av1an encoding for "quality" video encodes.

I'm guessing from context that VapourSynth is a frame-server in the vein of avisynth? If so, does it run on Linux? Avisynth was the single biggest thing I missed when moving to Linux about 20 years ago.

[edit]

found the docs; it's available on Linux[1]. I'm definitely looking into it tonight because it can't be worse than writing ffmpeg CLI filtergraphs!

1: http://www.vapoursynth.com/doc/installation.html#linux-insta...

Re: FFmpeg lands CLI multi-threading as its "most complex refactoring" in decades

#45
post #3

It’s nuts to think that in the near future LLM will be able to do that refactoring in seconds. All we need is enough context window.

Why on earth would you possibly think that?

I'm quite confused by the answers I got from this thread. Haven't you tried refactoring with gpt-4 yet?

Re: FFmpeg lands CLI multi-threading as its "most complex refactoring" in decades

#46
I've always wondered if better multi-core performance can come from processing different keyframe segments separately.

IIUC all current encoders that support parallelism work by multiple threads working on the same frame at the same time. Often times the frame is split into regions and each thread focuses on a specific region of the frame. This approach can have a (usually small) quality/efficiency cost and requires per-encoder logic to assemble those regions into a single frame.

What if instead/additionally different keyframe segments are processed independently? So if keyframes are every 60 frames ffmpeg will read 60 frames pass that to the first thread, the next 60 to the next thread, ... then assemble the results basically by concatenating them. It seems like this could be used to parallelize any codec in a fairly generic way and it should be more efficient as there is no thread-communication overhead or splitting of the frame into regions which harms cross-region compression.

Off the top of my head I can only think of two issues:

1. Requires loading N*keyframe period frames into memory as well as the overhead memory for encoding N frames.

2. Variable keyframe support would require special support as the keyframe splits will need to be identified before passing the video to the encoding threads. This may require extra work to be performed upfront.

But both of these seem like they won't be an issue in many cases. Lots of the time I'd be happy to use tons of RAM and output with a fixed keyframe interval.

Probably I would combine this with intra-frame parallelization such as process every frame with 4 threads and then run 8 keyframe segments in parallel. This way I can get really good parallelism but only minor quality loss from 4 regions rather than splitting the video into 32 regions which would harm quality more.

Re: FFmpeg lands CLI multi-threading as its "most complex refactoring" in decades

#47
post #17

Earlier quoted context omitted.

FFMPEG does so much more than just video encoding. I use ffmpeg all day every day, and only a fraction of the time do I actually make a video.

Like what do you do?

I've used it for video and audio concatenation of laserdisc game segments, transcoding audio clips for gamedev, programmatically generating GIFs of automatically generated video clips from tests in a CI pipeline, ripping songs and audio clips from YouTube videos to ogg/mp3, creating GIFs from burst-shot and time-lapse photography (and decimating them), excerpting clips from a video without re-encoding, and compressing or transforming audio on remote servers where VLC wasn't and couldn't be installed.

Re: FFmpeg lands CLI multi-threading as its "most complex refactoring" in decades

#48
post #26
post #17

Earlier quoted context omitted.

Like what do you do?

One can use it instead of cat to display text files. Easy syntax to remember. ffmpeg -v quiet -f data -i file.txt -map 0:0 -c text -f data -

I bet ffmpeg special cases that combination of flags and calls cat.

Re: FFmpeg lands CLI multi-threading as its "most complex refactoring" in decades

#49
post #9
post #3

It’s nuts to think that in the near future LLM will be able to do that refactoring in seconds. All we need is enough context window.

Yeah, it's nuts to think that.

I'm genuinely confused about your point of view. Have you tried refactoring with GPT-4?

I have been refactoring code using gpt-4 for some months now and the limiting factor have been the context size.

GPT-4 turbo now have 128k context and I can provide it with larger portions of the code base for the refactors.

When we have millions of tokens of context, based on what I'm experiencing now, I can see that a refactoring like the one made in ffmpeg would be possible. Or not? What am I missing here?

Re: FFmpeg lands CLI multi-threading as its "most complex refactoring" in decades

#50
post #26
post #17

Earlier quoted context omitted.

Like what do you do?

One can use it instead of cat to display text files. Easy syntax to remember. ffmpeg -v quiet -f data -i file.txt -map 0:0 -c text -f data -

can I use ffmpeg to embed a gif in a Hacker News comment, because I want that so much right now
Post reply on HN