0

I have tons of phone media backup, and I want to reduce their size by compressing them.

For example compressing video files by encoding them to x265 codec, and for the photo files to lossless JPEG, but my problem is preserving metadata.

I want to simply drag and drop folders and it should compress media files without changing it metadata such as creation date or even modified date.

Joep van Steen
  • 4,730
  • 1
  • 17
  • 34
  • 1
    And your OS is …? – Kamil Maciorowski Nov 23 '22 at 23:48
  • Most media data, or many media data formats already apply some form of compression. JPEG always applies lossless compression on top of lossy compression for example. In general there's little to be gained by compressing media data. – Joep van Steen Nov 23 '22 at 23:51
  • @KamilMaciorowski my os is windows 10 – Halil Nevzat Demirel Nov 23 '22 at 23:56
  • @JoepvanSteen I had files shrinked by a factor of 1.5 up to factor 8 by compressing with x265. compression != compression – mashuptwice Nov 23 '22 at 23:56
  • @mashuptwice, what type of video was it? And was it lossless? – Joep van Steen Nov 23 '22 at 23:57
  • @JoepvanSteen Can't say in hindsight. Sample size was my entire video library with around 3TB. Most of it was in h264 and was 2-3x smaller after converting to h265. 8x was an extreme example which only happened with 3-4 files yet. For all samples I've used the default CRF of 28 – mashuptwice Nov 24 '22 at 00:18
  • @mashuptwice, yeah, so not lossless. thanks for the downvote BTW. – Joep van Steen Nov 24 '22 at 00:32
  • @JoepvanSteen h264 as well as h265 support lossless encoding, so based on my previous statements it cannot be guaranteed that the files were in fact lossy encoded. Check my comments under your answer for several reasons for my downvote, I could also provide even more if necessary. – mashuptwice Nov 24 '22 at 00:44
  • "h264 as well as h265 support lossless encoding" - it appears you're correct (https://linuxhint.com/h264-vs-h265/), then I stand corrected with regards to this specific example. – Joep van Steen Nov 24 '22 at 00:51
  • @HalilNevzatDemirel compressing on file level without altering metadata cannot be done easily, as the conversion will necessarily create a new file. [Handbrake](https://handbrake.fr/) should be capable of batch conversion. [You would need to modify the metadata afterwards](https://superuser.com/questions/71962/how-to-change-file-creation-time-in-the-different-file-systems). Enabling NTFS compression would probably be (without knowing your exact usecase) the easier method, but it will likely slow down your IO operations and is very inefficient for video files. – mashuptwice Nov 24 '22 at 00:55
  • @JoepvanSteen You are right and I have my peace and quiet. – mashuptwice Nov 24 '22 at 00:59
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 24 '22 at 03:11
  • You should also note that a lot of metadata added to video files is done so in non-standard ways. Specifically, EXIF data (All EXIF data is metadata, but not all metadata is EXIF data, most video metadata is Quicktime) and GPS tracks will be lost if you edit the files. Every camera manufacturer embeds this data in different ways, sometime in different ways between different models from the same manufacturer. – StarGeek Nov 25 '22 at 16:58

1 Answers1

-1

AFAIK, most media data, or many media data formats already apply some form of compression. JPEG always applies lossless compression on top of lossy compression for example (unless you specifically instructed lossless compression only, and if your encoder supports this, not many do). In general there's little to be gained by compressing media data*.

If you want drag and drop and your using for example NTFS, you could just enable NTFS compression for the folders containing the media files. This is lossless compression and will not alter EXIF data etc.

(*) EDIT: See for example https://linuxhint.com/h264-vs-h265/, it appears encoding for example h264 to h265 may help save disk space.

So depending on format, re-encoding may save disk space, in other cases it does not.

Joep van Steen
  • 4,730
  • 1
  • 17
  • 34
  • It should be made clear, especially as this is a newbie question, that enabling compression on a NTFS drive will [heavily impact its performance](https://superuser.com/questions/411720/how-does-ntfs-compression-affect-performance). – mashuptwice Nov 24 '22 at 00:00
  • Why link to the acronym of "as far as I know" without linking to the source of the knowledge? – mashuptwice Nov 24 '22 at 00:14
  • @mashuptwice, don't you have better things to do? The source of the knowledge is experience for example working with JPEG. Based on experience I know these are default lossless (Huffman) and lossy (transform coding) compressed. More compression can only be achieved by lowering quality. Much video and image data is high entropy data with little room for further increasing entropy. – Joep van Steen Nov 24 '22 at 00:26
  • @mashuptwice, he's referring to backups which I assume he's not accessing all the time. So selectively compressing specific folders shouldn't have that much effect on overall performance. – Joep van Steen Nov 24 '22 at 00:29