Git Product home page Git Product logo

video-compressor's Introduction

video-compressor

(tl;dr) compress your videos in VID_YYYYMMDD_xxxxxx.jpg format into subfolders sorted by years with reduced filesize.
For images, see also: image-compressor

Use-case:

If you run out of storage on your smartphone and don't want to spend hours deleting and sorting out videos, one easy solution is to simply reduce the file-size of your videos on the backup device (Computer/HDD/NAS?) by using this script and shove them back to your phone.

Notes:

  • The naming-Convention VID_YYYYMMDD_xxxxxx.mp4 is assumed (default for most Android Camera-Apps).
  • The video_compressor script only deals with .mp4 files.
  • By default, file size will be reduced to about 55% of the original size, while maintaining acceptable quality (see also Quality adjustments below).
  • No files will be deleted!
  • A directory 'VID_compressed' is created which will hold the subdirectories VID_2019, VID_2020 ... per year respectively.
  • .mp4 files that have weird numbers after the extension (as i experienced in my case) are copied without changes.
  • Files without '.mp4' are being ignored.
  • The video-compressor does not run through subdirectories.

Simply place video_compressor.py at the place your videos are sitting and run it.

Installation (Unix-like, MacOS)

Eighter install FFMPEG or go through the (horrible) process of compiling it by yourself for proper hardware-acceleration, but regular installation will do:

sudo apt update -y
sudo apt install ffmpeg

or for Mac

brew install ffmpeg

There are discussions about self-compiling it, as people seemed to have experienced bugs (i didn't) or not much speed improvements by doing so.

Anyway, assuming Python (version >= 3.4) is installed, in terminal:

clone this repository, cd into it:

    git clone https://github.com/warneat/video-compressor && cd video-compressor

copy the script to your video folder e.g:

    cp video_compressor.py ~/foo/bar/videos

Optionally, clean up/delete repository with

    cd .. &&  sudo rm -r video-compressor

Run

In your video directory run the script with

    python3 video_compressor.py
or
    ./video_compressor.py

On Windows

  • Install or compile the video processing library FFMPEG
  • Download this repository or git clone https://github.com/warneat/video-compressor like above.
  • move the video_compressor.py script to desired location and run it from there with python .\video_compressor.py

Optional: Quality adjustments

  • FFMPEG takes a -crf argument to set the output quality. Higher values correspond to lower quality. For example 23 reduces the filesize to about 84 % compared to original. Default is 25 (file-size to 58%). They don't recommend values higher than 28 (filesize reduces 42%) Detailed Information about -crf flag

  • Lower values (higher output-quality) increase computing time dramatically

    To modify settings:

    • change crf=xx to your liking (line 39)

Further reading

  • FFMPEG really eats up all your computing-power!

  • As the processing might take hours or days for a large amount of data, when accessing via remote/ssh you might want to use screen (ultra-quick tutorial) to keep it running in background without an open terminal session.
    In a nutshell: Install it, $screen to start, [do stuff], ctr+a and d to detach. Reattach with $screen -r

  • To automate (video) backups e.g Phone to NAS/Cloud-Server/Online-Account... i highly recommend the app FolderSync

Feedback is very much apprechiated

video-compressor's People

Contributors

warneat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.