Tool to convert media files when they are moved to a directory
The following tools are required:
# Install virtualenv package for Python:
pip install virtualenv
# Create virtual environment named VideoConveter:
virtualenv VideoConveter
# or
virtualenv -p python3 VideoConveter
# Activate virtual environment:
source VideoConveter/bin/activate
# Deactivate virtual environment:
deactivate
# Install required pip-tools for requirements installation:
alias py='python -m pip'
py install pip-tools
# Move to root project directory:
cd /project_root/
# Read requirements to install:
pip-compile --output-file requirements.txt requirements.in
# Install required packages:
pip-sync
Launch tool:
# Start main:
python src/Application.py
# or you can specify a configuration file:
python src/Application.py /path/custom_config.ini
Configurations file example:
# Legend
# [opt] := optional parameter
# [dft] := default value
# [mnd] := mandatory parameter
[GENERAL]
# [opt] - Log directory. If no directory will be specified no log file will be created
# [dft] -
log.dir = /var/log
# [opt] - Directory for temporary files
# [dft] - /tmp
# tmp = /Volumes/Ramdisk/tmp
# [opt] - Processes for conversion handling
processes = 5
[MEDIA]
# [mnd] - Input directory
in.folder = /Volumes/Ramdisk/test/in
# [opt] - Directory where will be moved files after conversion
# NOTE: leave empty this parameter to delete files after conversion
# NOTE: if this parameter will not be specified then not action will be taken
in.converted_folder =
# in.converted_folder = /Volumes/Ramdisk/test/converted
# [opt] - Frequency (seconds) for checking new files
# [dft] - 1
in.timeout = 0.5
# [mnd] - Directory for storing converted files
out.folder = /Volumes/Ramdisk/test
# [mnd] - Conversion format. Follow JSON format
out.format = {
'format' : 'avi',
'audio' : {
'codec' : 'mp3',
'samplerate' : 11025,
'channels' : 2
},
'video' : {
'codec' : 'h264',
'width' : 720,
# 'height' : 400,
# 'fps' : 15
}
}
# [opt] - Path of requested binary
# [dft] - Binaries for ffmpeg and ffprobe will be searched in PATH environment variable
ffmpeg = /usr/local/opt/ffmpeg/ffmpeg
ffprobe = /usr/local/opt/ffmpeg/ffprobe
- In MacOS ecosystem execute the following commands in a bash shell:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
- python-video-converter is a wrapper for ffmpeg Python by senko.