June 29th, 2024

LosslessCut: The Swiss army knife of lossless video/audio editing

LosslessCut is a versatile FFmpeg GUI tool for fast, lossless media operations. It supports cutting, merging, editing, and more on various formats. Available on multiple platforms with advanced features and automation options.

Read original articleLink Icon
LosslessCut: The Swiss army knife of lossless video/audio editing

LosslessCut is a versatile cross-platform FFmpeg GUI tool designed for fast and lossless operations on various media files. It supports features like lossless cutting of most video and audio formats, smart cut, rearranging segments, merging files, stream editing, snapshots, metadata editing, and technical data viewing. The tool is available for download from multiple sources including Mac App Store, Microsoft Store, Snapcraft, Flathub, and GitHub Releases. LosslessCut supports a wide range of formats and codecs, with the ability to convert unsupported formats for lossless cutting. It offers a user-friendly interface with keyboard shortcuts, timeline zoom, video thumbnails, audio waveform, undo/redo functions, and advanced features like CLI and HTTP API for automation. For more information, including detailed features, supported operating systems, and download options, users can visit the LosslessCut GitHub page.

Link Icon 27 comments
By @pixelmonkey - 4 months
Looks like an open source competitor to this absolutely magical app I used to use back in my Windows media PC days, way back when, which was called VideoReDo.

(Unfortunately, VideoReDo was proprietary, produced by an indie developer, and that indie developer recently passed away.)

For those who don't really get what "lossless" video editing is all about, consider that most video editing software always involves these stages: importing video/audio "clips", storing the video/audio timelines in some sort of "app native" format (e.g. Pitivi, Premiere, Final Cut), and then exporting the completed video in one or more output formats (e.g. MP4, MOV), re-encoding the entire thing from scratch.

This means that if your only goal is to, say, cut 30-90 seconds out of a 1-hour video, you're still going to have to re-encode the entire 1-hour video. That also means if your re-encoding system isn't a match for however the original video was encoded, you'll make some changes you didn't intend via the re-encoding (e.g. video or audio quality changes).

With this "lossless" style of editor, however, it'll figure out a way to "snip out" the 30-90 seconds (you can think about this being "at the byte level") without re-encoding the entire thing.

By @manca - 4 months
When I read lossless, I immediately thought about the editing of the real lossless formats like ProRes, MJPEG2000, HuffYUV, etc. But what this ultimately does it remuxes the original container in a new one without touching the elementary stream (no reencoding).

It's no wonder that it uses FFMpeg to do the heavy-lifting, but I think it's worthwhile for the community to understand how this process ultimately works.

In a nutshell, every single modern video format you know about - mp4, mov, avi, ts, etc - is ultimately the extension of the container that could contain multiple video and audio tracks. The tracks are called Elementary Streams (ES) and they are separately encoded using appropriate codecs such as H264/AVC, H265/HEVC, AAC, etc. Then during the process called "muxing" they are put together in a container and each sample/frame is timestamped, so the ESes can be in sync.

Now, since the ES is encoded, you don't get frame-level accuracy when seeking for example, because the ES is compressed and the only fully decodable frame is an I-Frame. Then every subsequent frame (P, or B) is decoded based on the information from the IFrame. This sequence of IPPBPPB... is called GOP (Group of Pictures).

The cool part is that you could glean the type of the frame, even though it's encoded by looking into NAL units (Network Abstraction Layer), which have specific headers that identify each frame type or picture slice. For example for H264 IFrame the frame-type byte is like 0x07, while the header is 0x000001.

Putting all this together, you could look into the ES bitstream and detect GOP boundaries without decoding the stream. The challenge here is of course that you can't just cut in the middle of the GOP, but the solution for that is to either be ok with some <1sec accuracy, or just decode the entire GOP which is usually 30 frames and insert an IFrame (fully decoded frame can be turned into an IFrame) in the resulting output. That way all you do is literally super fast bit manipulation and copy from one container into another. That's why this is such an efficient process if all you care about is cutting the original video into segments.

By @dang - 4 months
Related:

LosslessCut: lossless video/audio editing - https://news.ycombinator.com/item?id=33969490 - Dec 2022 (153 comments)

Lossless-cut: The swiss army knife of lossless video/audio editing - https://news.ycombinator.com/item?id=24883030 - Oct 2020 (10 comments)

LosslessCut – Save space by quickly and losslessly trimming video files - https://news.ycombinator.com/item?id=22026412 - Jan 2020 (1 comment)

Show HN: LosslessCut – Cross-platform GUI tool for fast, lossless video cutting - https://news.ycombinator.com/item?id=12885585 - Nov 2016 (33 comments)

