-
Notifications
You must be signed in to change notification settings - Fork 23
support wan 2.7 #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
support wan 2.7 #195
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,16 +18,16 @@ public class VideoSynthesisUsage { | |
| */ | ||
| public static void basicCall() throws ApiException, NoApiKeyException, InputRequiredException { | ||
| VideoSynthesis vs = new VideoSynthesis(); | ||
| List<String> referenceVideoUrls = new ArrayList<>(); | ||
| referenceVideoUrls.add("https://cdn.wanx.aliyuncs.com/wanx/1014827220770308/upload-video-cut/cda0f4dc063ec258184263691558af36.mp4"); | ||
| List<String> referenceUrls = new ArrayList<>(); | ||
| referenceUrls.add("https://cdn.wanx.aliyuncs.com/wanx/1014827220770308/upload-video-cut/cda0f4dc063ec258184263691558af36.mp4"); | ||
|
|
||
| List<String> referenceVideoDescription = new ArrayList<>(); | ||
| referenceVideoDescription.add("这段视频展示一位年轻女性(<cast>)身着灰色长袖上衣与裤子,乌黑长发垂落,面容清秀。她先低头后抬头,目光侧移,继而转身背对再面向镜头,动作流畅自然。背景为素净灰色墙面,环境简约无装饰。镜头由面部特写缓缓拉远至全身,光影柔和,突出人物形态与情绪。"); | ||
| VideoSynthesisParam param = | ||
| VideoSynthesisParam.builder() | ||
| .model("wan2.6-r2v") | ||
| .prompt(" character1 站在海边,吹着海风,夕阳西下,阳光洒在她的脸上") | ||
| .referenceVideoUrls(referenceVideoUrls) | ||
| .referenceUrls(referenceUrls) | ||
| .referenceVideoDescription(referenceVideoDescription) | ||
| .shotType(VideoSynthesis.ShotType.MULTI) | ||
| .watermark(Boolean.TRUE) | ||
|
|
@@ -39,6 +39,83 @@ public static void basicCall() throws ApiException, NoApiKeyException, InputRequ | |
| VideoSynthesisResult result = vs.call(param); | ||
| System.out.println(result); | ||
| } | ||
| /** | ||
| * Create a video compositing task and wait for the task to complete. | ||
| */ | ||
| public static void basicCallI2V27() throws ApiException, NoApiKeyException, InputRequiredException { | ||
| VideoSynthesis vs = new VideoSynthesis(); | ||
| final String prompt = "一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。"; | ||
| final String negativePrompt = "ugly, bad anatomy"; | ||
| List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>(){{ | ||
| add(VideoSynthesisParam.Media.builder() | ||
| .url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png") | ||
| .type(VideoSynthesis.MediaType.FIRST_CLIP) | ||
| .build()); | ||
| add(VideoSynthesisParam.Media.builder() | ||
| .url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3") | ||
| .type(VideoSynthesis.MediaType.DRIVING_AUDIO) | ||
| .build()); | ||
| }}; | ||
| VideoSynthesisParam param = | ||
| VideoSynthesisParam.builder() | ||
| .model("wan2.7-i2v") | ||
| .prompt(prompt) | ||
| .media(media) | ||
| .watermark(Boolean.TRUE) | ||
| .duration(10) | ||
| .negativePrompt(negativePrompt) | ||
| .size("1280*720") | ||
| .build(); | ||
| VideoSynthesisResult result = vs.call(param); | ||
| System.out.println(result); | ||
| } | ||
| /** | ||
| * Create a video compositing task and wait for the task to complete. | ||
| */ | ||
| public static void basicCallR2V27() throws ApiException, NoApiKeyException, InputRequiredException { | ||
| VideoSynthesis vs = new VideoSynthesis(); | ||
| final String prompt = "一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。"; | ||
| final String negativePrompt = "ugly, bad anatomy"; | ||
| List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>(){{ | ||
| add(VideoSynthesisParam.Media.builder() | ||
| .url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/image/res240_269.jpg") | ||
| .type(VideoSynthesis.MediaType.REFERENCE_IMAGE) | ||
| .build()); | ||
| add(VideoSynthesisParam.Media.builder() | ||
| .url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/image/man_5K_7_7K_18_4M.JPG") | ||
| .referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/2s.wav") | ||
| .type(VideoSynthesis.MediaType.REFERENCE_IMAGE) | ||
| .build()); | ||
| add(VideoSynthesisParam.Media.builder() | ||
| .url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/100M.mov") | ||
| .referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/mp3_1s.mp3") | ||
| .type(VideoSynthesis.MediaType.REFERENCE_VIDEO) | ||
| .build()); | ||
| add(VideoSynthesisParam.Media.builder() | ||
| .url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/29_99s.mp4") | ||
| .referenceDescription("这是一个身穿蓝衣的男子<cast>,他有着浓密的络腮胡") | ||
| .type(VideoSynthesis.MediaType.REFERENCE_VIDEO) | ||
| .build()); | ||
| add(VideoSynthesisParam.Media.builder() | ||
| .url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/cat_127.mp4") | ||
| .referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/wav_10s.wav") | ||
| .referenceDescription("这是一只毛绒小猫<cast>,它正在对着镜头微笑") | ||
| .type(VideoSynthesis.MediaType.REFERENCE_VIDEO) | ||
| .build()); | ||
| }}; | ||
|
Comment on lines
+79
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double-brace initialization should be avoided. It creates an anonymous inner class for each use, which can lead to performance and memory issues. A better approach is to use List<VideoSynthesisParam.Media> media = new ArrayList<>(java.util.Arrays.asList(
VideoSynthesisParam.Media.builder()
.url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/image/res240_269.jpg")
.type(VideoSynthesis.MediaType.REFERENCE_IMAGE)
.build(),
VideoSynthesisParam.Media.builder()
.url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/image/man_5K_7_7K_18_4M.JPG")
.referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/2s.wav")
.type(VideoSynthesis.MediaType.REFERENCE_IMAGE)
.build(),
VideoSynthesisParam.Media.builder()
.url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/100M.mov")
.referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/mp3_1s.mp3")
.type(VideoSynthesis.MediaType.REFERENCE_VIDEO)
.build(),
VideoSynthesisParam.Media.builder()
.url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/29_99s.mp4")
.referenceDescription("这是一个身穿蓝衣的男子<cast>,他有着浓密的络腮胡")
.type(VideoSynthesis.MediaType.REFERENCE_VIDEO)
.build(),
VideoSynthesisParam.Media.builder()
.url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/cat_127.mp4")
.referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/wav_10s.wav")
.referenceDescription("这是一只毛绒小猫<cast>,它正在对着镜头微笑")
.type(VideoSynthesis.MediaType.REFERENCE_VIDEO)
.build()
)); |
||
| VideoSynthesisParam param = | ||
| VideoSynthesisParam.builder() | ||
| .model("wan2.7-r2v") | ||
| .prompt(prompt) | ||
| .media(media) | ||
| .watermark(Boolean.TRUE) | ||
| .duration(10) | ||
| .negativePrompt(negativePrompt) | ||
| .size("1280*720") | ||
| .build(); | ||
| VideoSynthesisResult result = vs.call(param); | ||
| System.out.println(result); | ||
| } | ||
|
|
||
| /** | ||
| * List all tasks. | ||
|
|
@@ -63,7 +140,9 @@ public static void fetchTask(String taskId) throws ApiException, NoApiKeyExcepti | |
|
|
||
| public static void main(String[] args) { | ||
| try { | ||
| basicCall(); | ||
| // basicCall(); | ||
| // basicCallI2V27(); | ||
| basicCallR2V27(); | ||
| // listTask(); | ||
| // fetchTask("b451725d-c48f-4f08-9d26-xxx-xxx"); | ||
| } catch (ApiException | NoApiKeyException | InputRequiredException e) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double-brace initialization should be avoided. It creates an anonymous inner class for each use, which can lead to performance and memory issues. It's better to initialize the list and then add elements to it.