Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
VectCutAPI/add_effect_impl.py at main · sun-guannan/VectCutAPI · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
sun-guannan
VectCutAPI
Repository navigation
Code
Issues
2
(2)
Pull requests
3
(3)
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
VectCutAPI
/
add_effect_impl.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
90 lines (83 loc) · 3.52 KB
main
Breadcrumbs
VectCutAPI
/
add_effect_impl.py
Copy path
Top
File metadata and controls
Code
Blame
90 lines (83 loc) · 3.52 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from
pyJianYingDraft
import
trange
,
Video_scene_effect_type
,
Video_character_effect_type
,
CapCut_Video_scene_effect_type
,
CapCut_Video_character_effect_type
,
exceptions
import
pyJianYingDraft
as
draft
from
typing
import
Optional
,
Dict
,
List
,
Union
,
Literal
from
create_draft
import
get_or_create_draft
from
util
import
generate_draft_url
from
settings
import
IS_CAPCUT_ENV
def
add_effect_impl
(
effect_type
:
str
,
# Changed to string type
effect_category
:
Literal
[
"scene"
,
"character"
],
start
:
float
=
0
,
end
:
float
=
3.0
,
draft_id
:
Optional
[
str
]
=
None
,
track_name
:
Optional
[
str
]
=
"effect_01"
,
params
:
Optional
[
List
[
Optional
[
float
]]]
=
None
,
width
:
int
=
1080
,
height
:
int
=
1920
)
->
Dict
[
str
,
str
]:
"""
Add an effect to the specified draft
:param effect_type: Effect type name, will be matched from Video_scene_effect_type or Video_character_effect_type
:param effect_category: Effect category, "scene" or "character", default "scene"
:param start: Start time (seconds), default 0
:param end: End time (seconds), default 3 seconds
:param draft_id: Draft ID, if None or corresponding zip file not found, a new draft will be created
:param track_name: Track name, can be omitted when there is only one effect track
:param params: Effect parameter list, items not provided or None in the parameter list will use default values
:param width: Video width, default 1080
:param height: Video height, default 1920
:return: Updated draft information
"""
# Get or create draft
draft_id
,
script
=
get_or_create_draft
(
draft_id
=
draft_id
,
width
=
width
,
height
=
height
)
# Calculate time range
duration
=
end
-
start
t_range
=
trange
(
f"
{
start
}
s"
,
f"
{
duration
}
s"
)
# Select the corresponding effect type based on effect category and environment
effect_enum
=
None
if
IS_CAPCUT_ENV
:
# If in CapCut environment, use CapCut effects
if
effect_category
==
"scene"
:
try
:
effect_enum
=
CapCut_Video_scene_effect_type
[
effect_type
]
except
:
effect_enum
=
None
elif
effect_category
==
"character"
:
try
:
effect_enum
=
CapCut_Video_character_effect_type
[
effect_type
]
except
:
effect_enum
=
None
else
:
# Default to using JianYing effects
if
effect_category
==
"scene"
:
try
:
effect_enum
=
Video_scene_effect_type
[
effect_type
]
except
:
effect_enum
=
None
elif
effect_category
==
"character"
:
try
:
effect_enum
=
Video_character_effect_type
[
effect_type
]
except
:
effect_enum
=
None
if
effect_enum
is
None
:
raise
ValueError
(
f"Unknown
{
effect_category
}
effect type:
{
effect_type
}
"
)
# Add effect track (only when track doesn't exist)
if
track_name
is
not
None
:
try
:
imported_track
=
script
.
get_imported_track
(
draft
.
Track_type
.
effect
,
name
=
track_name
)
# If no exception is thrown, the track already exists
except
exceptions
.
TrackNotFound
:
# Track doesn't exist, create a new track
script
.
add_track
(
draft
.
Track_type
.
effect
,
track_name
=
track_name
)
else
:
script
.
add_track
(
draft
.
Track_type
.
effect
)
# Add effect
script
.
add_effect
(
effect_enum
,
t_range
,
params
=
params
[::
-
1
]
if
params
else
None
,
track_name
=
track_name
)
return
{
"draft_id"
:
draft_id
,
"draft_url"
:
generate_draft_url
(
draft_id
)
}
You can’t perform that action at this time.