Requires The mg.core.element application.
This application is responsible for handling video files in a gallery. It provides a cache of recompressed video files in order to provide galleries to different devices or plugins.
A video is the authoritative model for storing a video. All other classes only store caches of the data stored herein.
A video is a file of a given container format (avi, ogg, mov, etc.), with a video stream and an audio stream, each with specific attributes (codec, bitrate, etc.). Only one stream of each type is supported for now.
The file containing the original stream.
Width of the original video stream image. In pixels.
Height of the original video stream image. In pixels.
width/height ratio, to help find pictures by format.
Display aspect ratio. The width/height ratio the image should have when displayed to user. This is present as a medatada field in most container streams.
max((width, height)), here for query efficiency.
Format of the original container. This is the container around the streams, line mov, avi, ts, etc.
Format of the original audio stream.
Format of the original video stream.
The side of the original video stream that is the bottom of the scene. This defines the orientation of the original picture. This works exactly link photo’s Bottom side. This is most useful for videos authored with compact cameras where users don’t think rotation is not given for free :).
A time (in seconds) from the start of the stream where the image is interesting. This is where the snapshot will be taken for thumbnail generation.
Retrieves the absolute path to saved file in spool.
Returns: | An absolute path in file system |
---|
This defines a format for resized video streams. This actually defines the codecs to use, the bitrates, and the container.
Maximal width of the video stream (pixels).
Maximal height of the video stream (pixels).
Audio format. This is a format name (like mp3, aac or pcm16le). Codec to use for this format will be looked-up through mg.utils.video.StreamInfo.format_map.
Video format.
Container format.
Video frame per second to encode (float). This may be a non-integer value.
Video bitrate (in bit/second). Only used for lossy formats.
Audio sampling rate (in Hz).
Count of audio channels in audio stream. Most values will be 1 (mono) or 2 (stereo).
Additional flags to pass to the compression utility. By default, this is ffmpeg flags. See mg.utils.video.VideoHandler.
A 2-tuple of (width, height) matching video size.
Yields a dict with four keys:
Pointer to a VideoFormat: The format the video got recompressed to.
A file where the resized video is stored.
The side of the original video used to generate the resized video. If the bottom_side value does not match the one of the original video, updaters will recompute the resized video. See Bottom side.
Creates a name matching the referenced element and size. This can be used as base path for saving the thumbnail file.
Returns: | A relative path string |
---|
In order to use these templatetags, you must use the following code in your template:
{% load mg_video %}
This inclusion tag generates links to the relevant links for each of the video formats. When such link is followed:
{% video_prefer_size_links %}
Prefered size for videos is used by the video_resized_get template tag.
Used template is video/prefer_size.html. It gets a sizes variable with all the existing VideoFormat objects.
This tag retrieves a ResizedVideo fitting the user’s preferences. Example:
{% video_resized_get video_element as resized %}
<!-- ugly <embed/object/script /> code using {{resized.file.url}},
{{resized.size.width}}, {{resized.size.height}}, etc -->
mg.media.video provides some views. They are not directly usable to display the video streams, though.
A view used by the video_prefer_size_links template tag.
mg.media.video.urls exports mg.media.video.views.prefer_size() to the prefer_size/ url. This should not be used directly, but mg.media.video.urls should be included in your root urls.py if you use the template tag.