Skip to main content

converter

(documentation outdated)

Script to maintain a multimedia library. It will make sure that the codec and bitrate that each file has is the expected and it will do the transcodding if needed.

It can eficiently handle libraries with more than 100.000 multimedia files automatically. I was no able to find a free/paid software that allows me to do that, so I made my own :)

Requisites:

  • ffmpeg
  • redis server
  • python3
  • pip3 modules: bs4, redis, colorama, argparse

Configuration:

  • Change de following files as needed:

conf.py:

# redis server host
REDIS_HOST = '10.0.0.3'

# Multimedia library path
LIBRARY = '/XXXX/YYYYY/ZZZZZZ'

# Temporal folder to save finished transcodding and ongoing ones
TEMPORAL = '/XXXX/YYYYY/ZZZZZZ'

parse.py:

probe = 'ffprobe -v quiet -print_format json -show_streams'
aria = 'aria2c --disable-ipv6=true --follow-torrent=mem --seed-time=0 --enable-color=false --check-certificate=false --console-log-level=error --summary-interval=0'
ffmpeg = 'ffmpeg -hide_banner -y'
ffmpeg_vo = '-vsync 2 -r 30 -vf scale=1280x1280:force_original_aspect_ratio=decrease -b:v 500k -movflags +faststart'

# Commands used
cmds = {
    # To get coddecs details about a file
    'w-probe': '%s {0}' % probe,
    # To transcode a video file using nvidia hardware aceleration
    'w-hvideo': '%s -hwaccel nvdec -i {0} -c:a copy -c:v h264_nvenc %s -f mp4 {1}' % ( ffmpeg, ffmpeg_vo ),
    # To transcode a video file using the cpu
    'w-svideo': '%s -i {0} -c:a copy -c:v h264 %s -f mp4 {1}' % ( ffmpeg, ffmpeg_vo ),
    # To transcode the audio of a video file
    'w-vaudio': '%s -i {0} -c:a aac -b:a 100k -c:v copy -f mp4 {1}' % ( ffmpeg ),
    # To transcode an audio file
    'w-audio': '%s -i {0} -c:a mp3 -b:a 128k -f mp3 {1}' % ( ffmpeg ),
    # To download a file
    'w-download': '%s -d / -o {1} {0}' % aria,
    # To download a torrent
    'w-torrent': '%s -d {1} {0}' % aria
}

# This function makes sure that the file's coddecs are correct.
# If you have a different needs, you should change this one it too.
def job_codec(f, codecs):
    (...)

Usage:

# To print a detailed usage text:
./main -h

# To scan files in the library and create jobs to analize them if needed:
./main -s

# To analize and transcode the files if needed:
./main -k w-download,w-torrent,w-svideo,w-vaudio,w-audio

# To transcode the files using the GPU you may notice
# that there is a maximum supported number of transcodding jobs that they can run in parallel.
# You can match that amount use the parameter '-jN' as needed.
# By default, all the videos are transcodded using the GPU.
./main -j2 -k w-hvideo

# To force retry some jobs, you can clean the redis lists 'done', 'doing' and 'failed'
# using the command:
./main -p

Logs:

Executed commands output is appended to: $TEMP/converter.out

Release files for mconv 1.0.1

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

Source distribution (sdist)

Source distribution for mconv 1.0.1
File Size Uploaded
mconv-1.0.1.tar.gz 3.1 kB Details

Built distribution (wheel)

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

Total release size: 6.4 kB

Release files / mconv-1.0.1.tar.gz

Download URL mconv-1.0.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b07c79dbb33eec7b90f7df391500c9084af022913c922f37f356fc5486b40d82
BLAKE2b-256 checksum
How to use checksums
a2a40feb9de89f9f6a9f645688a8a701ee60dc27064b144524afa84f6dbf965e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.8.7

Release files / mconv-1.0.1-py3-none-any.whl

Download URL mconv-1.0.1-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5d61f417e26bc17acb5d0993dfecc4da714a4818002663f496b10f871f1df78
BLAKE2b-256 checksum
How to use checksums
28a30c4907314cf3f5aa1589d9fa3ba407e68d8810accbbecaa9d30fc028c7cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.8.7

Release history Release notifications | RSS feed

1.1.2

2 release files

1.1.1

2 release files

1.1

2 release files

1.0.2

2 release files

This release

1.0.1 This release

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