qfjp / MediaLibraryCompression

A script to convert video files to x265 codec in mp4 containers. Forces hvc1 for MacOS Big Sur compatibility
GNU General Public License v3.0
2 stars 1 forks source link

Store media files in (sqlite?) database #3

Open qfjp opened 1 year ago

qfjp commented 1 year ago

Building the list of files to convert every time this is run is painfully slow. A better solution might be to build a database of all convertible files, along with some metadata to detect if any of the files changed. If no changes detected, use the database instead of building a new list.

An example format:

Filename Path Last Seen Last Modified (System) Video Container VCodec
Titanic (1997) /home/user/Movies/ 2023-05-14 2020-01-23 Matroska HEVC
Moonrise Kingdom (2012) /home/user/Movies/ 2015-01-08 2019-09-12 Matroska AVC
Nope (2022) /home/user/Movies NULL 2023-02-16 MPEG-4 AVC

The table above would be built with some combination of the existing sqlite database and a 'find . -type f -regex \.(mkv|mp4)$' command. The column Last Seen would have been the last time this program collected information for that particular row's file, while Last Modified would be taken from the file's information in the filesystem. For those rows where the value in Last Seen is earlier than Last Modified, or if Last Seen == NULL, the information would be updated, skipping lots of redundant work.