Giter Club home page Giter Club logo

video-compression's Introduction

Video Compression Script

This Python script compresses an MKV video file to an MP4 format while preserving embedded subtitles and audio tracks. It uses ffmpeg to perform the compression and saves the log information to a specified text file.

Prerequisites

  • Python 3.x
  • ffmpeg installed on your system
  • ffprobe installed on your system

Installation

Install ffmpeg and ffprobe on your system. For macOS, you can use Homebrew:

brew install ffmpeg

Usage

Update the script with the paths to your input video file, output video file, and log file.

Run the script.

The script can be found in here:

Video Compression Script

Explanation

  1. Calculate Duration and Bitrate:
  • The script first calculates the duration of the input video using ffprobe.
  • It then determines the total bitrate needed to compress the video to the target size of 4GB.
  1. ffmpeg Command:
  • The script constructs an ffmpeg command to compress the video.
  • It maps all streams from the input file, excludes the problematic stream #6, and sets the video codec to libx264.
  • The video bitrate is set to 75% of the calculated total bitrate.
  • Audio tracks are encoded using the aac codec at 128k bitrate.
  • Subtitles are encoded using the mov_text codec.
  • The -max_muxing_queue_size option is set to prevent muxing queue overflow.
  • The -y option is used to overwrite the output file if it already exists.
  1. Run the Command:
  • The ffmpeg command is executed, and the log output is saved to the specified log file.

Logs

  • The script saves detailed log information to the specified log file. This log can be reviewed to troubleshoot any issues that may arise during the compression process.

Notes

  • Adjust the audio bitrate if higher audio quality is needed.

video-compression's People

Contributors

iliaryzhkovpr 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.