Skip to main content

Python 3 scripts which use ffmpeg to convert videos to webm format (vp9+opus) or to convert audio to opus or vorbis.

Project description

Introduction

towebm is a Python 3 script to transcode video files to a webm container with VP9 format video and Opus format audio using the ffmpeg tool. Arguments are available for basic edit operations - crop, scale, cut, grayscale, and deinterlate - as well as for passing arbitrary ffmpeg video or audio filters. toopus and tovorbis will transcode audio from video or audio files to Opus and Vorbis format files, respectively, with many of the same features as towebm. Finally, ffcat will concatenate files using the concat demuxer, intended for joining multiple output segments produced by towebm from a single input file.

Usage

Transcode a source MP2 video with no edits and default quality settings:

towebm Great*.mpg

Transcode a source 1920x1080 MP4 video, which is cropped to 4:3 ratio (1440x1080), then scaled to 720 vertical resolution (960x720), and converted to grayscale. Video quality is set to 25:

towebm -q 25 -s crop43 -s scale23 -s gray Three*.mp4

Transcode a source MP4 video with a 140 and 144 crop from the top and bottom, respectively:

towebm -y 140 144 Music*.mp4

Transcode a source MKV video with a crop to all sides and an aspect-correct scale to 706 horizontal resolution:

towebm -x 260 260 -y 16 4 -f "scale=h=706:w=-1" Calif*.mkv

Transcode two minutes of a video, starting ten seconds from the start, using three different available options:

towebm --start 10 --duration 2:00 Calif*.mkv
towebm --start 0:10 --duration 2:10 Calif*.mkv
towebm --segment 0:10 2:10 Calif*.mkv

Transcode multiple segments of a video, with one output per segment:

towebm input.mp4 \
    --segment 00:00:30.300 00:07:04.900 \
    --segment 00:09:44.366 00:14:30.133 \
    --segment 20:42:49.300 29:20:01.400

Same as the previous example, but using multiple executions (especially useful if different filters need to be applied to the different segments):

towebm input.mp4 -# --segment 00:00:30.300 00:07:04.900
towebm input.mp4 -# --segment 00:09:44.366 00:14:30.133
towebm input.mp4 -# --segment 20:42:49.300 29:20:01.400

Join the output of the previous example into a single file:

ffcat input_*.webm final.webm

Transcode a segment of a video with a one second fade-in and half-second fade-out:

towebm input.mp4 --start 1:00 --end 2:00 --fade-in 1 --fade-out 0.5

Same as the previous example, but producing an output file with only opus audio:

towebm input.mp4 --start 1:00 --end 2:00 --fade-in 1 --fade-out 0.5

Transcode a portion of a FLAC audio file to vorbis, quality 4:

tovorbis -q 4 --start 1:00 --end 2:00 input.flac

Installation

Warning

Some Linux distributions discourage installation of system-level python packages using pip or setup.py install, due to collisions with the system package manager. In those cases, dependencies should be installed through the package manager, if possible, or choose a user folder installation method.

Installing with pip

If your system has pip installed, and you have access to install software in the system packages, then kantag kan be installed as administrator from PyPI:

# pip install towebm

If you do not have access to install system packages, or do not wish to install in the system location, it can be installed in a user folder:

$ pip install --user towebm

Installing from source

Either download a release tarball from the Downloads page, and unpack:

$ tar zxvf towebm-1.0.0.tar.gz

Or get the latest source from the git repository:

$ git clone https://github.com/dgasaway/kantag.git

If you have access to install software in the system packages, then it can be installed as administrator:

# python setup.py install

If you do not have access to install system packages, or do not wish to install in the system location, it can be installed in a user folder:

$ python setup.py install --user

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

towebm-1.0.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

towebm-1.0.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file towebm-1.0.0.tar.gz.

File metadata

  • Download URL: towebm-1.0.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.7.9

File hashes

Hashes for towebm-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dc5771513fea6ca42f17964ae0d5f029df53ec84be0d9de4bf43017d89a42f19
MD5 34b88a0cadcc4c89561316f84a87ce96
BLAKE2b-256 650e482859c1812336cef9653d4eac4d9a070094c8068a6973c779c5dd1fad38

See more details on using hashes here.

File details

Details for the file towebm-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: towebm-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.7.9

File hashes

Hashes for towebm-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 542bd9757e51e6e2d1ba9fe52ccd0bed40a394f914005b43320b432ddc6313e4
MD5 2bee4ea9f6e53bc4ab02249998421cf7
BLAKE2b-256 977e7909c6f24d853373e9800b21196b361e53f21b86fa14347b2cfaf5c4696d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page