Models

Models.

class MediaFile(*args, **kwargs)

Model for media files.

class Encoder(*args, **kwargs)

Encoder model for tool like FFmpeg or ImageMagick.

encode_cmd

The full command for the encoder, eg. ffmpeg -loglevel fatal -y.

Returns:A list of options that represent the encoder base command.
Return type:list
class EncodingProfile(*args, **kwargs)

Job data for encoding a file.

encode_cmd

The command for the encoder without the vars injected, eg. ffmpeg -y -i "{input}" "{output}".

Returns:A string that represents the command that the encoder should execute.
Return type:str
class MediaBase(*args, **kwargs)

Base model for media objects.

ready

Indicates if all output files have completed encoding.

Returns:Boolean indicating if all output files have completed encoding.
Return type:boolean
encodable

Indicates if the input file has not completed encoding yet.

Returns:Boolean indicating if the input file has not completed encoding yet.
Return type:boolean
input_path

The path to the input file uploaded by the user.

Returns:For example: [MEDIA_ROOT]/user/video/IMG001.MPEG.
Return type:str or None
output_path(profile)

The path of the encoded output file.

Parameters:profile (EncodingProfile) – The EncodingProfile instance that contains the encoding data.
Returns:For example: [ENCODE_MEDIA_ROOT]/[ENCODE_MEDIA_PATH_NAME]/audio/51.mp3.
Return type:str
get_media()

The media type. Either VIDEO, SNAPSHOT, or AUDIO.

Return type:MediaBase subclass.
Returns:The media subclass.
store_file(profile)

Add the encoded input file to the output_files field.

Parameters:profile (EncodingProfile) – The EncodingProfile instance that contains the encoding data.
Raises:UploadError: Something went wrong while uploading the file or the file does not exist.
remove_file(profile)

Remove the input (and possible local encoded) file.

Parameters:profile (EncodingProfile) – The EncodingProfile instance that contains the encoding data.
save(profiles=[], *args, **kwargs)

Set the encoding status to True and save the model.

Parameters:profiles (list) – List of primary keys of encoding profiles.
class Video(*args, **kwargs)

Model for video files.

save(*args, **kwargs)

Encode and upload the video.

class Audio(*args, **kwargs)

Model for audio files.

save(*args, **kwargs)

Encode and upload the audio clip.

class Snapshot(*args, **kwargs)

Model for snapshot files.

save(*args, **kwargs)

Encode and upload the snapshot file.