156 comments

[ 2.4 ms ] story [ 232 ms ] thread
nice, I needed a program like this. is there something similar for Android?
Finally. I have been longing for simple paint.net style video editor ...
I use this cut begining and end of pirate radio broadcast recordings (read: big MP3 which I don't want to reencode). Works well for this purpose.
LosslessCut is a lifesaver for cutting segments out of my usually-unedited podcast[1].

The workflow to do a minor edit in a full editor like Final Cut Pro looks roughly like:

- open Final Cut Pro

- create a new proj... oh shoot no, a new library? Yeah that's right.

- click import and track down the videos on my hard drive

- now create a new project and drag the videos into the timeline

- use the blade tool to cut out a segment

- export the video which is... uh... oh yes under the share menu bar and then the format needs to be... hmmm... I think export for YouTube

- wait approximately `videoLength/5` for the video to export

- oh my goodness my hard drive somehow has `videoSize*4` less space

In LosslessCut that workflow looks like:

- open LosslessCut[2]

- drag and drop your videos in

- mark the start and end times of either the segments you want to keep or the ones you want to take out

- hit export and... wow, it's already done? How is that possible?! And it's just in the same format as my source video! Perfect. Oh man and it even saved a little xml file so if I happen to open the same file again I haven't lost my human work of marking the in and out points.

The cuts are usually slightly off from where I'd ideally like them to be, I think because LosslessCut can only cut on i-frames[3], but it's a totally fair tradeoff for my use case.

I liked the minimalist editor interface so much I copied the timeline part of it for a dedicated social media video clipper I'm working on[4].

If you'd like to try it out I strongly suggest installing it from GitHub and donating the amount you would've spent in the macOS app store. The macOS app store version has fewer disk permissions and adds an extra step asking for access to each folder you want to edit in.

1. makers.dev

2. frustratingly, right clicking a video and selecting "open in LosslessCut" doesn't work

3. i-frames in most video codecs are "key frames" that repaint the entire frame. Most frames are p-frames or "predicted frames" which just store a delta from the last frame.

4. thevideoclipper.com

> The cuts are usually slightly off from where I'd ideally like them to be

That is (probably) because the editor uses certain marks in the video (I don't remember how they are called) that "group" the frames together, and you can't use simple editors to re encode the video.

I had this issue some time I tried to cut videos from my gf. Then I moved to ShotCut, that cuts the videos exactly where you want, although the walkthrough is a little longer.

Right, it will (by default) align the cut to the nearest I frame, which allows the cut to be "lossless." Doing the cut anywhere else requires re-encoding part of the video.
But ShotCut isn't lossless, is it? e.g

"“lossless” in Shotcut export does not imply the image goes through the engine untouched. It simply means that the codec is lossless or in lossless mode. The engine does not support every pixel format and color space in existence – only a few. Often sources get converted going through the engine. In your case, the source is RGB, but the engine defaults to yuv422 unless it has an mlt_image_format specified in Export > Other. For your 6SrK4.mp4, you would need mlt_image_format=rgb24 Also, in order to avoid image changes, you must use a Video Mode that matches the source and must not use any effecs (multiple video tracks, transitions, filters). (A mismatching video mode can cause automatic deinterlace, colorspace conversion, scaling, and padding)." –source: https://forum.shotcut.org/t/lossless-annoyances/18344

> The cuts are usually slightly off from where I'd ideally like them to be, I think because LosslessCut can only cut on i-frames[3], but it's a totally fair tradeoff for my use case.

There is an experimental "smart cut" mode where it re-encodes the video between your cut and the next keyframe. It will of course not be entirely lossless though

https://github.com/mifi/lossless-cut/issues/126

I think avidemux does the same thing.

https://avidemux.sourceforge.net/

Or ffmpeg (with 'copy' codec) or mkvtoolnix
or mpegstreamclip (select in, out & save as)
And mp3DirectCut for MP3 / AAC: https://mpesch3.de/

Or mp3splt for MP3 and Ogg Vorbis: https://mp3splt.sourceforge.net/mp3splt_page/home.php

For AAC/M4A there's also https://github.com/nu774/m4acut, which can split MPEG-4 based AAC audio and preserves gapless playback. (While mp3DirectCut can read AAC in MPEG-4 containers, it only ever spits back out the raw AAC stream, which lacks the necessary tagging for gapless playback.)

I've found handy for splitting up the occasional concert regording off Youtube back into individual tracks, and things like that…

Came to say that. I've modified avidemux it to drop the checks, since then I'm cutting in light speed, it's amazing +1
Protip: for simple lossless cutting, ffmpeg is more than enough. To make a 2 second clip starting from the third second of input file:

ffmpeg -ss 3 -t 2 -i in.mkv -c copy out.mkv

[edited to put -ss and -t before -i]

Don't do this. Place both ss and t before the input -i.

As output options, ss waits till the first KF after the given value, it's not a seek. With a t of 2, that may very well result in an empty video stream.

Of course (pretty sure LosslessCut using ffmpeg under the covers). But this is probably one of those instances where having a GUI comes in handy. You can quickly scrub the video for the exact point you want, see where the closest I frame is (read: the place where your cut is going to start), create multiple cut segments, etc.
For simple cases where you just cut a single clip out of a longer file, I find CLI to be faster. For more complex stuff like joining several clips together or manipulating multiple files, GUI is usually the better option indeed.
Losslesscut is infact a front-end to ffmpeg afaik
Yep, it's ffmpeg with 400MB more Electron.
> This app is not for exact cutting. Start cut time will be "rounded" to the nearest previous keyframe, which may be a fraction of a second before your desired cut point, or up to several seconds, depending on the encoding.

I found this problem with all ffmpeg-based editors...does anybody know of an editor capable of cutting between inter-frames? The same happens with sound files, which is inconvenient.

That's not "a problem with ffmpeg-based editors"; that's the only way to do it lossless.

Some containers such as Matroska are able to store an offset (and ffmpeg does that), so it starts playing from exact wanted position even though the actual stream contains data since the last keyframe. Some players ignore that though.

Depending on the encoder the GOP size / keyframe interval can be more or less unbounded as well. Typically you'd only have a few seconds per, but for example CCTV cameras are happy to produce minute-long GOPs. Seeking backwards in a video player tends to not work so well at that point, and most NLEs are significantly unhappy with such a file.
I wonder though if this could be solved with edit lists, supported e.g. by ISO BMFF. Not all players support them completely, though, for example I believe mpv only supports one edit, so I guess that's not useful for general purpose use..
When cutting with ffmpeg you can use "frame-accurate seeking", but you may run into issues down the road (e.g. audio/video being out of sync).
You can't do that at all in long-GOP formats without re-encoding.

What happens is that every so often it sends a complete image - the intra frame - and then sends differences to show what changes from frame to frame. This is a complete and utter pain in the tits to edit with, so most people transcode to an intraframe codec like DNxHR or ProRes although there's absolutely nothing wrong with MJPEG or MPEG2 intra-only.

If you don't re-encode, you're limited to cutting at an intra frame because that's where it starts drawing from. If you don't you get all this weird "ghost trail" stuff happening.

As has been said, this happens because of cutting on the closest keyframe, which is the only point where the cut can be done losslessly.

This is how it's been done traditionally, since basically forever as far as I can remember. To be honest, I think modern tools could do better. If you happen to want a cut just 20 frames after a keyframe, those 20 frames could be computed (decoded) in order to create a new keyframe right in the spot you wanted. There are a myriad tools to do the typical lossless easy cut, but no idea of one that goes the extra mile to do this more advanced technique.

UPDATE: Navigating the GitHub issues I found out that this is indeed an in-progress experimental feature! That's amazing -- https://github.com/mifi/lossless-cut/issues/126

> If you happen to want a cut just 20 frames after a keyframe, those 20 frames could be computed (decoded) in order to create a new keyframe right in the spot you wanted.

All the P-frames and B-frames in between two I-frames have to be recomputed. That’s by definition re-encoding and not lossless.

You could re-encode just that small segment though.

This would obviously be codec dependent, but I'm surprised it's impossible to losslessly re-encode a video given I, P, and B frames. Mentally, I think of P frames as containing "changes" in the frame. The changes would be the same regardless of whether or not the previous frame was an I or P frame.
> I'm surprised it's impossible to losslessly re-encode a video

It is possible, it will just be a ridiculously large video.

> Mentally, I think of P frames as containing "changes" in the frame. The changes would be the same regardless of whether or not the previous frame was an I or P frame.

P-frames in modern codecs use multiple previously decoded frames, not just the previous frame. And I'm not getting into the complexity of frame ordering (decoded frames and presented frames can be ordered differently).

Oh so the P frame after the one you want to cut at may be looking farther back than just one I frame. I guess you could do the lossless cut at the previous I frame as this tool does, then also set the start media timestamp to the frame that you actually wanted to cut at, as described elsetheread by NelsonMinar.
> set the start media timestamp to the frame that you actually wanted to cut at

You can do that, but it’s container format-dependent (e.g. mov edit list) and player support is uneven. If the player doesn’t support it you get extended cut and A/V desync.

> It is possible, it will just be a ridiculously large video.

Ha true, I guess you could encode every P/B frame after the cut as an I-frame.

It's perfectly possible, just not with the common media-mogul owned and propagated video encoding formats. There are applications where you need a compressed video stream that does not have keyframes, so that you are not blind until the next one if one happens to get scrogged in transit. (Think things like UAV pilots blowing up things halfway around the world.)

These algorithms had methods have existed for 20 years - nearly that long ago, I held in my hand a single DVD with thirty full-length movies on it - all compressed losslessly using such an codec on a laptop. I actually accepted a job with the company (they even sent tickets for the flight out to Seattle for my first day on Monday) before calling me on Friday afternoon to tell me that the company had been acquired by a government-related entity and my role (being public-facing) was not needed. (Pissing me off because I'd turned down another good offer to take theirs!) It's the only time I've ever even heard of getting laid off before you start. The company vanished from the face of the earth that week...

> I held in my hand a single DVD with thirty full-length movies on it

But at what resolution, fps, color space ? Storing the same gray scale image over and over again, as in most old security camera footage, takes up very little space.

Lossless encoding of 30 full-length movies on one DVD?

That's an extraordinary claim, I presume you can present the requisite extraordinary evidence?

With that kind of tech they can displace all the “media moguls”, combined. Realistically though, they’re probably talking about average-to-low-quality 480p rips fit for 90s TVs.
I agree, it's almost definitely bullshit, but the claim was lossless.

>single DVD with thirty full-length movies on it - all compressed *losslessly* using such an codec on a laptop

Decoding the “changes” can be dependent on the “changes” in a previous frame, notably that the prediction for motion vectors can come from previous frames’ motion vectors. Which I frames obviously don’t have.

Besides that the only way to losslessly re-encode frames is to use lossless encoding, which would easily be a 50-100x size bloat.

They could do much better than that, cut at a keyframe and change the metadata to start at the correct time.

You end up with a tiny bit of wasted data, but it's happy middle ground compared to having to give up the key selling point

MOV/MP4 files can do that, but most other video formats can't.

You can also leave out the B-frames prior to the new start time.

The problem with that is that the skipped data will still be present and therefore easy to recover if you know what you're looking for. That may "leak" seconds worth of video (and audio) the user may have thought was removed. And those seconds may contain something sensitive, e.g. a pan over some confidential information on some paper or screen, or genitals, or whatever.
It'd take one button with a label to solve that.
It would be lossless for the vast majority of the video, only the cut point would be lossy. I'm sure that is ideal for most people. Sounds like it's in progress.
B-frames should simplify this a lot. Only this very short portion would be re-encoded
Shotcut.org cuts the videos exactly where you want
> I believe software should be available to everyone, and LosslessCut will always be free for anyone to use and look at the code.

Costs $18.99 on App Store!

(comment deleted)

  brew install losslesscut  
is free :-)
If you click on the words "always be free", you will be taken to the GitHub project, from there click on the release in the right column, and then download it for your platform. The store links are for the "donation" purchase process.
That's the price of devs having to deal with shitty Apple ecosystem
There's a beta feature to exactly cut, and re-encode just the affected "block".
I love LosslessCut for capturing game footage and making GIFs.
Can this be used for video compression or is there a better tool? Currently I use Handbrake or online tools.
This is a tool for explicitly avoiding video compression.
Nice interface, simple and beautiful.

For casual video audio editing, I usually use Avidemux. Its Copy mode is similar in cutting out portions of the video without the lengthy re-encoding process. LosslessCut looks nice. I’ll give it a try.

I've a semi-related question. What's your workflow for matching torrented videos with subtitles that have been provided in the same torrent? Often the directory structure is

    Some.video.mkv
    Subtitles/Some.video/English.0.srt
and my players of choice (mpv and MPC) are unable to automatically make the match.
My solution was to use Sonarr, Radar, Bazarr, and Plex. Others are using Jellyfin.

This setup eliminated 99% of the time I spent on all media management.

mkvtoolnix to add the subtitles you want as well as remove the tracks that you don't need.
Virtualdub downloads as a 1.81 MB zip file.

This downloads as an 84.9 MB zip file.

I sure hope this does something Virtualdub can't / anything better than Virtualdub, my current preferred lossless video / audio editing Swiss army knife.

Can anyone confirm whether that is the case?

BTW downloads that don't require approaching Lord Appstore cap in hand can be found here:

https://github.com/mifi/lossless-cut/releases

Are people who edit video all that concerned about 80 MB? At current prices, that's like $0.005 of disk space.
I'm not about the 80 MB... but I'm rather concerned by the proliferation of Electron-based applications. They use way too much system resources. Like Chrome does... but for a browser (which is kind-of a "heavy" application) I still understand.
Statically linked FFMPEG executable is about 80 MB. As there is no need to ship entire FFMPEG when only lossless operations are to be used, I'm sure it can be reduced below 10 MB.
"Smart cutting" does some re-encoding work, so you couldn't throw out those parts of FFMPEG after all.
Looks like it has better meta-data support and you can mark multiple segments of a video, re-arrange and then do a stream copy to a new file. I've been using VirtualDub for decades (maybe the wrong way) but I think doing the same would have required steam-copying the segments to new files and then appending them together. Not a fan of the interface based on the screenshot but I think it's worth giving it a try.
Can this fix videos where an orientation change happens partway through?
If you mean a video where the camera was rotated while recording, I believe no, that's not possible to do losslessly. I believe the orientation flag stored in the metadata cannot change over time. Correct me if I'm wrong. - author
Been using this for years, it's a very good and simple tool. There's a surprising amount of garbage in this space. SEO spam infects any searches you do for video editing software. Many "cut" tools actually just fiddle some start media timestamp in the file so the output file isn't smaller, just a video player will start at the right timestamp. Ie: not an actual cut. This one does the job.

It's implemented in Javascript with Chromium and the HTML5 video player. Not the way I would have thought to do it but makes cross platform a lot easier. You can do the same with ffmpeg on the command line of course but having a GUI to pick the cut points makes all the difference.

LosslessCut is great, but I needed something quick when I cleaned up old GoPro videos. Just open an mp4/mov in QuickTime Player, trim it and save under a new name. It will create a lossless cut. If you need several from same video, you would need to repeat the process on the original file.

(unfortunately, the trimmed video won't get the same metadata, so I also needed to use exiftool -TagsFromFile oldvid.mp4 -all:all newvid.mp4 )

Just tried this on a screen recording I made, really simple way to cut out boring bits e.g loading/waiting times, mousing etc. Great, I'll use this again!
Has anyone had experience merging two video files with this tool?
As long as the files are the same codec and resolution and stuff, it works just fine (I just used this earlier today to combine 20 short instagram stories into one video).
Merging works great. Drag multiple files to the main window. A dialog pops up to allow you to select the order of the files. Then merge and a new merged file is created.
I do it all the time, first cutting up my long GoPro videos in to the actually interesting segments and then merging those all together. Works great.
Been using this for a while to cut down gameplay footage I want to share with friends. It works well but I wish they implemented a simple way to combine multiple audio streams into one stream for upload to youtube/elsewhere.

From what I can tell, FFMPEG does support actions like that. Perhaps it's not "lossless enough" for the app author.

I'll keep an eye on this. I have a very technically interesting project soon which will require quite a lot of cuts; my thought was just "re-encode everything as I-frames" (all of the source material consists of clips under four minutes long). This might help.
If you'd prefer something command-line-based, I'd recommend mkvmerge: https://mkvtoolnix.download/

FFmpeg also works of course (it's what LosslessCut uses internally), but in my experience I've occasionally run into files where FFMpeg doesn't properly cut on keyframes and I end up with a few seconds of no image at the start of the video. No such problems with mkvmerge, and the API is much simpler.

Used this for ages. People will bring up various alternatives (including just strictly using FFmpeg) and I have to wonder if the only use case they can fathom is clipping 1 segment out of a longer video. All suggested alternatives would involve such a garbage workflow and unintuitive experience for any real project. I dislike Electron as much as anyone else but it works fine here, and does the job better than anything else I've tried. I am very comfortable with FFmpeg and have used pretty much any tool you can name, I still use Losslesscut daily.
Seems it uses ffmpeg on the backend anyway :)

Best tool for the job. I'll probably keep using ffmpeg to clip out a single segment, but it gets hairy when you have more complicated edits.

Not sure exactly what your use case is, but I use vidcutter for lossless clip extraction and it works great and does not require Electron (it's QT based I believe). https://github.com/ozmartian/vidcutter

To answer a point that's been brought up elsewhere in the thread, one nice feature of vidcutter is that you can either cut fully losslessly (on keyframes) or cut frame-perfect while only encoding the frames before and after the first and last keyframes in the cut.

The Arch Linux package for vidcutter is only 4 MB. It has dependencies, of course, but I already have all of them installed for other things. (There's nothing uncommon.) All praise to dynamic linking.

Vidcutter is good but no where near as customizable as Losslesscut (specifically in terms of keybinds) and using the timeline is nowhere near as smooth. Its being developed in a way I approve of much more but I still prefer using Losslesscut by a large margin. If it ever catches up I'll be thrilled because I do like what its about a lot more but I don't really think it currently competes in terms of user experience. Still if it works well for you then there's a lot to appreciate.
I use FFmpeg for multiple streams and mux them into another container file format. Don't see what LosslessCut does outside of FFmpeg expect for the UI. The backend is anyway FFmpeg as another comment mentions. CLI haters I can understand, not me.
I at times am chopping up 2-8 hour videos with dozens of clips that are not pre-defined for me. I can do this with FFmpeg and I love doing most things from terminal but its a pretty hard sell when what you're doing involves something inherently graphical. I use FFmpeg for all sorts of things but it just doesn't make sense for editing such large videos on the fly like this.
LosslessCut looks awesome! I also created a lossless video trimming tool a couple of months ago: https://videotrim.app LosslessCut seems to be more featureful but mine works in the browser without having to install it. It also has the same limitations since cutting times are rounded to the closest keyframes, but this way there's no need to re-encode anything.
That's very cool! are you using ffmpeg.js?
Thanks! Yes, it's built on top of ffmpeg.js.
This project has been my go-to example of the absurdity of Electron since its inception. This is a thin wrapper around ffmpeg, which does all of the real work here and is a much more powerful and versatile tool. Why does this ship an entire web browser? Why does this even exist? The world may never know.
(comment deleted)
> This is a thin wrapper around ffmpeg, which does all of the real work here and is a much more powerful and versatile tool. Why does this ship an entire web browser? Why does this even exist? The world may never know.

You answered "Why does this even exist?" yourself, it's a thin wrapper around ffmpeg. It provides a reasonably usable and friendly GUI to perform the kind of basic cuts a lot of people want to do with their video.

When I have two hours of GoPro footage I want to chop up in to a quick and dirty highlight reel, which one do you think I'm going to choose?

1. Fire up my favorite video player, scrub through every file noting the start and end times of every segment, turn each of those segment times in to a ffmpeg command line, and throw all those in a script.

2. Fire up LosslessCut, scrub through every video clicking "start segment" and "end segment" as appropriate, click "Export"

It ships a whole web browser because unfortunately that's the easiest way to make a cross platform GUI app these days, and they get video playback support "for free" (though this does result in some limitations with codecs other than H.264). Yes it's heavier than it could be, but I'm editing video here, I don't really care about megabytes of hard disk space or RAM.

There's nothing else like it as far as I'm aware. AviDemux only does one cut at a time, VirtualDub doesn't even run on non-Windows platforms.

It’s odd, because you’re framing these questions rhetorically, but you might be well served by asking them earnestly.

There are plenty of parallel comments on this page that describe why people like LosslessCut. It exists because its authors saw a niche they wanted to fill, and the userbase suggests they aren’t alone. How strange to look at that and call it “absurd”.

It's lovely you can remember or have the time to look up the right arguments in ffmpeg, others of us use GUIs for this, both ways of using the computer are valid.