Giter Club home page Giter Club logo

sspenc's Introduction

SSPEnc using ffmpeg (simple streaming platform encoder)

This repository contains a Python script that utilizes FFmpeg to encode video files into different resolutions and extract audio into an MP3 file. The tool employs multi-threading to optimize the encoding process for various resolutions concurrently.

Prerequisites

  • Python 3.x
  • FFmpeg installed and added to system PATH

Installation

  1. Clone the repository:

    git clone https://github.com/Sprechender/SSPEnc.git
    cd SSPenc
  2. Install required Python packages:

    pip install -r requirements.txt

    or

    pip install ffmpeg-python argparse

Usage

Run the script:

python main.py <file_path>

Replace <file_path> with the path to the video file you want to encode.

Code Overview

Dependencies

  • argparse: Parsing command-line arguments.
  • time: Handling time-related operations.
  • ffmpeg-python: Python FFmpeg bindings.
  • threading: Managing concurrent execution using threads.

Script Logic

  1. Argument Parsing: The script uses argparse to accept a single argument - the path to the file to be encoded.

  2. FFmpeg Functions:

    • ffmpeg_func: Encodes the video file into different resolutions concurrently.
    • convert_to_mp3: Extracts audio from the video file into an MP3 format.
  3. File Validation:

    • Checks if the provided file exists. If not, it displays an error message and exits.
    • Creates an "encoded" directory if it doesn't exist already.
  4. Video Resolution Handling:

    • Determines the height of the input video file.
    • Defines resolutions to encode the video into (1080p, 720p, 360p, 144p).
    • Initiates encoding threads for resolutions supported by the input video's height.
  5. Execution:

    • Starts threads for video encoding and audio extraction.
    • Waits for all threads to complete their tasks.
  6. Performance Measurement:

    • Calculates the execution time of the entire process.

Example

python main.py path/to/your/video.mp4

This command will concurrently encode the video into different resolutions and extract its audio into an MP3 file, all within the "encoded" directory.

License

This project is licensed under the MIT License - see the LICENSE file for details.

sspenc's People

Contributors

sprechender avatar

Stargazers

 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.