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

Django ffmpeg

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


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


pip install django-ffmpeg

Create structure in MEDIA_ROOT directory:

  |- orig
  |- thumb
  |- conv

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

Add 'django_ffmpeg' to INSTALLED_APPS and execute python migrate


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.


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

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

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 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.


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