video_transcoding package¶
Subpackages¶
- video_transcoding.transcoding package
- Submodules
- video_transcoding.transcoding.analysis module
- video_transcoding.transcoding.codecs module
- video_transcoding.transcoding.extract module
- video_transcoding.transcoding.ffprobe module
- video_transcoding.transcoding.inputs module
- video_transcoding.transcoding.metadata module
- video_transcoding.transcoding.outputs module
- video_transcoding.transcoding.profiles module
- video_transcoding.transcoding.transcoder module
- video_transcoding.transcoding.workspace module
- Module contents
Submodules¶
video_transcoding.admin module¶
- class video_transcoding.admin.AudioProfileAdmin(model, admin_site)¶
Bases:
ProfileAdmin- form¶
alias of
AudioProfileForm
- inlines = [<class 'video_transcoding.admin.AudioProfileTracksInline'>]¶
- property media¶
- class video_transcoding.admin.AudioProfileInline(parent_model, admin_site)¶
Bases:
ProfileInline- model¶
alias of
AudioProfile
- property media¶
- class video_transcoding.admin.AudioProfileTracksInline(parent_model, admin_site)¶
Bases:
ProfileTracksInline- model¶
alias of
AudioProfileTracks
- property media¶
- class video_transcoding.admin.AudioTrackAdmin(model, admin_site)¶
Bases:
TrackAdmin- form¶
alias of
AudioTrackForm
- property media¶
- class video_transcoding.admin.PresetAdmin(model, admin_site)¶
Bases:
ModelAdmin- inlines = [<class 'video_transcoding.admin.VideoProfileInline'>, <class 'video_transcoding.admin.AudioProfileInline'>]¶
- list_display = ('name', 'created', 'modified')¶
- property media¶
- readonly_fields = ('created', 'modified')¶
- search_fields = ('=name',)¶
- class video_transcoding.admin.ProfileAdmin(model, admin_site)¶
Bases:
ModelAdmin- list_display = ('name', 'preset', 'order_number', 'created', 'modified')¶
- list_filter = ('preset',)¶
- property media¶
- ordering = ('preset', 'order_number')¶
- readonly_fields = ('created', 'modified')¶
- search_fields = ('=name',)¶
- class video_transcoding.admin.ProfileInline(parent_model, admin_site)¶
Bases:
TabularInline- extra = 0¶
- list_display = ('name',)¶
- property media¶
- readonly_fields = ('condition',)¶
- class video_transcoding.admin.ProfileTracksInline(parent_model, admin_site)¶
Bases:
TabularInline- autocomplete_fields = ('track',)¶
- extra = 0¶
- list_display = ('track', 'order_number')¶
- property media¶
- class video_transcoding.admin.TrackAdmin(model, admin_site)¶
Bases:
ModelAdmin- list_display = ('name', 'preset', 'created', 'modified')¶
- list_filter = ('preset',)¶
- property media¶
- readonly_fields = ('created', 'modified')¶
- search_fields = ('=name',)¶
- class video_transcoding.admin.VideoAdmin(model, admin_site)¶
Bases:
ModelAdmin- add_view(request: HttpRequest, form_url: str = '', extra_context: Any = None) HttpResponse¶
- transcode(request: HttpRequest, queryset: QuerySet) None¶
- actions = ['transcode']¶
- list_display = ('basename', 'source', 'status_display')¶
- list_filter = ('status',)¶
- property media¶
- readonly_fields = ('created', 'modified', 'video_player')¶
- search_fields = ('source', '=basename')¶
- class video_transcoding.admin.VideoProfileAdmin(model, admin_site)¶
Bases:
ProfileAdmin- form¶
alias of
VideoProfileForm
- inlines = [<class 'video_transcoding.admin.VideoProfileTracksInline'>]¶
- property media¶
- class video_transcoding.admin.VideoProfileInline(parent_model, admin_site)¶
Bases:
ProfileInline- model¶
alias of
VideoProfile
- property media¶
- class video_transcoding.admin.VideoProfileTracksInline(parent_model, admin_site)¶
Bases:
ProfileTracksInline- model¶
alias of
VideoProfileTracks
- property media¶
- class video_transcoding.admin.VideoTrackAdmin(model, admin_site)¶
Bases:
TrackAdmin- form¶
alias of
VideoTrackForm
- property media¶
- video_transcoding.admin.short_description(name: str | Promise) Callable[[C], C]¶
Sets short description for function.
video_transcoding.apps module¶
video_transcoding.celery module¶
- video_transcoding.celery.send_term_to_children(**kwargs: Any) None¶
- video_transcoding.celery.set_same_process_group(**kwargs: Any) None¶
video_transcoding.defaults module¶
video_transcoding.forms module¶
- class video_transcoding.forms.AudioProfileForm(*args: Any, **kwargs: Any)¶
Bases:
NestedJSONForm- class Meta¶
Bases:
object- model¶
alias of
AudioProfile
- fields = '__all__'¶
- base_fields = {'_min_bitrate': <django.forms.fields.IntegerField object>, '_min_sample_rate': <django.forms.fields.IntegerField object>, 'audio': <django.forms.models.ModelMultipleChoiceField object>, 'condition': <django.forms.fields.JSONField object>, 'name': <django.forms.fields.SlugField object>, 'order_number': <django.forms.fields.IntegerField object>, 'preset': <django.forms.models.ModelChoiceField object>}¶
- declared_fields = {'_min_bitrate': <django.forms.fields.IntegerField object>, '_min_sample_rate': <django.forms.fields.IntegerField object>, 'condition': <django.forms.fields.JSONField object>}¶
- json_field: str = 'condition'¶
- property media¶
Return all media required to render the widgets on this form.
- nested_fields: List[str] = ['min_bitrate', 'min_sample_rate']¶
- class video_transcoding.forms.AudioTrackForm(*args: Any, **kwargs: Any)¶
Bases:
NestedJSONForm- class Meta¶
Bases:
object- model¶
alias of
AudioTrack
- fields = '__all__'¶
- base_fields = {'_bitrate': <django.forms.fields.IntegerField object>, '_channels': <django.forms.fields.IntegerField object>, '_codec': <django.forms.fields.CharField object>, '_sample_rate': <django.forms.fields.IntegerField object>, 'name': <django.forms.fields.SlugField object>, 'params': <django.forms.fields.JSONField object>, 'preset': <django.forms.models.ModelChoiceField object>}¶
- declared_fields = {'_bitrate': <django.forms.fields.IntegerField object>, '_channels': <django.forms.fields.IntegerField object>, '_codec': <django.forms.fields.CharField object>, '_sample_rate': <django.forms.fields.IntegerField object>, 'params': <django.forms.fields.JSONField object>}¶
- json_field: str = 'params'¶
- property media¶
Return all media required to render the widgets on this form.
- nested_fields: List[str] = ['codec', 'bitrate', 'channels', 'sample_rate']¶
- class video_transcoding.forms.NestedJSONForm(*args: Any, **kwargs: Any)¶
Bases:
ModelForm- clean() Dict[str, Any]¶
Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.
- base_fields = {}¶
- declared_fields = {}¶
- json_field: str¶
- property media¶
Return all media required to render the widgets on this form.
- nested_fields: List[str]¶
- class video_transcoding.forms.VideoProfileForm(*args: Any, **kwargs: Any)¶
Bases:
NestedJSONForm- class Meta¶
Bases:
object- model¶
alias of
VideoProfile
- fields = '__all__'¶
- base_fields = {'_max_dar': <django.forms.fields.FloatField object>, '_min_bitrate': <django.forms.fields.IntegerField object>, '_min_dar': <django.forms.fields.FloatField object>, '_min_frame_rate': <django.forms.fields.FloatField object>, '_min_height': <django.forms.fields.IntegerField object>, '_min_width': <django.forms.fields.IntegerField object>, 'condition': <django.forms.fields.JSONField object>, 'name': <django.forms.fields.SlugField object>, 'order_number': <django.forms.fields.IntegerField object>, 'preset': <django.forms.models.ModelChoiceField object>, 'segment_duration': <django.forms.fields.DurationField object>, 'video': <django.forms.models.ModelMultipleChoiceField object>}¶
- declared_fields = {'_max_dar': <django.forms.fields.FloatField object>, '_min_bitrate': <django.forms.fields.IntegerField object>, '_min_dar': <django.forms.fields.FloatField object>, '_min_frame_rate': <django.forms.fields.FloatField object>, '_min_height': <django.forms.fields.IntegerField object>, '_min_width': <django.forms.fields.IntegerField object>, 'condition': <django.forms.fields.JSONField object>}¶
- json_field: str = 'condition'¶
- property media¶
Return all media required to render the widgets on this form.
- nested_fields: List[str] = ['min_bitrate', 'min_width', 'min_height', 'min_frame_rate', 'min_dar', 'max_dar']¶
- class video_transcoding.forms.VideoTrackForm(*args: Any, **kwargs: Any)¶
Bases:
NestedJSONForm- class Meta¶
Bases:
object- model¶
alias of
VideoTrack
- fields = '__all__'¶
- base_fields = {'_buf_size': <django.forms.fields.IntegerField object>, '_codec': <django.forms.fields.CharField object>, '_constant_rate_factor': <django.forms.fields.IntegerField object>, '_force_key_frames': <django.forms.fields.CharField object>, '_frame_rate': <django.forms.fields.FloatField object>, '_gop_size': <django.forms.fields.IntegerField object>, '_height': <django.forms.fields.IntegerField object>, '_max_rate': <django.forms.fields.IntegerField object>, '_pix_fmt': <django.forms.fields.CharField object>, '_preset': <django.forms.fields.CharField object>, '_profile': <django.forms.fields.CharField object>, '_width': <django.forms.fields.IntegerField object>, 'name': <django.forms.fields.SlugField object>, 'params': <django.forms.fields.JSONField object>, 'preset': <django.forms.models.ModelChoiceField object>}¶
- declared_fields = {'_buf_size': <django.forms.fields.IntegerField object>, '_codec': <django.forms.fields.CharField object>, '_constant_rate_factor': <django.forms.fields.IntegerField object>, '_force_key_frames': <django.forms.fields.CharField object>, '_frame_rate': <django.forms.fields.FloatField object>, '_gop_size': <django.forms.fields.IntegerField object>, '_height': <django.forms.fields.IntegerField object>, '_max_rate': <django.forms.fields.IntegerField object>, '_pix_fmt': <django.forms.fields.CharField object>, '_preset': <django.forms.fields.CharField object>, '_profile': <django.forms.fields.CharField object>, '_width': <django.forms.fields.IntegerField object>, 'params': <django.forms.fields.JSONField object>}¶
- json_field: str = 'params'¶
- property media¶
Return all media required to render the widgets on this form.
- nested_fields: List[str] = ['codec', 'constant_rate_factor', 'preset', 'max_rate', 'buf_size', 'profile', 'pix_fmt', 'width', 'height', 'frame_rate', 'gop_size', 'force_key_frames']¶
video_transcoding.helpers module¶
- video_transcoding.helpers.send_transcode_task(video: Video) AsyncResult¶
Send a video transcoding task.
If task is successfully sent to broker, Video status is changed to QUEUED and Celery task identifier is saved.
- Parameters:
video (video.models.Video) – video object
- Returns:
Celery task result
- Return type:
celery.result.AsyncResult
video_transcoding.models module¶
- class video_transcoding.models.AudioProfile(id, created, modified, name, order_number, condition, preset)¶
Bases:
AudioProfileBase- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
- audio¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- audioprofiletracks_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- condition¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- order_number¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- preset¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- preset_id¶
- class video_transcoding.models.AudioProfileBase(*args, **kwargs)¶
Bases:
TimeStampedModelAudio transcoding profile.
- class Meta¶
Bases:
object- abstract = False¶
- ordering = ['order_number']¶
- unique_together = (('name', 'preset'),)¶
- verbose_name = 'Audio profile'¶
- verbose_name_plural = 'Audio profiles'¶
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
- audio¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- condition¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- order_number¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- preset¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- preset_id¶
- class video_transcoding.models.AudioProfileTracks(id, profile, track, order_number)¶
Bases:
AudioProfileTracksBase- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- order_number¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- profile¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- profile_id¶
- track¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- track_id¶
- class video_transcoding.models.AudioProfileTracksBase(*args, **kwargs)¶
Bases:
Model- class Meta¶
Bases:
object- abstract = False¶
- ordering = ['order_number']¶
- unique_together = (('profile', 'track'),)¶
- verbose_name = 'Audio profile track'¶
- verbose_name_plural = 'Audio profile tracks'¶
- order_number¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- profile¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- profile_id¶
- track¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- track_id¶
- class video_transcoding.models.AudioTrack(id, created, modified, name, params, preset)¶
Bases:
AudioTrackBase- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
- audioprofile_set¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- audioprofiletracks_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- params¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- preset¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- preset_id¶
- class video_transcoding.models.AudioTrackBase(*args, **kwargs)¶
Bases:
TimeStampedModelAudio stream transcoding parameters.
- class Meta¶
Bases:
object- abstract = False¶
- unique_together = (('name', 'preset'),)¶
- verbose_name = 'Audio track'¶
- verbose_name_plural = 'Audio tracks'¶
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- params¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- preset¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- preset_id¶
- class video_transcoding.models.Preset(id, created, modified, name)¶
Bases:
PresetBase- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
- audio_profiles: ReverseManyToOneDescriptor¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- audio_tracks: ReverseManyToOneDescriptor¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- video_profiles: ReverseManyToOneDescriptor¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- video_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- video_tracks: ReverseManyToOneDescriptor¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- class video_transcoding.models.PresetBase(*args, **kwargs)¶
Bases:
TimeStampedModelTranscoding preset.
- class Meta¶
Bases:
object- abstract = False¶
- verbose_name = 'Preset'¶
- verbose_name_plural = 'Presets'¶
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
- audio_profiles: ReverseManyToOneDescriptor¶
- audio_tracks: ReverseManyToOneDescriptor¶
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- video_profiles: ReverseManyToOneDescriptor¶
- video_tracks: ReverseManyToOneDescriptor¶
- class video_transcoding.models.Video(*args, **kwargs)¶
Bases:
TimeStampedModelVideo model.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- change_status(status: int, **fields: Any) None¶
Changes video status.
Also saves another model fields and always updates modified value.
- Parameters:
status – one of statuses for Video.status (see STATUS_CHOICES)
fields – dict with model field values.
- format_video_url(edge: str) str¶
Returns a link to m3u8 playlist on one of randomly chosen edges.
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
- get_status_display(*, field=<django.db.models.fields.SmallIntegerField: status>)¶
- CREATED = 0¶
- DONE = 3¶
- ERROR = 4¶
- PROCESS = 2¶
- QUEUED = 1¶
- STATUS_CHOICES = ((0, 'new'), (1, 'queued'), (2, 'process'), (3, 'done'), (4, 'error'))¶
- basename¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- duration¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- error¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- metadata¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- preset¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- preset_id¶
- source¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- status¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- task_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class video_transcoding.models.VideoProfile(id, created, modified, name, order_number, condition, preset, segment_duration)¶
Bases:
VideoProfileBase- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
- condition¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- order_number¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- preset¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- preset_id¶
- segment_duration¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- video¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- videoprofiletracks_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- class video_transcoding.models.VideoProfileBase(*args, **kwargs)¶
Bases:
TimeStampedModelVideo transcoding profile.
- class Meta¶
Bases:
object- abstract = False¶
- ordering = ['order_number']¶
- unique_together = (('name', 'preset'),)¶
- verbose_name = 'Video profile'¶
- verbose_name_plural = 'Video profiles'¶
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
- condition¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- order_number¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- preset¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- preset_id¶
- segment_duration¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- video¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- class video_transcoding.models.VideoProfileTracks(id, profile, track, order_number)¶
Bases:
VideoProfileTracksBase- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- order_number¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- profile¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- profile_id¶
- track¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- track_id¶
- class video_transcoding.models.VideoProfileTracksBase(*args, **kwargs)¶
Bases:
Model- class Meta¶
Bases:
object- abstract = False¶
- ordering = ['order_number']¶
- unique_together = (('profile', 'track'),)¶
- verbose_name = 'Video profile track'¶
- verbose_name_plural = 'Video profile tracks'¶
- order_number¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- profile¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- profile_id¶
- track¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- track_id¶
- class video_transcoding.models.VideoTrack(id, created, modified, name, params, preset)¶
Bases:
VideoTrackBase- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- params¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- preset¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- preset_id¶
- videoprofile_set¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- videoprofiletracks_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- class video_transcoding.models.VideoTrackBase(*args, **kwargs)¶
Bases:
TimeStampedModelVideo stream transcoding parameters.
- class Meta¶
Bases:
object- abstract = False¶
- unique_together = (('name', 'preset'),)¶
- verbose_name = 'Video track'¶
- verbose_name_plural = 'Video tracks'¶
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- params¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- preset¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- preset_id¶
video_transcoding.signals module¶
- video_transcoding.signals.send_request_finished(task: Task, **kwargs: Any) None¶
Send request_finished signal to launch django life cycle handlers.
- video_transcoding.signals.send_request_started(task: Task, **kwargs: Any) None¶
Send request_started signal to launch django life cycle handlers.
video_transcoding.strategy module¶
- class video_transcoding.strategy.ResumableStrategy(source_uri: str, basename: str, preset: Preset)¶
Bases:
StrategyTranscoding strategy implementation with resume support.
Source file is downloaded to temporary shared webdav directory, split to chunks. Chunks are transcoded on by one and merged to a single file at the end. Resulting file is segmented to HLS on a result storage.
- cleanup(is_error: bool) None¶
Cleanup workspace.
- Parameters:
is_error – True if processing finished with an error
- get_segment_list() List[str]¶
Parses a list of segment names from a M3U8 playlist. :return: a list of chunk filenames.
- initialize() None¶
Initialize workspace.
- merge(segments: List[str], meta: Metadata) Metadata¶
Combines resulting chunks to a single output and segments it to HLS. :param segments: list of chunk filenames. :param meta: resulting file metadata. :return: resulting file metadata.
- static merge_metadata(result_meta: Metadata | None, segment_meta: Metadata) Metadata¶
Appends next chunk metadata to resulting file metadata.
Combines duration, scenes and samples/frames count.
- Parameters:
result_meta – resulting file metadata.
segment_meta – chunk metadata.
- Returns:
updated resulting file metadata.
- static metadata_file(file: File) File¶
- Parameters:
file – chunk filename
- Returns:
a json file containing resulting file metadata.
- process_segment(filename: str) Metadata¶
Transcodes source chunk to a resulting chunk if not yed transcoded.
Skips transcoding if resulting chunk metadata exists on shared webdav. :param filename: chunk filename :return: resulting chunk metadata.
- select_profile(src: Metadata) Profile¶
Selects profile for input if it has not already been selected.
Selected profile is stored in sources collection. :return: selected or cached profile.
- split(src: Metadata) Metadata¶
Splits source file to chunks at shared webdav
- Parameters:
src – remote source metadata.
- Returns:
a list of chunk filenames.
- write_concat_file(segments: List[str]) str¶
Writes ffconcat file to a shared collection :param segments: segments list :return: uri for ffconcat file
- property manifest_uri: str¶
A m3u8 master manifest uri for results at storage.
- Type:
return
- results: Collection¶
A collection to store split resulting chunks after transcoding.
- sources: Collection¶
A collection to store split source file downloaded to shared webdav.
- class video_transcoding.strategy.Strategy(source_uri: str, basename: str, preset: Preset)¶
Bases:
LoggerMixin,ABCTranscoding strategy.
- abstract cleanup(is_error: bool) None¶
Cleanup workspace.
- Parameters:
is_error – True if processing finished with an error
- abstract initialize() None¶
Initialize workspace.
video_transcoding.tasks module¶
- class video_transcoding.tasks.TranscodeVideo(*args: Any, **kwargs: Any)¶
Bases:
LoggerMixin,TaskVideo processing task.
- lock_video(video_id: int) Video¶
Gets video in QUEUED status from DB and changes status to PROCESS.
- Parameters:
video_id – Video primary key
- Returns:
Video object
- Raises:
Retry – in case of unexpected video status or task_id
- retry(args: Iterable[Any] | None = None, kwargs: Dict[str, Any] | None = None, exc: Exception | None = None, throw: bool = True, eta: datetime | None = None, countdown: float | int | None = None, max_retries: int | None = None, **options: Any) Any¶
Retry the task, adding it to the back of the queue.
Example
>>> from imaginary_twitter_lib import Twitter >>> from proj.celery import app
>>> @app.task(bind=True) ... def tweet(self, auth, message): ... twitter = Twitter(oauth=auth) ... try: ... twitter.post_status_update(message) ... except twitter.FailWhale as exc: ... # Retry in 5 minutes. ... raise self.retry(countdown=60 * 5, exc=exc)
Note
Although the task will never return above as retry raises an exception to notify the worker, we use raise in front of the retry to convey that the rest of the block won’t be executed.
- Parameters:
args (Tuple) – Positional arguments to retry with.
kwargs (Dict) – Keyword arguments to retry with.
exc (Exception) –
Custom exception to report when the max retry limit has been exceeded (default:
@MaxRetriesExceededError).If this argument is set and retry is called while an exception was raised (
sys.exc_info()is set) it will attempt to re-raise the current exception.If no exception was raised it will raise the
excargument provided.countdown (float) – Time in seconds to delay the retry for.
eta (datetime) – Explicit time and date to run the retry at.
max_retries (int) – If set, overrides the default retry limit for this execution. Changes to this parameter don’t propagate to subsequent task retry attempts. A value of
None, means “use the default”, so if you want infinite retries you’d have to set themax_retriesattribute of the task toNonefirst.time_limit (int) – If set, overrides the default time limit.
soft_time_limit (int) – If set, overrides the default soft time limit.
throw (bool) – If this is
False, don’t raise the@Retryexception, that tells the worker to mark the task as being retried. Note that this means the task will be marked as failed if the task raises an exception, or successful if it returns after the retry call.**options (Any) – Extra options to pass on to
apply_async().
- Raises:
celery.exceptions.Retry – To tell the worker that the task has been re-sent for retry. This always happens, unless the throw keyword argument has been explicitly set to
False, and is considered normal operation.
- run(video_id: int) str | None¶
Process video.
Locks video changing status from QUEUED to PROCESS
Transcodes video and stores result to origins
Changes video status to DONE, stores result basename
On errors changes video status ERROR, stores error message
- Parameters:
video_id – Video id.
- select_for_update(video_id: int, status: int) Video¶
Lock video in DB for current task.
- Parameters:
video_id – Video primary key
status – expected video status
- Returns:
Video object from db
- Raises:
models.Video.DoesNotExist – in case of missing or locked Video for primary key
ValueError – in case of unexpected Video status or task_id
- unlock_video(video_id: int, status: int, error: str | None, meta: dict | None, duration: timedelta | None) None¶
Marks video with final status.
- Parameters:
video_id – Video primary key
status – final video status (Video.DONE, Video.ERROR)
error – error message
meta – resulting media metadata
duration – media duration
- Raises:
RuntimeError – in case of unexpected video status or task id
- acks_late = True¶
When enabled messages for this task will be acknowledged after the task has been executed, and not right before (the default behavior).
Please note that this means the task may be executed twice if the worker crashes mid execution.
The application default can be overridden with the :setting:`task_acks_late` setting.
- acks_on_failure_or_timeout = True¶
When enabled messages for this task will be acknowledged even if it fails or times out.
Configuring this setting only applies to tasks that are acknowledged after they have been executed and only if :setting:`task_acks_late` is enabled.
The application default can be overridden with the :setting:`task_acks_on_failure_or_timeout` setting.
- autoretry_for = (<class 'django.db.utils.OperationalError'>,)¶
- ignore_result = False¶
If enabled the worker won’t store task state and return values for this task. Defaults to the :setting:`task_ignore_result` setting.
- inifinite_retry_for = (<class 'django.db.utils.OperationalError'>,)¶
- priority = None¶
Default task priority.
- rate_limit = None¶
None(no rate limit), ‘100/s’ (hundred tasks a second), ‘100/m’ (hundred tasks a minute),`’100/h’` (hundred tasks an hour)- Type:
Rate limit for this task type. Examples
- reject_on_worker_lost = True¶
Even if
acks_lateis enabled, the worker will acknowledge tasks when the worker process executing them abruptly exits or is signaled (e.g., :sig:`KILL`/:sig:`INT`, etc).Setting this to true allows the message to be re-queued instead, so that the task will execute again by the same worker, or another worker.
Warning: Enabling this can cause message loops; make sure you know what you’re doing.
- request_stack = <celery.utils.threads._LocalStack object>¶
Task request stack, the current request will be the topmost.
- retry_backoff = True¶
- routing_key = 'video_transcoding'¶
- serializer = 'json'¶
The name of a serializer that are registered with
kombu.serialization.registry. Default is ‘json’.
- store_eager_result = False¶
- store_errors_even_if_ignored = False¶
When enabled errors will be stored even if the task is otherwise configured to ignore results.
- track_started = False¶
If enabled the task will report its status as ‘started’ when the task is executed by a worker. Disabled by default as the normal behavior is to not report that level of granularity. Tasks are either pending, finished, or waiting to be retried.
Having a ‘started’ status can be useful for when there are long running tasks and there’s a need to report what task is currently running.
The application default can be overridden using the :setting:`task_track_started` setting.
- typing = True¶
Enable argument checking. You can set this to false if you don’t want the signature to be checked when calling the task. Defaults to
app.strict_typing.
video_transcoding.utils module¶
- class video_transcoding.utils.LoggerMixin(*args: Any, **kwargs: Any)¶
Bases:
objectA mixin for logger injection.
Should not be used with Django models, because Logger contains non-serializable threading.Lock object.