this post was submitted on 13 Oct 2024
26 points (100.0% liked)

Free and Open Source Software

17949 readers
47 users here now

If it's free and open source and it's also software, it can be discussed here. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 2 years ago
MODERATORS
 

TLDR: Curtail losslessly compresses photos without losing date/time metadata. What program like Curtail can do the same with video's (preferably with MKV support)?

Curtail is FOSS Software for Linux that I've found extremely helpful. It's designed to bulk losslessly compress your images and photos without losing the date & time metadata in them. I've found this really helpful for skimming down the overall storage-use of my photo's.

But the thing that takes the most space on my PC is video's. You see, I record all of my videogame gameplay and store them on a hard drive. This takes many hundreds of gigabytes of space and is ever-increasing; and compressing them without losing any quality while retaining the date & time metadata is invaluable to me.

I'd love a program that functionally acts the same as curtail, but losslessly compresses each individual frame of a video rather than a photo. Curtail doesn't provide this, so does anybody know of any programs I can use that do this? MKV support is preferable, as that is how I store my video's, but still tell me about it even if it doesn't support MKV.

top 11 comments
sorted by: hot top controversial new old
[–] Maxy@lemmy.blahaj.zone 13 points 1 month ago

Unless your initial recordings were lossless (they probably weren’t), recompressing the files with a lossless flag will only increase the size by a lot. Lossless video is HUGE, which is why almost no one actually records/saves it. What you’re probably looking for is visually lossless transcoding, where you do lose some data, but the difference is too small for most people to notice.

My recommendations:

  1. Go to your recording software and change the setting to better compress your videos the first time around. Compressing once generally gives a better quality to size ratio than compressing twice. It’s therefore best if your recording software get it right first time, without you having to keep on recompressing your videos.
  2. When tinkering with encoding setting, trying to find what works best for you, it might be useful to install Identity to help you compare the original files and one or more transcoded version(s).
  3. Don’t try to recompress the audio; you’ll save very little space, and the losses in quality become perceptible much faster than video. When using ffmpeg, the “-c:a copy” flag should simply copy the original audio to the new file, without any change in quality or size
  4. I’d recommend taking some time to read through the ffmpeg encoding guides. H265 and AV1 are good for personal archiving, with AV1 providing better compression ratios at the cost of much slower encoding. You could also choose VP9, which is similar in compression ratio and encoding speed to h265.
  5. You’ll have to choose between hardware and software encoding. Hardware encoding can (depending on your specific hardware and settings) be 10-100x faster than software, but software generally gives better compression ratios at similar qualities. You should test this difference for yourself and see if the extra time is worth it for the extra quality. Do keep in mind that AV1 hardware encoding is only supported by some of the most recent GPU’s (rx7000 and rtx4000 from the top of my head). If you don’t have one of those GPU’s, you’ll either have to choose software encoding or pick a different codec.
[–] SomeoneSomewhere@lemmy.nz 7 points 1 month ago (1 children)

"Lossless" isn't the term you want; that refers to not lossily compressing the main data. Lossless compression or storage of media is very rare outside of text and sometimes audio, because it ends up so large.

You want to preserve metadata. That applies regardless of how lossy the data compression is.

[–] DreitonLullaby@lemmy.ml 3 points 1 month ago* (last edited 1 month ago) (1 children)

In that case, what I mean to say is that I want a program that compresses the video in a way that is not perceptible to the eye, while also preserving metadata and reducing the overall file size.

I'm not sure why "lossless" is not the right term, because that's the term that curtail itself uses within the app. Is the term misleading? The app is designed for photos, not videos. It compresses each photo without losing any quality, and slightly decreases the overall file size without losing metadata. I want a program that can do the same thing with videos.

[–] chaos@beehaw.org 2 points 1 month ago (1 children)

"Lossless" has a specific meaning, that you haven't lost any data, perceptible or not. The original can be recreated down to the exact 1s and 0s. "Lossy" compression generally means "data is lost but it's worth it and still does the job" which is what it sounds like you're looking for.

With images, sometimes if technology has advanced, you can find ways to apply even more compression without any more data loss, but that's less common in video. People can choose to keep raw photos with all the information that the sensor got when the photo was taken, but a "raw" uncompressed video would be preposterously huge, so video codecs have to throw out a lot more data than photo formats do. It's fine because videos keep moving, you don't stare at a single frame for more than a fraction of a second anyway. But that doesn't leave much room for improvement without throwing out even more, and going from one lossy algorithm to another has the downside of the new algorithm not knowing what's "good" visual data from the original and what's just compression noise from the first lossy algorithm, so it will attempt to preserve junk while also adding its own. You can always give it a try and see what happens, of course, but there are limits before it starts looking glitchy and bad.

[–] DreitonLullaby@lemmy.ml 1 points 1 month ago* (last edited 1 month ago) (1 children)

I know that lossy normally lessens the image quality in the compression process, but Curtail has two options:

Lossless mode: Compresses the file by removing unnecesary data that does not affect image quality; thus reducing file size. Lossy mode: Compresses the file much further by lowering the visual quality of the image; thus reducing the file size but looking a bit worse.

After using the lossless mode, I've personally done very thorough image comparisons to see if there was any discernible difference between the original file and the compressed file. I could not find any visual difference.

In Curtails own words on their site "It supports both lossless and lossy compression modes with an option to whether keep or not metadata of images."

[–] progandy 3 points 1 month ago* (last edited 1 month ago) (1 children)

Curtail is a wrapper around tools like pngquant, jpgoptim and oxipng. In lossless mode it optimizes and reorders e.g the compression tables. I know of no tool that does that for video data and I am not even sure that is feasable. Video is not stored as a simple sequence of images.

[–] DreitonLullaby@lemmy.ml 1 points 1 month ago

Okay, thanks. I guess it's not possible at the moment then.

[–] brickfrog@lemmy.dbzer0.com 3 points 1 month ago* (last edited 1 month ago)

I don't think it's possible, or at least not in the way you're thinking. Encoding a video with lossless flags usually results in a file size bigger or about the same as the source, and on top of that it takes a long time to actually do the encode.

Video is already highly compressed.

But for sure you can tinker around with ffmpeg (FOSS) & see how it goes for you. I've done it in the past just for kicks since some of the common video codec encoders do have lossless flags but it really wasn't worth the effort.

EDIT: That's just the video in the file, you also have to contend with the audio. That's a bit easier if you just want to use ffmpeg to dump everything into FLAC but again, I don't think you're saving much hard drive space if any.

[–] some_guy@lemmy.sdf.org 3 points 1 month ago
[–] AVincentInSpace@pawb.social 3 points 1 month ago

FFmpeg has FFV1 which is lossless

[–] Toes@ani.social 2 points 1 month ago

I'd suggest using IFME (https://x265.github.io/download.html) it does support MKV.

Due to the nature of video, using another codec will have some differences even if it's minimal.

But if you encode the video as AV1 with conservative settings it should be possible to reclaim a lot of that space with minimal impact.

Metadata should be retainable but you'll likely need to experiment.