By @capitainenemo - 4 months
FWIW, below is a bash script I've used for generating ffmpeg cuts, based off of a pretty useful stackoverflow suggestion. Input to the script is a file consisting of start/end times in seconds, one set per line. If the video has no sound, it looks pretty much the same, just without the atrim/outa parts.

    C=0;echo -n "-filter_complex '";
    while read f;do
        A=($f);echo -n "[0:v]trim=start=${A[0]}:end=${A[1]},setpts=PTS-STARTPTS[${C}v];[0:a]atrim=start=${A[0]}:end=${A[1]},asetpts=PTS-STARTPTS[${C}a];";C=$((C+1));
    done <$1
    for i in `seq 0 $((C-1))`;do echo -n "[${i}v][${i}a]";done
    echo -n "concat=n=$((C)):v=1:a=1[outv][outa]'"
    echo  ' -map "[outv]" -map "[outa]"'
By @jsheard - 4 months
To preempt the complaints about this being a 100MB+ Electron app, AVIDemux is a native app which does much the same thing if that works better for you.
By @hoistbypetard - 4 months
I just found this last week, and it was tremendously useful. I had filmed an entire dive competition with a small poolside camera, and wanted to cut it up into clips of individual dives. LosslessCut let me play it back as fast as I wanted (a little over 300% speed was the fastest I could use to listen for the gaps between divers), tap 'B' every time the scores were announced for a dive, then click export after I'd done that for all the dives. It took me less than an hour to split a 3 hour competition into nicely labeled clips I could share with each diver and their coach.
By @simple10 - 4 months
I'm a big fan of lossless cut and use it almost every day. Typical use case for me is to trim or edit screen recordings. Since it's lossless, the saving of the edited videos is almost instantaneous.

It's basically just a GUI for ffmpeg.

I then use Permute if I need to recompress, or Davinci Resolve if I need to add effects or lossy edits.

By @slimscsi - 4 months
GPL-2.0 license in GitHub. MIT license on snap store. $19 in Mac OS APP store.
By @sbt567 - 4 months
I wonder if its possible to losslessly download & cut video from remote server. Currently i'm using a bash script with ffmpeg i've got from stackoverflow to download a small portion of video from the likes of YouTube. But currently, it has to re-encode the video on the fly while downloading. For now, I assume it's impossible to losslessly download & cut this kind of video because we don't have the information about the video locally (keyframes, etc). But I like to be proven wrong!
By @heartag - 4 months
I just found out about this app recently and love it. Hard to believe I ever fired up a full blender instance and video project to cut clips, much less regularly.
By @relwin - 4 months
Also useful for archiving large video files to DVD-R, just cut into 4Gbyte chunks and write to a few discs.
By @hannasm - 4 months
Given the OS'iness I'm sure the information is available but would anyone be interested in linking the code containing the interesting ffmpeg args or does the project have documentation bridging the gap between ffmpeg and lossless cutting technique?
By @NKosmatos - 4 months
Reminds me of VirtualDub from the good old days :-)
By @IshKebab - 4 months
How does it work if you want to cut at a B frame?
By @dsp_person - 4 months
I wish there was a way to crop lossless and with deleting the unused data (not just metadata/bitstream filter). I feel like it must be technically possible with some kind of partial re-encode.
By @jpnguyen - 4 months
Used this a bit. Great free tool. Not always precise on cuts depending on the available keyframing, and takes some trial and error iteration, but definite a quick way to not have to re-encode the whole file.
By @cf100clunk - 4 months
For those who capture cable or antenna broadcast TV programs or use HDMI capture devices like the Hauppauge HD-PVR, MythTV has had frame-exact editing of TS recordings for many years.
By @ChrisMarshallNY - 4 months
This looks really well-done!

Not sure that I have a use for it, myself (although I could have used it back in my wageslave days).

I know exactly how difficult this type of thing is, so hats off to making it easy.

Best of luck with it!

By @TacticalCoder - 4 months
That's an Electron wrapper on top off ffmpeg right?
By @nathancahill - 4 months
I use and love Shutter Encoder, I wonder how it compares?

https://www.shutterencoder.com

By @Scotrix - 4 months
Looks great. what do you usually use to put some simple animations/text (not subs) into a recorded video?
By @nanna - 4 months
Anyone have tips for removing audio noise from a VHS transfer? Linux and ideally Foss?
By @feverzsj - 4 months
Not as stable as avidemux, though avidemux is already quite buggy.
By @MitPitt - 4 months
I wonder how it compares to Handbrake