« BackFFmpeg Assembly Language Lessonsgithub.comSubmitted by flykespice 3 hours ago
  • cr125rider 2 hours ago

    I can’t imagine the scale that FFMPEG operates at. A small improvement has to be thousands and thousands of hours of compute saved. Insanely useful project.

    • prisenco 2 hours ago

      Their commitment to performance is a beautiful thing.

      Imagine all projects were similarly committed.

      • Almondsetat 15 minutes ago

        Yeah no, I'd like non-performance critical programs to focus on other things than performance thank you

        • EliRivers 3 minutes ago

          Surely all programs are performance critical. Any program we think isn't is just a program where the performance met the criteria already.

        • therealmarv 11 minutes ago

          like Slack or Jira... lol.

          • byteknight an hour ago

            Seems so easy! You only need the entire world even tangentially related to video to rely solely on your project for a task and you too can have all the developers you need to work on performance!

            • ackfoobar an hour ago

              I seem to recall that they lamented on twitter the low amount of (monetary or code) contribution they got, despite how heavily they are used.

              • hluska 19 minutes ago

                You know friend, if open source actually worked like that I wouldn’t be so allergic to releasing projects. But it doesn’t - a large swath of the economy depends on unpaid labour being treated poorly by people who won’t or can’t contribute.

            • zahlman 2 hours ago

              It'd be nice, though, to have a proper API (in the traditional sense, not SaaS) instead of having to figure out these command lines in what's practically its own programming language....

              • codys an hour ago

                FFMpeg does have an API. It ships a few libraries (libavcodec, libavformat, and others) which expose a C api that is used in the ffmpeg command line tool.

                They publish doxygen generated documentation for the APIs, available here: https://ffmpeg.org/doxygen/trunk/

                • zahlman an hour ago

                  Don't know how I overlooked that, thanks. Maybe because the one Python wrapper I know about is generating command lines and making subprocess calls.

                  • ansk 6 minutes ago

                    For future reference, if you want proper python bindings for ffmpeg* you should use pyav.

                    * To be more precise, these are bindings for the libav* libraries that underlie ffmpeg

                    • Wowfunhappy 40 minutes ago

                      They're relatively low level APIs. Great if you're a C developer, but for python just calling the command line probably does make more sense.

                      • javier2 41 minutes ago

                        If you are processing user data, the subprocess approach makes it easier to handle bogus or corrupt data. If something is off, you can just kill the subprocess. If something is wrong with the linked C api, it can be harder to handle predictably.

                    • xxpor 27 minutes ago

                      I get why the CLI is so complicated, but I will say AI has been great at figuring out what I need to run given an English language input. It's been one of the highest value uses of AI for me.

                  • KwanEsq 2 hours ago

                    Prior discussion 2025-02-22, 222 comments: https://news.ycombinator.com/item?id=43140614

                    • NullCascade an hour ago

                      What is the actual process of identifying hotspots caused suboptimal compiler generated assembly?

                      Would it ever make sense to write handwritten compiler intermediate representation like LLVM IR instead of architecture-specific assembly?

                      • molticrystal an hour ago

                        It would be interesting to look into this to see if anybody has every hand tuned LLVM IR.

                        My best guess is you were doing codegen for several different instruction sets and the optimization or side channel prevention is something that would be too difficult or specialized to automate so you have to do it by hand.

                      • abhisek 35 minutes ago

                        Love it. Thanks for taking the time to write this. Hope it will encourage more folks to contribute.

                        • Alifatisk 2 hours ago

                          How do they make these assembly instructions portable across different cpus?

                          • CannotCarrot an hour ago

                            I think there's a generic C fallback, which can also serve as a baseline. But for the big (targeted) architectures, there one handwritten assembly version per arch.

                            • faluzure an hour ago

                              Yup.

                              On startup, it runs cpuid and assigns each operation the most optimal function pointer for that architecture.

                              In addition to things like ‘supports avx’ or ‘supports sse4’ some operations even have more explicit checks like ‘is a fifth generation celeron’. The level of optimization in that case was optimizing around the cache architecture on the cpu iirc.

                              Source: I did some dirty things with chromes native client and ffmpeg 10 years ago.

                            • KeplerBoy an hour ago

                              They don't. It's just x86-64.

                              • ahartmetz an hour ago

                                The lessons yes, but the repo contains assembly for the 5-6 architectures in wide use in consumer hardware today. Separate files of course. https://github.com/FFmpeg/FFmpeg/tree/master/libavcodec

                                • KeplerBoy 18 minutes ago

                                  Yeah, sure. I was specifically referring to the tutorials. Ffmpeg needs to run everywhere, although I believe they are more concerned about data center hardware than consumer hardware. So probably also stuff like power pc.

                            • nisten 42 minutes ago

                              I feel like I just got a 3 page intro to autism.

                              It's glorious.

                              • ngcc_hk 2 hours ago

                                More interesting than I thought it could be. A domain specific tutorial is so much better.

                                • sylware 2 hours ago

                                  There is serious abuse of nasm macro-preprocessor. Going to be tough to move away to another assembler.