Git Product home page Git Product logo

ffmpeg's Introduction

ffmpeg

Simple python bindings for ffmpeg using subprocess and progress metrics (tqdm).

Setup

Ensure ffmpeg is accessible in your PATH.

  • download/install ffmpeg (e.g. https://ffmpeg.org/download.html#build-windows)
  • add the executable directory to your system path if required, e.g. on Windows via GUI:
    systempropertiesadvanced.exe
    
    or via command line:
    set PATH=%PATH%;path/to/your/ffmpeg
    
  • ensure the executable is accessible:
    ffmpeg -version
    
  • install this ffmpeg package with pip:
    pip install git+https://github.com/pbouill/ffmpeg.git
    
    or clone to your local workspace and install the requirements:
    git clone https://github.com/pbouill/ffmpeg.git
    cd ffmpeg
    pip install -r requirements.txt
    

Use

Convert videos

  • Create an FFmpeg class instance with the input video file path:
from pathlib import Path
from ffmpeg import FFmpeg, VideoEncoders

ff = FFmpeg(input_path=Path('file.mp4'))
ff.convert(output_path=Path('converted.mp4'), vcodec=VideoEncoders.LIBX265, crf=35)

or convert an entire directory of videos with the "convert_all" class method:

from pathlib import Path
from ffmpeg import FFmpeg, VideoEncoders

FFmpeg.convert_all(videos_dir_path=Path('file.mp4'), vcodec=VideoEncoders.LIBX265, crf=35)

Add Chapters

  • Create yaml file with timestamps and chapter names in the format:
# events.yaml
file.mp4:
  00:00:10: chapter at 10 seconds
  00:01:00: chapter at 1 minute
  01:00:00: chapter at 1 hour
path/to/other/video/file.mp4:
  00:01:10: something interesting at 1 minute 10 seconds
  • Call the "add_chapters_from_yaml" class method
from pathlib import Path
from ffmpeg import FFmpeg

FFmpeg.add_chapters_from_yaml(yaml_path=Path('events.yaml'), inplace=True)

ffmpeg's People

Contributors

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