Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

Django Videologue

Videologue is a reusable Django application that provides powerful video management functionality as well as a complete video gallery solution.

What does it do?

Videologue's VideoModel abstract class adds original_video, flv_video, mp4_video, and ogv_video fields to your model, and adds any uploaded videos to a model for batch processing. After processing the flv_video, mp4_video, and ogv_video fields and the image field of the model are updated with the processed video data. This class is a subclass of Photologue's ImageModel abstract class so the model has the same properties for displaying the image grabbed from the video.

Plug Videologue into your existing apps using foreign key relationships and enjoy a better experience managing uploaded videos.

Adds a management command to manage.py called vlprocess that handles the batch converting of videos.

Videologue comes with a complete set of example templates for setting up a video gallery fast. Define a master template, apply some styles and you've got a complete video gallery system for your site or blog.

Installation

  1. Make sure you got ffmpeg and ffmpeg is compiled with the lame mp3 encoder.

  2. Unless you are running ffmpeg from svn you need flvtool and ruby, eek!

    If running ffmpeg from svn add VIDEOLOGUE_FLVTOOL = None to your settings.py since ffmpeg now adds metadata for you.

  3. Get the required third party modules

    svn co http://django-photologue.googlecode.com/svn/trunk/ django-photologue

    or download here.

    Optionally:

    svn checkout http://django-batchadmin.googlecode.com/svn/trunk/batchadmin

  4. Add the videologue directory to your Python path.

  5. Add the needed apps to INSTALLED_APPS

    'photologue',
    'videologue',
    #'batchadmin'
    
  6. Add this to crontab to make videos convert automatically on upload.

    Example: crontab -e

    # add env and run every two minutes
    PYTHONPATH=/path/to/project
    */2     *     *     *     *         python /path/to/project/projectname/manage.py vlprocess
    
  7. Get Flowplayer and serve the swf.

    Set the setting FLOWPLAYER to the location of the flowplayer swf.

  8. If you want the video gallery add videologue.urls to your projects urlconf:

    (r'^videos/', include('videologue.urls')),
    

    Copy the templates to adapt them for your site

  9. If the the default settings are not suited to your needs you have these settings available:

    VIDEOLOGUE_FFMPEG defaults to ffmpeg

    VIDEOLOGUE_FLVTOOL defaults to flvtool2

    VIDEOLOGUE_VIDEO_SIZE defaults to 320x240

    VIDEOLOGUE_IMAGE_SIZE defaults to 320x240

    VIDEOLOGUE_AUDIO_CODEC defaults to libmp3lame

    VIDEOLOGUE_AUDIO_BITRATE defaults to 32000

    VIDEOLOGUE_AUDIO_SAMPLING_RATE defaults to 22050

    Additional settings control which encodings are produced. The defaults are meant to maintain backwards-compatibility with previous versions. Eg, "Why did that update cause our CPU usage to spike?"

    VIDEOLOGUE_ENCODE_FLV defaults to True

    VIDEOLOGUE_ENCODE_MP4 defaults to False

    VIDEOLOGUE_ENCODE_OGV defaults to False

    By default, MP4 encoding does two passes for higher quality. To reduce encoding time at the cost of quality, you can disable the two-pass encoding with the following setting.

    VIDEOLOGUE_MP4_TWOPASS defaults to True

    Videologue supports automatic letterboxing/pillarboxing (currently doesn't work with the image snapshot, only the video). Can be disabled:

    VIDEOLOGUE_AUTO_LETTERBOX defaults to True

Other Requirements

  • For MP4 encoding, libx264 (video) and libfaac (audio) are required and must be supported by ffmpeg.
  • For OGV encoding, libtheora (video) and libvorbis (audio) are required and must be supported by ffmpeg.

Debugging

  • If conversion is failing and you notice "frame size for ffmpeg must be a multiple of 2" in your output:

    Problem: ffmpeg is dying complaining that the frame size must be a multiple of 2.

    Solution: In video_render, the calculation for height needs to be floor(height/2)*2

    In other words, take your desired height, round it down to the nearest even integer, and use that height instead.

  • For better ffmpeg performance and possibly smaller file sizes, ensure that both numbers in VIDEOLOGUE_VIDEO_SIZE are evenly divisible by 16.

  • If you have trouble getting HTML5's <video> to work properly, especially with the MP4 format, check out Apple's reference library on configuring your server. This took forever to figure out, but django's runserver doesn't support byte-range requests (which are required for MP4 playback). If you host the media through a proper server like Apache, it should work fine.

HTML5 Resources

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.