15 ms·
Emacs as your video-trimming tool
- precompute 1y agoGreat tool! I'm always impressed by how versatile a tool Transient is. I use it extensively as well and there's nothing like it anywhere else.
- iLemming 1y agoTransient is indeed very nice, even though I wish its programmable API was simpler and made more sense, sometimes it feels annoyingly quirky and unreasonably complex. Shameless plug for further ideation and discussion: https://news.ycombinator.com/item?id=44025635 https://news.ycombinator.com/item?id=44025635 - it's a long video - ~1hr, it's unscripted and unedited. I guess I just couldn't fit all my Transient use cases in a smaller one. I have a lot of these bad boys in my Emacs.
- submeta 1y agoWhen you have a hammer in your hand and try to use it for more than nails.
- bitwize 1y agoHey, has your favorite IDE been used to run German air traffic control?
- trey-jones 1y agoThis may be a bit pedantic, but Emacs-as-a-hammer metaphor might work better than you intended, since a hammer is definitely useful for more than just hitting nails. This seems pretty neat to me.
- iLemming 1y agoTypical reaction from someone who has no clue. Emacs isn’t a “hammer”; it's more like “glue” - you don't have to do everything _with_ Emacs, but it can definitely mediate and delegate specific tasks to more specialized tools - it can give you the sense of doing everything _through_ Emacs. Why would anyone do that? Because plain text rocks. > There is no equivalent in any other communication technology for the social, communicative, cognitive and reflective complexity ¹ And there's simply nothing better today than Emacs for dealing with the plain text. Neovim comes close, but still can't match it. __ ¹ Graydon Hoare: Always bet on text https://graydon2.dreamwidth.org/193447.html https://graydon2.dreamwidth.org/193447.html
- Igrom 1y agoI know that you are a stalwart Emacs supporter — I've seen your posts before, and still remember your airplane awakening — but don't you think that more carrot than stick would be more effective at convincing people to use Emacs?
- iLemming 1y agoI may not sound nice at times, but I strive to be kind. Kindness implies honesty. Why is it easier to learn a foreign language around kids? Because kids (with no malice in their hearts) would tell you the truth - when you mispronounce things, they'd laugh at your mistakes. When it comes to spreading truth about Emacs, I'd rather be like a kid. I don't think the comment above justified characterizing it as a "stick", but I suppose that is something you wanted to say to me long ago, and I appreciate your veracity. If you give me more constructive suggestions for changing my rhetoric, I may even promise to consider changing my narrative, but at this point, I don't even see what's wrong with it, really.
- submeta 1y agoYou don’t have to tell me what Emacs is capable of. Been using it for all my computational use-cases for years. But migrated away from it because it is obvious that each use case has better solutions outside Emacs. I am convinced the Unix way (do one thing and do it well, connect them via pipes and text) is the way to go.
- lycopodiopsida 1y ago> I am convinced the Unix way (do one thing and do it well, connect them via pipes and text) is the way to go. I was convinced too, but after the amount of work required to convince terminal, tmux and neovim to be friends I thought “It would be nice if all of it would be in one sane configuration language and actually debuggable!” These days, if I need unix tools (use rg a lot) I plug them into emacs.
- iLemming 1y ago
- swyx 1y agoi love this but dont use emacs. i wish that existing tools were lighter weight at video trimming. Screenflow is the lightest i know of but fails badly at some video formats and sometimes OoMs. if it had a better architecture streaming bytes i feel like it might not have that problem. any other light weight trimming people have?
- xenodium 1y ago> Screenflow is the lightest i know of but fails badly at some video formats and sometimes OoMs I'm a big fan of ScreenFlow, but light it is not ;) If you just want to trim and assuming you are on macOS, QuickTime's "Edit > Trim..." does the job. It's what I used before doing the Emacs thingy.
- latexr 1y agoI find my approach lightweight, but it’s still around 80 lines of code so a tad big to share as an HN comment. It also requires a bit of explanation to set up (though once done, it’s incredibly simple to use) and the output is custom to my needs. Essentially, I already use mpv as my video player, which in addition to being very fast also allows seeking frame-by-frame, saving and returning to positions, and running Lua scripts. So I wrote some Lua which reacts to a specific key press by saving the current video timestamp. Press it again and it records a second timestamp, then it fires off Handbrake CLI (FFmpeg could also work) to do the cutting and save the trimmed file. If you search online for “mpv cut video” you should find some plugins with that same idea. I have never used them so I can’t attest to how good or bad they are. All the ones I found are larger than my approach, but then again I just made mine do exactly what I want without customisation so that’s to be expected. One specific advice I’ll give, if you go this approach and are on the Apple ecosystem: Use the Handbrake CLI instead of FFmpeg to do the cutting. FFmpeg was super frustrating and I was unable to get a result where the output video worked properly in Quick Look and sending through iMessage; after too long trying to get it to work and messing with a myriad flags, I switched to Handbrake with no weird settings and it’s been working flawlessly ever since.
- jcynix 1y agoLightweight? I don't mind a bit of weight if its versatile. But when I want to do things fast, I use Shotcut (free, open source) which is much easier to use than e.g. ffmpeg. There exist a number of good tutorials showing how to accomplish tasks. https://en.wikipedia.org/wiki/Shotcut https://en.wikipedia.org/wiki/Shotcut P.S. What's great about tools like emacs or ffmpeg is their usability via a command line and thus scripting. Which even works on an Android device running inside Termux.
- rickdarlino 1y agoEverything seems like a nail these days. Probably uses his smartwatch to spread butter, too.
- xnx 1y agoImpressive, but I'll stick with LosslessCut (https://github.com/mifi/lossless-cut https://github.com/mifi/lossless-cut)
- deleted 1y ago[deleted]
- beklein 1y agoVery cool tool, and always amazing what Emacs can do... If this isn’t your _daily_ use case and you only need to edit video from time to time, just ask your preferred LLM to give you the FFmpeg commands to cut, speed up, mute, flip, add text, etc. This has worked quite well for me with simple use cases, and well no need to learn Emacs.
- latexr 1y agoThat’d be an awful way to cut video, because it wouldn’t help with the most important part: visualising and extracting the exact initial and final time stamps. Especially if you don’t do this regularly, a GUI makes much more sense and saves you the frustration of having to sift through potentially wrong commands and figuring out what exactly to edit to fix the mistakes.
- beklein 1y agoI’m not saying this is better than a GUI, but instead let me give you an example. Sometimes I have movie clips A, B, and C. I want to trim part of A at the beginning and end, then stitch clip B to it while speeding it up by 2x, and finally add clip C at the end, also trimmed a bit. After that, I want to add some text at specific times for a specific duration. In the end, I’ll export everything in 1080p. I know all of this can be done with Final Cut or any other video editing app using a GUI, or the cool Emacs tool above... But for me this would mean (GUI example) downloading the app and watching YouTube tutorials just to learn what to click. For simple video editing (and other tasks), I sometimes need to get the job done quickly without wanting to learn a whole new tool. I found out that I can achieve sufficiently advanced video edits with FFmpeg commands produced step by step from a LLM. If you think this is awful, ok. I thought it was neat and wanted to share the idea.
- latexr 1y agoI’m having a hard time believing your example. If you ever needed to do that more than once, using a basic video editor (of which there are many, free and open-source, no need for a commercial behemoth like Final Cut), playing with it for ten minutes once would give you all the knowledge you need forever, even when you are without access to your LLM. And you can keep the app installed, you don’t need to download it every time. There’s also no need to watch YouTube videos, most of these basic editors have evident interfaces that anyone could figure out on their own for simple tasks. People did figure out things before YouTube tutorials. Or hey, if you’re that keen on LLMs, ask them where the option you want is. Furthermore, you have not addressed at all the crux of the point. How are you even getting the exact time stamps to give to the LLM of FFmpeg for the cut? Or how do you decide that 2x is the exact speedup you need? Or how do you know what size and position and text font and colour even make sense? All of those are visual decisions which need confirmation because video is visual. It doesn’t make sense to blindly run lengthy FFmpeg commands over and over to see if the result is any good.
- smw 1y agoAll of your links to your own posts in your blog seem to be broken -- relative links need a "/" at the beginning, I think?
- _ache_ 1y agoIt's odd. There multiples problems on that blog. https://xenodium.com/emacs-as-your-video-trimming-tool/ https://xenodium.com/emacs-as-your-video-trimming-tool/ Is fixed and also fix various typo in the blog post. Bbut has other bugs, for example, the title link redirect to the bugged URL. But (the bugged URL): https://xenodium.com/emacs-as-your-video-trimming-tool https://xenodium.com/emacs-as-your-video-trimming-tool Have the problems with relative links you talked about.
- xenodium 1y agoHey, thanks for reporting. I had a couple of links that went haywire. Please lemme know if you run into other issues. First link to https://xenodium.com/seek-and-you-shall-find https://xenodium.com/seek-and-you-shall-find was broken. Should work fine now.
- taeric 1y agoMassive kudos on this! Could see elevating this to a full blown "ffmpeg-mode" that allows other forms of editing that is common from that tool.
- dfltr 1y agoI love that (and I say this with zero shade intended) you can never really tell which "Use Emacs for x" posts are goofs and which ones are serious.
- deleted 1y ago[deleted]
- cpldcpu 1y agoYou what is even easier than using Emacs to operare ffmpeg? Just use claude-code (or one of the other CLI code-agents)...
- iLemming 1y agoEmacs can do that too. Plug gptel and voila.
- layer8 1y agoThis supports the meme of Emacs as an operating system. It would actually be nice if graphical integrations like that could be implemented as easily on our actual OSs.
- JohnKemeny 1y agoEmacs is an elisp interpreter.
- finaard 1y agoNice, I was just about to do something like that as I didn't find anything ready last week when I got annoyed yet again when trimming a video.
- Zobat 1y agoThis is impressive, but (and probably because I'm not the intended audience for this post) I don't get it, I kind of want to get it though. With "it" I mean making Emacs do X, where X is something far from editing text files. It always seems to me like playing Doom on a pregnancy test. Sure you can do it, sure it's impressive, but should you? n.b. I'm a C# developer that has accepted my fate and use Visual Studio to earn a living, though I've made sure I know my tool, flaws and merits, better than most developers I've met/worked with. My first job as a programmer was writing C++ code in Emacs and can't remember anything negative about that experience (other than getting used to ctrl+x, ctrl+s for saving and, by reflex, doing the same in Excel, and losing a big part of the document that I had just selected to move, because Excel couldn't undo past last save). Reading the (at the time I'm writing this) 13 comments on this post I see mentions of at least three lightweight programs that does this. What other than "the mountain is there" makes someone think Emacs would be the tool for this? As a Resolve user I know what tool I'd reach for even if using a multi GB, Hollywood grade, non linear editor, compositor and color grader for trimming a short video clip is about as ridiculously overpowered as using a sledge hammer to press a key (and I did exactly that just a few days ago). Like I said, I'm most likely not "getting it", on multiple levels. Please educate me, why would I use Emacs for this or any of the page upon page of "strange" use cases you find if you search for "Emacs" here on HN. I know Emacs is a powerful editor but I can't for the life of me understand why I would use it to trim video clips.
- kelvinjps10 1y agoGreat comment, although I use emacs for everything code, writing, finanaces, task management still all these things are text so I don't get using emacs for non text things
- iLemming 1y ago> I don't get using emacs for non text things What do you mean by "non-text things"? You are dealing with the computer, it's all about text and mostly text. Sure, it might be encoded and digitized, but even structured binary - is all just text. Even when you give a computer voice commands - they are just synthesized audio form of fucking text. Even with "turtles all the way down" - it's all turtles made of text. Have you seen the gif in the blogpost? With the transient that has "Move Forward/Backward", "Increase", etc. commands? The commands that you'd have to send to the specialized app anyway - Emacs or not. In what form? Fucking text, of course.
- tombert 1y agoThis is pretty interesting; I had never thought of using Emacs as a video trimming thing, but why not? I've trimmed videos manually with FFmpeg and I've thought about building my own GUI to do it, so Emacs is as good a choice as any. I don't really use Emacs but I love that people use it for everything; next step is a non-linear video editor.
- sexyman48 1y ago[flagged]
- tombert 1y agoI'm not sure how you'd do it "properly" with libavcodec while still doing a regular Emacs plugin. It's 300 lines and in pure Emacs lisp, it doesn't seem boneheaded to me.
- sexyman48 1y agoI'm not sure how to libavcodec while still doing Emacs I'm glad you see my point.
- tombert 1y agoI just don't think it's that bad. Even if it spawns a process for each frame when you're scrubbing, it seems to run fast enough on my computer. If you want to do a lot of advanced video editing then yeah use a real editor, but if you're just doing a quick trim it's really not a big deal to spin up a few dozen very-short-lived processes.
- mr_toad 1y agoIt’s probably be more efficient to convert the video to multiple frames in batches, and then buffer them. Spawning processes is pretty resource intensive.
- tombert 1y agoI mean, "resource intensive"; that's technically true but the processes are pretty short-lived and only one spawns at a time as far as I can tell. It's definitely more overhead than an in-thread thing, but still not that much on modern computers. I agree that it would be more efficient to do these things in batches but I really don't think its current state is that bad, at least for a V1.
- 1y ago
- yashasolutions 1y agoPretty neat. I use Emacs a lot, and also do quite a bit of video trimming. For people wondering "why Emacs?", here’s the use case: trimming video is mostly about writing down start/end times, sometimes with a note. That’s all text. If you can turn that text directly into clips without switching to a separate video editor, it’s surprisingly efficient. Of course, this only makes sense if you already live in Emacs, then it reduces context switching, helps to keep the flow. If you don’t, it just looks odd. But it’s not about making a meme out of "doing everything in Emacs" - it is just a small tool that fits the workflow of people who are already in that environment.
- __mharrison__ 1y agoHaving been an Emacs user for 25+ years, I have a bunch of muscle memory. So I created Emacs shortcuts for Davinci Resolve. (I create a lot of videos, and every time I've attempted to outsource editing, it has always been more work to review and give feedback than to just do it myself. I have a routine using the AI transcription features of Resolve that lets me edit video very fast. Editing a one-hour video might take 2-3 hours).
- 3shv 1y agoCould you explain your workflow in a video?
- prawn 1y agoI'm also interested in hearing more about your process. I get bogged down going through my footage either comparing similar options, or trimming to the best action (best focus, least shake). I find the default Resolve keyboard shortcuts to be fast, and trim in the Edit mode (whatever #4 is called), but I'd love an AI augment that colour-coded clips based on which segments might be best (e.g., eyes/face in focus, or require least stabilisation, etc). I have a Resolve Speed Editor panel but just found that to be far slower than the keyboard.
- mhh__ 1y agoI had a daydream about a DJ using Emacs once
- kickingvegas 1y agoWe are out here.
- iLemming 1y agoThey exist: https://www.youtube.com/watch?v=l3h773bycP8 https://www.youtube.com/watch?v=l3h773bycP8
- ks2048 1y agoOther responses were getting at the same ideas, but to put in concisely, an Emacs-based solution is: 1. keyboard driven 2. programmable 3. within an ecosystem they are already within (lightweight, cross-platform, etc).
- AdieuToLogic 1y agoYears ago, a friend of mine said to me: Given enough time, any actively maintained application will become an operating system. This has held for emacs, Microsoft Excel, Microsoft Word, and probably vim as well. Honorable mentions for AutoCAD, Blender, and Eclipse too. :-)
- shadowgovt 1y agoAnd the browser, which is functionally now a virtual machine with sandboxing that also happens to have native support for HTML rendering and a couple natively-interpreted languages.
- lupusreal 1y agoI've been using emacs for light video editing too, but I took a different approach. Instead of having emacs deal with video directly, I use emacs as a JSON IPC client of mpv, over a unix socket, which handles the video. Over that IPC link I can control mpv playback (optional) and get timestamps/etc to add into an Edit Decision List (EDL) file.
- skeezyboy 1y agoAuthor needs money from you but lives in London. Maybe he should move somewhere cheaper
- xenodium 1y ago> Author needs money from you but lives in London. Maybe he should move somewhere cheaper Wow. Is this because I wrote the following on my blog? "Find video-trimmer-mode useful? Want me to publish to MELPA? Enjoying this blog or my projects? I am an indie dev. Help make my work sustainable by sponsoring. Need a blog? I can help with that. Maybe buy my macOS/iOS apps too ;)"
- delichon 1y agoLiving in London isn't as much of a luxury as living on a personal yacht, but it is something of a luxury for a dev who has choices. I could see weighing it in my sponsorship decisions. As a dev living in a very low density, inexpensive rural area I have more resources for my side projects than otherwise. If I were buying rather than donating, it wouldn't factor in at all.
- iLemming 1y agoWhoa, that is an enormously terrible take. Consider that an average programmer over the lifetime of their career can produce the equivalent of 4-10 "War and Peace" volumes - just in pure estimation of numbers of words in their code. I'm not even speculating about the profound impact some software makes for the betterment of the entire human race. And many share their hard work with the world for absolutely nothing in return. Imagine if someone said: "Why should Tolstoy be entitled to get paid for writing 'War and Peace'? After all, he's an aristocrat, a Count..." Well, Tolstoy did later in his life reject copyright on many works, believing literature should be free, and his wealth allowed him to write "for fun, not profit," but honestly, wouldn't you feel honored to "buy the guy a coffee" back in the day - given that you really appreciated his work? Or you'd immediately put him in the same position as Onlyfans influencers if the epilogue of his book ended with: "You can send your support to ..."
- kookamamie 1y ago> The solution relies on ffmpeg to do the heavy lifting and is roughly 300 lines of code Checked the source and it seems to make a lot of assumptions on the output format, codec and quality.