Skip to content

patillacode/space-saver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Space Saver

space_saver.py converts video files to .mp4 format with H.265 codec. The script walks through a given directory and its subdirectories looking for files with a given extension (or all files if no extension is given), and converts them to .mp4 with H.265 codec.

The original file is deleted if the conversion is successful, and the new file is given permissions of 755. The script also calculates the space saved by the conversion and prints it at the end.

Setup

  1. Clone this repository.
  2. Navigate to the project directory.
  3. Run make install to set up the project.

Test

To run the tests: make test

Usage

usage: space_saver.py [-h] -p PATH [-e [EXTENSIONS ...]] [-c CRF] [-d] [-q] [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}]

Convert files to .mp4 with H.265 codec

options:
  -h, --help            show this help message and exit
  -p PATH, --path PATH  Path to the directory containing the files to convert
  -e [EXTENSIONS ...], --extensions [EXTENSIONS ...]
                        Extensions to filter, default: ['mp4', 'mkv', 'avi', 'mpg', 'mpeg', 'mov', 'wmv', 'flv', 'webm']
  -c CRF, --crf CRF     Constant Rate Factor for the H.265 codec, scale is 0-51 (default: 23)
  -d, --dry-run         Perform a dry run without actually converting files
  -q, --quiet           Keep the ffmpeg output to a minimum while converting
  -l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --log {DEBUG,INFO,WARNING,ERROR,CRITICAL}
                        Set the logging level (default: INFO))

    Examples:
        python space_saver.py -p /home/user/videos -e mp4 mkv
        python space_saver.py -p /home/user/videos -d
        python space_saver.py -p /home/user/videos -q
        python space_saver.py -p /home/user/videos -q -crf 28
        python space_saver.py -p /home/user/videos -q -l DEBUG

Some interesting ffmpeg commands for future reference:

Convert 4k to 1080 (no change in codec)

- ffmpeg -i input4kvid.mp4 -vf scale=1920:1080 -c:a copy output1080vid.mp4

Convert h.264 to h.265 (no change in resolution)

- ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 -c:a copy output.mp4

Convert 4k(h.264) to 1080(h.265) Downscaling + Change in compression codec

- ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 -vf scale=1920:1080 -crf 20 -c:a copy output.mp4

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published