11import copy
22import logging
3+ import uuid
34
45from typing import Optional , Union
56
6- from videodb ._constants import MaxSupported
7+ from videodb ._constants import MaxSupported , TextStyle
78
89logger = logging .getLogger (__name__ )
910
@@ -32,8 +33,8 @@ class VideoAsset(MediaAsset):
3233 def __init__ (
3334 self ,
3435 asset_id : str ,
35- start : Optional [int ] = 0 ,
36- end : Optional [Union [ int , None ] ] = None ,
36+ start : Optional [float ] = 0 ,
37+ end : Optional [float ] = None ,
3738 ) -> None :
3839 super ().__init__ (asset_id )
3940 self .start : int = start
@@ -55,8 +56,8 @@ class AudioAsset(MediaAsset):
5556 def __init__ (
5657 self ,
5758 asset_id : str ,
58- start : Optional [int ] = 0 ,
59- end : Optional [Union [ int , None ] ] = None ,
59+ start : Optional [float ] = 0 ,
60+ end : Optional [float ] = None ,
6061 disable_other_tracks : Optional [bool ] = True ,
6162 fade_in_duration : Optional [Union [int , float ]] = 0 ,
6263 fade_out_duration : Optional [Union [int , float ]] = 0 ,
@@ -117,3 +118,33 @@ def __repr__(self) -> str:
117118 f"y={ self .y } , "
118119 f"duration={ self .duration } )"
119120 )
121+
122+
123+ class TextAsset (MediaAsset ):
124+ def __init__ (
125+ self ,
126+ text : str ,
127+ duration : Optional [int ] = None ,
128+ style : TextStyle = TextStyle (),
129+ ) -> None :
130+ super ().__init__ (f"txt-{ str (uuid .uuid4 ())} " )
131+ self .text = text
132+ self .duration = duration
133+ self .style : TextStyle = style
134+
135+ def to_json (self ) -> dict :
136+ return {
137+ "text" : copy .deepcopy (self .text ),
138+ "asset_id" : copy .deepcopy (self .asset_id ),
139+ "duration" : copy .deepcopy (self .duration ),
140+ "style" : copy .deepcopy (self .style .__dict__ ),
141+ }
142+
143+ def __repr__ (self ) -> str :
144+ return (
145+ f"TextAsset("
146+ f"text={ self .text } , "
147+ f"asset_id={ self .asset_id } , "
148+ f"duration={ self .duration } , "
149+ f"style={ self .style } )"
150+ )
0 commit comments