### Full Workflow Example - Project Creation and Editing Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Demonstrates a complete workflow from creating a project to saving it. ```APIDOC ## 完整工作流示例 ### 完整的视频项目创建和编辑流程 ### Description Demonstrates a complete workflow for creating and editing a video project, including creating a project, importing media, adding effects, and saving. ### Method (Conceptual workflow using multiple API calls) ### Endpoint (N/A - Represents a sequence of operations) ### Steps 1. **Create New Video Project** * Use `JianYingApi.Drafts.Create_New_Drafts()` to create a new project at a specified path. 2. **Create Tracks** * Use `draft.Content.NewTrack()` to create video and effect tracks. 3. **Import Media** * Use `draft.Meta.Import2Lib()` to import video, photo, and music files. 4. **Add Effects (Conceptual)** * (Specific API calls for adding effects are not detailed in the provided text, but would typically involve manipulating segments on effect tracks). 5. **Save Project** * Use `draft.Save()` to save the current state of the project. ### Request Example ```python import JianYingApi import uuid # ========== Step 1: Create a new video project ========== project_path = r"E:\\MyVideos\\JianyingPro Drafts/PulpFiction" draft = JianYingApi.Drafts.Create_New_Drafts(project_path) # ========== Step 2: Create tracks ========== video_track = draft.Content.NewTrack(TrackType="video") effect_track = draft.Content.NewTrack(TrackType="effect") # ========== Step 3: Import media files ========== # Import video draft.Meta.Import2Lib(path=r"E:\\Videos\\clip1.mp4", metetype="video") # Import image draft.Meta.Import2Lib(path=r"E:\\Images\\logo.png", metetype="photo") # Import music draft.Meta.Import2Lib(path=r"E:\\Music\\bgm.mp3", metetype="music") # ========== Step 4: Add effects (Conceptual) ========== # Example: Add a transition effect between segments (details not provided) # ========== Step 5: Save the project ========== draft.Save() ``` ### Response (The final response is the saved project file.) ``` -------------------------------- ### Projects.Content.GetTracksById - Get Track by ID Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Retrieve track information by its ID. ```APIDOC ## Projects.Content.GetTracksById - 通过ID获取轨道 ### Description Get track object by track ID. Returns a dictionary containing complete track information, including track type and segment list. ### Method GET (conceptual) ### Endpoint /api/projects/{projectId}/tracks/{trackId} ### Parameters #### Path Parameters - **Track_id** (string) - Required - The ID of the track to retrieve. ### Request Example ```python import JianYingApi draft = JianYingApi.Drafts.Create_New_Drafts(r"E:\Projects\VideoProject") # Create a track video_track = draft.Content.NewTrack(TrackType="video") track_id = video_track["id"] # Get track information track_info = draft.Content.GetTracksById(Track_id=track_id) print(f"轨道类型: {track_info['type']}") print(f"片段数量: {len(track_info['segments'])}") ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the track. - **type** (string) - The type of the track (e.g., "video", "audio", "effect"). - **segments** (array) - A list of segments within the track. #### Response Example ```json { "id": "track_123", "type": "video", "segments": [] } ``` ``` -------------------------------- ### Get Track Information by ID Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Retrieve detailed track information including type and segments using a track ID. ```python import JianYingApi draft = JianYingApi.Drafts.Create_New_Drafts(r"E:\Projects\VideoProject") # 创建轨道 video_track = draft.Content.NewTrack(TrackType="video") track_id = video_track["id"] # 获取轨道信息 track_info = draft.Content.GetTracksById(Track_id=track_id) print(f"轨道类型: {track_info['type']}") print(f"片段数量: {len(track_info['segments'])}") # 输出示例: # 轨道类型: video # 片段数量: 0 draft.Save() ``` -------------------------------- ### Create and Edit Video Project Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Demonstrates the full workflow of creating a project and initializing tracks. ```python import JianYingApi import uuid # ========== 第一步:创建新的视频项目 ========== project_path = r"E:\MyVideos\JianyingPro Drafts/PulpFiction" draft = JianYingApi.Drafts.Create_New_Drafts(project_path) # ========== 第二步:创建轨道 ========== video_track = draft.Content.NewTrack(TrackType="video") effect_track = draft.Content.NewTrack(TrackType="effect") ``` -------------------------------- ### Select Existing Draft Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Navigate to and open a draft project from the startup screen by its index. ```python import JianYingApi jy = JianYingApi.Jy_Warp.Instance(JianYing_Exe_Path=r"E:\Software\JianyingPro") # 等待剪映启动 import time while jy._detect_viewport() != 0: time.sleep(0.5) # 选择第一个草稿(索引为0) jy._Select_Drafts(draft_num=0) # 选择第二个草稿(索引为1) # jy._Select_Drafts(draft_num=1) ``` -------------------------------- ### UI Automation API - Instance._Select_Drafts Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Select and open an existing draft project from the Jianying startup page. ```APIDOC ### Instance._Select_Drafts - 选择现有草稿 ### Description Select and open an existing draft project from the Jianying startup page. Indices start from 0. ### Method POST (conceptual) ### Endpoint /api/ui/instance/select_draft ### Parameters #### Request Body - **draft_num** (integer) - Required - The index of the draft project to select (0-based). ### Request Example ```python import JianYingApi jy = JianYingApi.Jy_Warp.Instance(JianYing_Exe_Path=r"E:\\Software\\JianyingPro") # Wait for Jianying to start import time while jy._detect_viewport() != 0: time.sleep(0.5) # Select the first draft (index 0) jy._Select_Drafts(draft_num=0) # Select the second draft (index 1) # jy._Select_Drafts(draft_num=1) ``` ### Response (No specific response details provided in the source text for this operation.) ``` -------------------------------- ### Create Jianying UI Instance Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Initialize a UI automation instance to control the Jianying application, including startup and viewport detection. ```python import JianYingApi # 创建剪映实例(自动启动剪映) jy = JianYingApi.Jy_Warp.Instance( JianYing_Exe_Path=r"E:\Software\JianyingPro", Start_Jy=True # 是否自动启动剪映 ) # 等待剪映启动并进入主页面 jy._Start_New_Draft_Content(wait=True) # 检测当前界面状态 # -1: 剪映未启动 # 0: 启动页面 # 1: 主编辑页面 # 2: 加载中 # 3: 文件选择页面 # 4: 导出页面 # 5: 素材加载中 viewport = jy._detect_viewport() print(f"当前界面状态: {viewport}") ``` -------------------------------- ### Import Assets to Library Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Add video, photo, or music files to the project resource library. ```python draft.Meta.Import2Lib(path=r"E:/Videos/clip1.mp4", metetype="video") draft.Meta.Import2Lib(path=r"E:/Videos/clip2.mp4", metetype="video") # 导入图片文件到资源库 draft.Meta.Import2Lib(path=r"E:/Images/logo.png", metetype="photo") draft.Meta.Import2Lib(path=r"E:/Images/background.jpg", metetype="photo") # 导入音乐文件到资源库 draft.Meta.Import2Lib(path=r"E:/Music/bgm.mp3", metetype="music") draft.Save() ``` -------------------------------- ### Create New Draft Project Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Initializes a new JianyingPro draft project at the specified path, returning a Projects object for further management. ```python import JianYingApi import uuid # 创建新的视频项目 project_path = r"E:\MyVideos\JianyingPro Drafts/MyProject" draft = JianYingApi.Drafts.Create_New_Drafts(project_path) # 创建视频轨道和特效轨道 video_track = draft.Content.NewTrack(TrackType="video") effect_track = draft.Content.NewTrack(TrackType="effect") # 导入视频素材到资源库 video_path = r"E:/Videos/sample.mp4" draft.Meta.Import2Lib(path=video_path, metetype="video") # 保存项目 draft.Save() ``` -------------------------------- ### Create and Edit JianYing Drafts Source: https://github.com/jianying-automation/jianyingapi/blob/main/README.md Demonstrates initializing a new draft, adding video and effect tracks, importing media, and applying effects to the timeline. ```python import Drafts , uuid d = Drafts.Create_New_Drafts(r"E:\SB\JianyingPro Drafts/PulpFiction") # Create New Project # Create Two Tracks video_track = d.Content.NewTrack(TrackType="video") efect_track = d.Content.NewTrack(TrackType="effect") # Add Video Material video_path = r"E:/Pulp Fiction 1994 720p BluRay DTS x264-SilverTorrentHD.mkv" video_name = "PulpFiction" video_material_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS,name=video_name+"_material")) video_track_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS,name=video_name+"_track")) d.Meta.Import2Lib(path=video_path,metetype="video") d.Content.AddMaterial(Mtype="videos",Content={"category_name":"local","extra_type_option":0,"has_audio":True,"id":video_material_id, "material_name":video_name,"path":video_path,"type":"video"}) d.Content.Add2Track(Track_id=video_track["id"],Content= { "id":video_track_id, "material_id":video_material_id, "visible":True, "volume":1, "source_timerange": { "duration": 605000000, "start": 2050633333 }, "target_timerange": { "duration": 605000000, "start": 0 }}) # Add Effects effect_name = "蓝色丝印" effect_resource_id="7131985730791805448" effect_id="4097661" effect_material_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS,name=effect_name+"_material")) effect_track_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS,name=effect_name+"_track")) d.Content.AddMaterial(Mtype="video_effects",Content= {"apply_target_type":2,"effect_id":effect_id,"id":effect_material_id,"name":effect_name,"render_index":0,"effect_resource_id":effect_resource_id, "type":"video_effect","value":1}) d.Content.Add2Track(Track_id=efect_track["id"],Content= { "id": effect_track_id, "material_id": effect_material_id, "render_index": 11000, "speed": 1, "target_timerange": { "duration": 500600000, "start": 0 }, "visible": True, "volume": 1 } ) # Save d.Save() ``` -------------------------------- ### Import and Add Video Material to Timeline Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Prepare video assets by importing them into the library, defining material properties, and placing them on a specific track. ```python video_path = r"E:/Videos/Pulp Fiction 1994.mkv" video_name = "PulpFiction" video_material_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name=video_name+"_material")) video_segment_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name=video_name+"_segment")) # 导入到资源库 draft.Meta.Import2Lib(path=video_path, metetype="video") # 添加素材定义 draft.Content.AddMaterial( Mtype="videos", Content={ "category_name": "local", "extra_type_option": 0, "has_audio": True, "id": video_material_id, "material_name": video_name, "path": video_path, "type": "video" } ) # 添加到时间线 draft.Content.Add2Track( Track_id=video_track["id"], Content={ "id": video_segment_id, "material_id": video_material_id, "visible": True, "volume": 1, "source_timerange": {"duration": 605000000, "start": 2050633333}, "target_timerange": {"duration": 605000000, "start": 0} } ) ``` -------------------------------- ### UI Automation API - Instance Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Create a Jianying UI automation instance to control the application. ```APIDOC ## UI 自动化 API ### Instance - 创建剪映UI实例 ### Description Create a Jianying UI automation instance. This allows control over Jianying's startup, interface operations, and video export. You can specify the Jianying installation path; otherwise, it defaults to the system's default location. ### Method POST (conceptual) ### Endpoint /api/ui/instance ### Parameters #### Request Body - **JianYing_Exe_Path** (string) - Optional - The absolute path to the Jianying executable. Defaults to the system's default installation path. - **Start_Jy** (boolean) - Optional - Whether to automatically start Jianying. Defaults to `True`. ### Request Example ```python import JianYingApi # Create a Jianying instance (automatically starts Jianying) jy = JianYingApi.Jy_Warp.Instance( JianYing_Exe_Path=r"E:\\Software\\JianyingPro", Start_Jy=True # Whether to automatically start Jianying ) # Wait for Jianying to start and enter the main page jy._Start_New_Draft_Content(wait=True) # Detect current viewport status # -1: Jianying not started # 0: Startup page # 1: Main editing page # 2: Loading # 3: File selection page # 4: Export page # 5: Material loading viewport = jy._detect_viewport() print(f"当前界面状态: {viewport}") ``` ### Response - **viewport** (integer) - The current status of the Jianying UI viewport. ``` -------------------------------- ### UI Automation API - Instance._Export Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Execute video export using the specified export configuration. ```APIDOC ### Instance._Export - 执行视频导出 ### Description Execute video export using the specified export configuration. This method automatically handles UI navigation, parameter setting, and waits for the export to complete. Returns a dictionary containing the export path and filename. ### Method POST (conceptual) ### Endpoint /api/ui/instance/export ### Parameters #### Request Body - **config** (object) - Required - An `Export_Options` object containing the export configuration. ### Request Example ```python import JianYingApi # Start Jianying and open a project jy = JianYingApi.Jy_Warp.Instance(JianYing_Exe_Path=r"E:\\Software\\JianyingPro") jy._Select_Drafts(draft_num=0) # Configure export options export_config = JianYingApi.Jy_Warp.Export_Options( export_name="FinalVideo", export_path=r"E:\\Output", vid_quality=1080, bit_rate="recommend", Encode="H.264", Format="mp4", Frame=30 ) # Execute export result = jy._Export(config=export_config) print(f"导出完成: {result['export_path']}") print(f"文件名: {result['export_name']}") ``` ### Response #### Success Response (200) - **export_path** (string) - The full path to the exported video file. - **export_name** (string) - The name of the exported video file. #### Response Example ```json { "export_path": "E:\\Output\\FinalVideo.mp4", "export_name": "FinalVideo" } ``` ``` -------------------------------- ### JianYing Draft Meta Info - Project Settings Source: https://github.com/jianying-automation/jianyingapi/blob/main/Docs/Doc.md Project settings in draft_meta_info.json include canvas configuration (height, ratio, width), color space, and frame rate (fps). ```json { "canvas_config": {"height":1080,"ratio":"original","width":1920}, "color_space": 0, "fps": 30 } ``` -------------------------------- ### Import Media to Library Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Imports local media files into the project library. Note that this does not automatically add the media to the timeline. ```python import JianYingApi draft = JianYingApi.Drafts.Create_New_Drafts(r"E:\Projects\VideoProject") ``` -------------------------------- ### UI Automation API - Export_Options Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Configure video export options. ```APIDOC ### Export_Options - 视频导出配置 ### Description Configure video export options, including resolution, bitrate, encoding format, and frame rate. Supports H.264 and HEVC encoding, and mp4 and mov formats. ### Method POST (conceptual) ### Endpoint /api/ui/export/options ### Parameters #### Request Body - **export_name** (string) - Required - The name of the exported video file. - **export_path** (string) - Required - The directory where the video will be exported. - **vid_quality** (integer) - Optional - Video resolution. Accepted values: 480, 720, 1080, 1440, 2160. Defaults to 1080. - **bit_rate** (string) - Optional - Bitrate setting. Accepted values: "recommend", "lower", "higher", "option". Defaults to "recommend". - **bit_rate_option_kbps** (integer) - Optional - Custom bitrate in kbps. Only effective when `bit_rate` is set to "option". - **bit_rate_option_cbr** (boolean) - Optional - Use Constant Bitrate (CBR). Defaults to `False`. - **bit_rate_option_vbr** (boolean) - Optional - Use Variable Bitrate (VBR). Defaults to `True`. - **Encode** (string) - Optional - Encoding format. Accepted values: "H.264", "HEVC". Defaults to "H.264". - **Format** (string) - Optional - Output file format. Accepted values: "mp4", "mov". Defaults to "mp4". - **Frame** (integer) - Optional - Frame rate. Accepted values: 24, 25, 30, 50, 60. Defaults to 30. ### Request Example ```python import JianYingApi # Create export configuration export_config = JianYingApi.Jy_Warp.Export_Options( export_name="MyVideo_Final", # Export file name export_path=r"E:\\Output\\Videos", # Export path vid_quality=1080, # Resolution: 480/720/1080/1440/2160 bit_rate="recommend", # Bitrate: recommend/lower/higher/option bit_rate_option_kbps=16000, # Custom bitrate (only effective when bit_rate="option") bit_rate_option_cbr=False, # Constant Bitrate bit_rate_option_vbr=True, # Variable Bitrate (default) Encode="H.264", # Encoding: H.264/HEVC Format="mp4", # Format: mp4/mov Frame=30 # Frame rate: 24/25/30/50/60 ) # High-quality export configuration example high_quality_config = JianYingApi.Jy_Warp.Export_Options( export_name="HighQuality_Output", export_path=r"E:\\Output", vid_quality=2160, # 4K resolution bit_rate="higher", # Higher bitrate Encode="HEVC", # HEVC encoding (higher compression efficiency) Format="mov", # MOV format Frame=60 # 60 FPS ) ``` ### Response (No specific response details provided in the source text for this operation.) ``` -------------------------------- ### Projects.Meta.Import2Lib Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Imports local media files into the project's resource library. ```APIDOC ## Projects.Meta.Import2Lib ### Description Imports a local file into the project library for later use in tracks. ### Parameters #### Request Body - **path** (string) - Required - The local file path of the media. - **metetype** (string) - Required - The media type: 'video', 'photo', or 'music'. ``` -------------------------------- ### Import Media Files Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Import video, photo, and music files into the resource library. ```APIDOC ## Import Media Files ### Description Import various media types (video, photo, music) into the Jianying resource library. ### Method POST (conceptual, as this is a Python API wrapper) ### Endpoint /api/resource/import ### Parameters #### Query Parameters - **path** (string) - Required - The absolute path to the media file. - **metetype** (string) - Required - The type of media to import. Accepted values: "video", "photo", "music". ### Request Example ```python # Import video files draft.Meta.Import2Lib(path=r"E:/Videos/clip1.mp4", metetype="video") draft.Meta.Import2Lib(path=r"E:/Videos/clip2.mp4", metetype="video") # Import image files draft.Meta.Import2Lib(path=r"E:/Images/logo.png", metetype="photo") draft.Meta.Import2Lib(path=r"E:/Images/background.jpg", metetype="photo") # Import music files draft.Meta.Import2Lib(path=r"E:/Music/bgm.mp3", metetype="music") ``` ### Response (No specific response details provided in the source text for this operation.) ### Save Project ```python draft.Save() ``` ``` -------------------------------- ### Execute Video Export Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Perform the export process using a pre-configured export object. ```python import JianYingApi # 启动剪映并打开项目 jy = JianYingApi.Jy_Warp.Instance(JianYing_Exe_Path=r"E:\Software\JianyingPro") jy._Select_Drafts(draft_num=0) # 配置导出选项 export_config = JianYingApi.Jy_Warp.Export_Options( export_name="FinalVideo", export_path=r"E:\Output", vid_quality=1080, bit_rate="recommend", Encode="H.264", Format="mp4", Frame=30 ) # 执行导出 result = jy._Export(config=export_config) print(f"导出完成: {result['export_path']}") print(f"文件名: {result['export_name']}") # 输出示例: # 导出完成: E:\Output\FinalVideo # 文件名: FinalVideo ``` -------------------------------- ### UI Automation API - Instance._To_column Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Navigate to a specified function panel within the Jianying main editing interface. ```APIDOC ### Instance._To_column - 导航到指定功能面板 ### Description Navigate to a specified function panel within the Jianying main editing interface. Requires sequential specification of the main tab, main category, and sub-category. ### Method POST (conceptual) ### Endpoint /api/ui/instance/navigate ### Parameters #### Request Body - **Main_tab** (string) - Required - The main tab name (e.g., "媒体", "特效"). - **Vetree** (string) - Required - The main category within the tab (e.g., "本地", "基础"). - **Vecell** (string) - Required - The sub-category within the category (e.g., "导入", "全部"). ### Request Example ```python import JianYingApi jy = JianYingApi.Jy_Warp.Instance(JianYing_Exe_Path=r"E:\\Software\\JianyingPro") jy._Start_New_Draft_Content(wait=True) # Navigate to the local media import panel jy._To_column( Main_tab="媒体", # Main tab: Media Vetree="本地", # Main category: Local Vecell="导入" # Sub-category: Import ) # Example navigation to the effects panel # jy._To_column(Main_tab="特效", Vetree="基础", Vecell="全部") ``` ### Response (No specific response details provided in the source text for this operation.) ``` -------------------------------- ### Create_New_Drafts Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Creates a new Jianying draft project at the specified path, initializing the necessary draft_content.json and draft_meta_info.json files. ```APIDOC ## Create_New_Drafts ### Description Initializes a new video draft project at a given file system path. ### Parameters #### Path Parameters - **project_path** (string) - Required - The local file system path where the project draft will be created. ### Response - **Projects** (object) - Returns a project object containing Meta and Content managers. ``` -------------------------------- ### Navigate UI Panels Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Programmatically navigate to specific functional panels within the Jianying editor interface. ```python import JianYingApi jy = JianYingApi.Jy_Warp.Instance(JianYing_Exe_Path=r"E:\Software\JianyingPro") jy._Start_New_Draft_Content(wait=True) # 导航到本地媒体导入面板 jy._To_column( Main_tab="媒体", # 主标签:媒体 Vetree="本地", # 主分类:本地 Vecell="导入" # 子分类:导入 ) # 导航到特效面板示例 # jy._To_column(Main_tab="特效", Vetree="基础", Vecell="全部") ``` -------------------------------- ### Configure Video Export Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Define export parameters such as resolution, bitrate, encoding, and format. ```python import JianYingApi # 创建导出配置 export_config = JianYingApi.Jy_Warp.Export_Options( export_name="MyVideo_Final", # 导出文件名 export_path=r"E:\Output\Videos", # 导出路径 vid_quality=1080, # 分辨率: 480/720/1080/1440/2160 bit_rate="recommend", # 码率: recommend/lower/higher/option bit_rate_option_kbps=16000, # 自定义码率(仅bit_rate="option"时生效) bit_rate_option_cbr=False, # 固定码率 bit_rate_option_vbr=True, # 可变码率(默认) Encode="H.264", # 编码: H.264/HEVC Format="mp4", # 格式: mp4/mov Frame=30 # 帧率: 24/25/30/50/60 ) # 高质量导出配置示例 high_quality_config = JianYingApi.Jy_Warp.Export_Options( export_name="HighQuality_Output", export_path=r"E:\Output", vid_quality=2160, # 4K分辨率 bit_rate="higher", # 更高码率 Encode="HEVC", # HEVC编码(更高压缩效率) Format="mov", # MOV格式 Frame=60 # 60帧 ) ``` -------------------------------- ### Add Material Definitions Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Registers media or effect definitions into the project's material library using a dictionary of attributes. ```python import JianYingApi import uuid draft = JianYingApi.Drafts.Create_New_Drafts(r"E:\Projects\VideoProject") video_track = draft.Content.NewTrack(TrackType="video") # 定义视频素材 video_name = "MyVideo" video_path = r"E:/Videos/sample.mp4" video_material_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name=video_name+"_material")) # 添加视频素材到项目 draft.Content.AddMaterial( Mtype="videos", Content={ "category_name": "local", "extra_type_option": 0, "has_audio": True, "id": video_material_id, "material_name": video_name, "path": video_path, "type": "video" } ) # 添加特效素材 effect_name = "蓝色丝印" effect_material_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name=effect_name+"_material")) draft.Content.AddMaterial( Mtype="video_effects", Content={ "apply_target_type": 2, "effect_id": "4097661", "id": effect_material_id, "name": effect_name, "render_index": 0, "effect_resource_id": "7131985730791805448", "type": "video_effect", "value": 1 } ) draft.Save() ``` -------------------------------- ### Generate UUID for IDs in Python Source: https://github.com/jianying-automation/jianyingapi/blob/main/Docs/Doc.md Demonstrates generating time-based and file-based UUIDs in Python, which are recommended for creating unique IDs in JianYing projects. ```python import uuid # Time-based ID time_based_id = uuid.uuid1() # File-based ID file_based_id = uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name="your_file_name") ``` -------------------------------- ### JianYing Proxy Settings Configuration Source: https://github.com/jianying-automation/jianyingapi/blob/main/Docs/Doc.md The draft_agency_config.json file is used to configure proxy settings for JianYing projects. It includes options for materials, whether to use a converter, and the desired video resolution for proxies. ```json { "marterials":null, "use_converter":true, "video_resolution":540 } ``` -------------------------------- ### Projects.Content.NewTrack Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Creates a new timeline track of a specific type (video, audio, text, or effect) within the project. ```APIDOC ## Projects.Content.NewTrack ### Description Adds a new track to the project timeline. ### Parameters #### Request Body - **TrackType** (string) - Required - The type of track to create: 'video', 'audio', 'text', or 'effect'. ### Response - **track** (object) - Returns a dictionary containing the unique 'id' of the created track. ``` -------------------------------- ### JianYing Draft Meta Info - Root Fields Source: https://github.com/jianying-automation/jianyingapi/blob/main/Docs/Doc.md Root fields in draft_meta_info.json define project-level settings such as draft folder path, cover image, draft name, removable storage device, and the root path of the draft folder. ```json { "draft_fold_path": "C:/xxx/JianYingPro Drafts/HelloWorld", "draft_cover": "draft_cover.jpg", "draft_name": "HelloWorld", "draft_removable_storage_device": "C:", "draft_root_path": "C:/xxx/JianYingPro Drafts/" } ``` -------------------------------- ### Save Project and Export via UI Automation Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Finalize the project by saving the draft and using the Jy_Warp instance to trigger the export process. ```python # ========== 第五步:保存项目 ========== draft.Save() print("项目创建完成!") # ========== 第六步:启动剪映并导出(可选)========== jy = JianYingApi.Jy_Warp.Instance(JianYing_Exe_Path=r"E:\Software\JianyingPro") jy._Select_Drafts(draft_num=0) export_config = JianYingApi.Jy_Warp.Export_Options( export_name="PulpFiction_Edit", export_path=r"E:\Output", vid_quality=1080, Encode="H.264", Format="mp4", Frame=30 ) result = jy._Export(config=export_config) print(f"视频导出完成: {result['export_path']}") ``` -------------------------------- ### Create Timeline Tracks Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Adds new tracks to the timeline, supporting video, audio, text, and effect types. ```python import JianYingApi import uuid draft = JianYingApi.Drafts.Create_New_Drafts(r"E:\Projects\VideoProject") # 创建不同类型的轨道 video_track = draft.Content.NewTrack(TrackType="video") audio_track = draft.Content.NewTrack(TrackType="audio") text_track = draft.Content.NewTrack(TrackType="text") effect_track = draft.Content.NewTrack(TrackType="effect") print(f"视频轨道ID: {video_track['id']}") print(f"音频轨道ID: {audio_track['id']}") # 输出示例: # 视频轨道ID: a1b2c3d4-e5f6-7890-abcd-ef1234567890 # 音频轨道ID: b2c3d4e5-f6a7-8901-bcde-f12345678901 draft.Save() ``` -------------------------------- ### Add Material Segments to Tracks Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Places material segments onto specific tracks using microsecond-based timing for source and target ranges. ```python import JianYingApi import uuid draft = JianYingApi.Drafts.Create_New_Drafts(r"E:\Projects\VideoProject") video_track = draft.Content.NewTrack(TrackType="video") effect_track = draft.Content.NewTrack(TrackType="effect") # 准备素材ID video_name = "MyVideo" video_material_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name=video_name+"_material")) video_segment_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name=video_name+"_segment")) # 将视频片段添加到视频轨道 # source_timerange: 源素材的时间范围(从哪里截取) # target_timerange: 目标时间线的时间范围(放置到哪里) draft.Content.Add2Track( Track_id=video_track["id"], Content={ "id": video_segment_id, "material_id": video_material_id, "visible": True, "volume": 1, "source_timerange": { "duration": 605000000, # 6.05秒(微秒单位) "start": 2050633333 # 从源素材的2.05秒开始 }, "target_timerange": { "duration": 605000000, # 6.05秒 "start": 0 # 放置到时间线的起始位置 } } ) # 将特效添加到特效轨道 effect_name = "蓝色丝印" effect_material_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name=effect_name+"_material")) effect_segment_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name=effect_name+"_segment")) draft.Content.Add2Track( Track_id=effect_track["id"], Content={ "id": effect_segment_id, "material_id": effect_material_id, "render_index": 11000, "speed": 1, "target_timerange": { "duration": 500600000, # 5秒 "start": 0 }, "visible": True, "volume": 1 } ) draft.Save() ``` -------------------------------- ### Projects.Content.AddMaterial Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Adds a media asset definition to the project's resource library. ```APIDOC ## Projects.Content.AddMaterial ### Description Registers a new material (video, effect, audio, etc.) into the project library. ### Parameters #### Request Body - **Mtype** (string) - Required - The category of material (e.g., 'videos', 'video_effects', 'audios', 'texts'). - **Content** (object) - Required - A dictionary containing detailed attributes of the material, including 'id', 'path', and type-specific metadata. ``` -------------------------------- ### Projects.Content.Add2Track Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Places a material segment onto a specific timeline track. ```APIDOC ## Projects.Content.Add2Track ### Description Adds a segment to a timeline track using a previously defined material ID. ### Parameters #### Request Body - **Track_id** (string) - Required - The ID of the target track. - **Content** (object) - Required - Segment properties including 'material_id', 'source_timerange', and 'target_timerange' (time units in microseconds). ``` -------------------------------- ### JianYing Draft Meta Info - Media Material Source: https://github.com/jianying-automation/jianyingapi/blob/main/Docs/Doc.md Media material details within draft_meta_info.json include extra information, file path, media type (photo, video, music), and a unique media ID. ```json { "extra_info": "Cat.png", "file_Path": "C:/Cat.png", "metetype": "photo", "id": "468c5693-6et0-41b8-b12g-1244dghd2733" } ``` -------------------------------- ### Apply Video Effects to Timeline Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Define effect material properties and add them to the designated effect track. ```python effect_name = "蓝色丝印" effect_resource_id = "7131985730791805448" effect_id = "4097661" effect_material_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name=effect_name+"_material")) effect_segment_id = str(uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name=effect_name+"_segment")) # 添加特效素材定义 draft.Content.AddMaterial( Mtype="video_effects", Content={ "apply_target_type": 2, "effect_id": effect_id, "id": effect_material_id, "name": effect_name, "render_index": 0, "effect_resource_id": effect_resource_id, "type": "video_effect", "value": 1 } ) # 添加特效到时间线 draft.Content.Add2Track( Track_id=effect_track["id"], Content={ "id": effect_segment_id, "material_id": effect_material_id, "render_index": 11000, "speed": 1, "target_timerange": {"duration": 500600000, "start": 0}, "visible": True, "volume": 1 } ) ``` -------------------------------- ### JianYing Draft Meta Info - Effect Material Source: https://github.com/jianying-automation/jianyingapi/blob/main/Docs/Doc.md Effect material details in draft_meta_info.json specify the apply target type, a unique ID, the effect name, its resource ID, and type. ```json { "apply_target_type": 2, "id": "E5E73C6B-8263-4896-957E-8CAB9B044940", "name": "蓝色丝印", "resource_id": 7131985730791805448, "type": "video_effect" } ``` -------------------------------- ### Delete Project Track Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Remove a specific timeline track from the project using its ID. ```python import JianYingApi draft = JianYingApi.Drafts.Create_New_Drafts(r"E:\Projects\VideoProject") # 创建多个轨道 video_track1 = draft.Content.NewTrack(TrackType="video") video_track2 = draft.Content.NewTrack(TrackType="video") audio_track = draft.Content.NewTrack(TrackType="audio") # 删除不需要的轨道 draft.Content.DelTrack(Track_id=video_track2["id"]) draft.Save() ``` -------------------------------- ### Projects.Content.DelTrack - Delete Track Source: https://context7.com/jianying-automation/jianyingapi/llms.txt Delete a specified timeline track from the project by its ID. ```APIDOC ## Projects.Content.DelTrack - 删除轨道 ### Description Delete a specified timeline track from the project by its ID. ### Method DELETE (conceptual) ### Endpoint /api/projects/{projectId}/tracks/{trackId} ### Parameters #### Path Parameters - **Track_id** (string) - Required - The ID of the track to delete. ### Request Example ```python import JianYingApi draft = JianYingApi.Drafts.Create_New_Drafts(r"E:\Projects\VideoProject") # Create multiple tracks video_track1 = draft.Content.NewTrack(TrackType="video") video_track2 = draft.Content.NewTrack(TrackType="video") audio_track = draft.Content.NewTrack(TrackType="audio") # Delete an unwanted track draft.Content.DelTrack(Track_id=video_track2["id"]) draft.Save() ``` ### Response (No specific response details provided in the source text for this operation.) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.