Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the video synthesis capabilities by integrating the latest Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for "wan 2.7" by introducing new parameters for video synthesis and refactoring the file upload logic to be concurrent. The changes are generally good, but there are a few areas for improvement. The new concurrent upload logic in VideoSynthesisParam.java uses hardcoded values for thread pool size and timeout, which could be problematic. Also, it uses magic strings for key construction, which is not ideal for maintainability. Additionally, the sample usage file VideoSynthesisUsage.java demonstrates a discouraged Java pattern for list initialization. My feedback focuses on addressing these points to improve the code's robustness and maintainability.
Note: Security Review is unavailable for this PR.
| 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()); | ||
| }}; |
There was a problem hiding this comment.
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.
List<VideoSynthesisParam.Media> media = new ArrayList<>();
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());
media.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());| 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()); | ||
| }}; |
There was a problem hiding this comment.
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 java.util.Arrays.asList or List.of (for Java 9+) to create the list.
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()
));| if (this.media != null) { | ||
| for (int i = 0; i < this.media.size(); i++) { | ||
| Media media = this.media.get(i); | ||
| if (media != null) { | ||
| if (media.getUrl() != null) { | ||
| itemsToProcess.add(new TaskItem(MEDIA_URLS, "_URL", media.getUrl(), i)); | ||
| } | ||
| if (media.getReferenceVoice() != null) { | ||
| itemsToProcess.add( | ||
| new TaskItem(MEDIA_URLS, "_REFERENCE_VOICE", media.getReferenceVoice(), i)); | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
The strings "_URL" and "_REFERENCE_VOICE" are used as magic strings to construct keys for the media items. This is fragile and error-prone, as the same strings are manually constructed again when retrieving values from the map (lines 458-459). It's better to define them as private static final constants to avoid typos and improve maintainability.
| } | ||
|
|
||
| if (isUpload) { | ||
| ExecutorService executor = Executors.newFixedThreadPool(5); |
There was a problem hiding this comment.
The thread pool size is hardcoded to 5. This might not be optimal for all environments. Consider defining it as a named constant at the class level (e.g., private static final int UPLOAD_THREAD_POOL_SIZE = 5;) to improve maintainability and clarity. It would be even better to allow users to provide their own ExecutorService.
| } finally { | ||
| executor.shutdown(); | ||
| try { | ||
| if (!executor.awaitTermination(60, TimeUnit.SECONDS)) { |
There was a problem hiding this comment.
The awaitTermination timeout is hardcoded to 60 seconds. This might be too short for uploading large files or on slow networks, which could lead to premature task cancellation. It's recommended to use a larger timeout and define it as a named constant for clarity and ease of modification (e.g., private static final long UPLOAD_TIMEOUT_SECONDS = 180;).
support wan 2.7