Skip to content
Download and encode video files by using ffmpeg utilit
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

Django ffmpeg

Download and encode video files by using ffmpeg utilit or any another (?) command line tool.

Authors

The original version is created by Alrusdi. Modify, making separate application, refactoring and further development pixxxel

Install

pip install django-ffmpeg

Create structure in MEDIA_ROOT directory:

videos
  |- orig
  |- thumb
  |- conv

or set another existing directory names by FFMPEG_PRE_DIR, FFMPEG_ORIG_VIDEO, FFMPEG_THUMB_VIDEO, FFMPEG_CONV_VIDEO in settings.py.

Add 'django_ffmpeg' to INSTALLED_APPS and execute python manage.py migrate

Dependencies

You must have Ffmpeg (or any other) utilit for converting video. Possible get it for Ubuntu as:

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg

For Windows you must download it.

Obviously, Django must have.

Usage

For converting video set the command(s) to ConvertingCommand model for example:

>>> from django_ffmpeg.models import ConvertingCommand
>>> ConvertingCommand(
	match_by='name',
	match_regex='.*',
	command='ffmpeg -y -hide_banner -nostats -i %(input_file)s -threads 0 -xerror %(output_file)s',
	convert_extension='mp4',
	thumb_command='ffmpeg -hide_banner -nostats -i %(in_file)s -y -frames:v 1 -ss %(thumb_frame)s %(out_file)s'
).save()

Fragments %(input_file)s and %(output_file)s in command is required.

Fragments %(in_file)s and %(thumb_frame)s in thumb_command is required.

Option -xerror is required for except ffmpeg conversion error to convert_status.

After this you must run python manage.py convert_videos or set it to crontab. Command is convert only one unconverted video at time. So execute this command as many times as unconverted videos is it.

Now you may reference on django_ffmpeg.Video model from other or get it directly.

Todo

  • Autocreate media directories
  • Refactoring utils.Converter
You can’t perform that action at this time.