Skip to main content

batchypegger

Apply ffmpeg in a simpler batchy way.

Easily shrink a video, or a folder of videos.

Turn that 50 gig TV series into a 5 gig folder. Turn that silly-sized screen recording into something you can upload.

Cleans up the filenames too.

Install

First install:

  • ffmpeg (and put it in your system path)
  • Python 3

Then install it with the pip command:

pip install batchypegger

Run it once to automatically create the config file ~/.batchypegger.yaml and you're ready to go!

Examples

  • Shrink all videos in the current folder to 360p:

    batchypegger 360p .

  • Shrink all the videos in the current folder without scaling them:

    batchypegger .

  • What about just a file?

    batchypegger 480p somevideo.mkv

  • Do a dry run to examine everything and make sure the filenames are right and the subtitles are picked up and stuff (good idea to do one first):

    batchypegger . dry

  • Make a few different sizes:

    batchypegger 360p 480p 720p 1080p .

  • Make a few different sizes but only the first 5 minutes (taster mode):

    batchypegger taster 360p 480p 720p 1080p .

  • BTW, mode switches taster and dry can appear anywhere. These are all the same:

    batchypegger 720p . dry

    batchypegger 720p . dry taster

    batchypegger taster dry 720p .

  • different schemes can be defined in the config file and then specified. This one will output 3 videos:

    batchypegger x265 1080p 720p x264 360p somevideo.webm

    Outputs: 
        somevideo__x265_720p.mkv
        somevideo__x265_1080p.mkv
        somevideo__x264_360p.mp4
    

Subtitles

If there is an .srt or .vtt file with the same exact filename as the video, only difference being the extension, then it will include the subtitles in the output.

If you do a dry run, you can see if it picked up the subtitles or not.

DVD Subtitles

If there is an .idx and .sub file with the same exact filename as the video, only difference being the extension, then it will pick them up.

However, with DVD subtitles you need to use one of the dvdsubs profiles: x264dvdsubs or x265dvdsubs

Or use your own custom profile that uses -c:s dvdsubs in the codec args and maps what you need, examine the config yaml for insight.

If you do a dry run, you can see if it picked up the subtitles or not.

Cleaning Filenames

It cleans the filenames. Someday this will be more configurable.

It will replace most characters with underscores and remove entire phrases that you've specified in the configuration section just_erase.

For example if you had filenames like: KittyShow 1x03 Freddy's birds (1080p BRrip x265 BooYeah).mkv, just paste (1080p BRrip x265 BooYeah) into just_erase in the config yaml, and do a dry run to make sure it got them. The output filenames would then look something like: KittyShow_1x03_Freddy_s_birds__x264_360p.mp4

Ignoring a file

Rename the file to end with __keep, like somevideo__keep.webm, and it won't be processed.

I want advanced ffmpeg arguments

Go ahead and edit the configuration file. Add as many schemes as you need. The ffmpeg command will be created like:

ffmpeg ffargs_prefix scheme_prefix -i infile codec_args scaling scheme_suffix ffargs_suffix outfile

and you can customise most of those in the config file. (scaling is calculated if you specify 480p etc)

Configuration: ~/.batchypegger.yaml

The first time you run batchypegger, the configuration file will be created in your home folder: ~/.batchypegger.yaml (On Windows that's like C:\Users\DingleToes\.batchypegger.yaml)

I tried to pick reasonable defaults. You can make new schemes for whatever you need. tag is what will be added to the filename, as in foo__x264_720p.mp4.

# full path to ffmpeg executable, or auto to look in the system path.
ffmpeg: auto

# the args parser will enforce only recognised numbers for p-ness (480p, 720p, etc)
# although the scaling math will probably do any number you need, just add it in here
# just the numbers, like [320, 300, 2000]
allow_p: []

# the command will be constructed as:
#   ffmpeg ffargs_prefix scheme_prefix -i infile codec_args scaling scheme_suffix ffargs_suffix outfile
ffargs_prefix: 
ffargs_suffix: -max_muxing_queue_size 1024 -movflags faststart

default_scheme: x264
schemes:
  x264: 
    codec_args: -c:v libx264 -crf 28 -c:s mov_text
    format: mp4
    tag: x264
    prefix:
    suffix:

  x264mkv: 
    codec_args: -c:v libx264 -crf 28 -c:s srt
    format: mkv
    tag: x264
    prefix:
    suffix:

  x264dvdsub: 
    codec_args: -map 0:v -map 0:a -map 1:s -c:v libx264 -crf 28 -c:a copy -c:s dvdsub
    format: mkv
    tag: x264
    prefix:
    suffix:

  x265: 
    codec_args: -c:v libx265 -crf 30 -c:s srt
    format: mkv
    tag: x265
    prefix:
    suffix:

  x265dvdsub: 
    codec_args: -map 0:v -map 0:a -map 1:s -c:v libx265 -crf 30 -c:s dvdsub
    format: mkv
    tag: x265
    prefix:
    suffix:

just_erase: [
  " (480p DVD x265 BooYeah)",
  " (480p x265 BooYeah)",
  # this list can get big...
]

Release files for batchypegger 0.5.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for batchypegger 0.5.4
File Size Uploaded
batchypegger-0.5.4.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for batchypegger 0.5.4
File Interpreter ABI Platform
batchypegger-0.5.4-py3-none-any.whl Python 3 none any Details

Total release size: 16.0 kB

Release files / batchypegger-0.5.4.tar.gz

Download URL batchypegger-0.5.4.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e624ab7e355f631880a366e5a2fa0d67e6e186d94169c207ea305912a8ee760a
BLAKE2b-256 checksum
How to use checksums
0a707c4e5383d491ab1108567abba5a4e6f6a4dfc32d0f02dea6392fd3437423
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.2

Release files / batchypegger-0.5.4-py3-none-any.whl

Download URL batchypegger-0.5.4-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f01e158828d4d2e865804941a31956c17a0d49fe06e65df23e14d02943aefe6
BLAKE2b-256 checksum
How to use checksums
1d1614ca8f7329e810a75bb598ecbbf0249fbb9fa4e890666dff8be8bd87821a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.5.4 This release

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page