1212import com .alibaba .dashscope .utils .PreprocessInputImage ;
1313import com .google .gson .JsonObject ;
1414import java .nio .ByteBuffer ;
15+ import java .util .ArrayList ;
1516import java .util .HashMap ;
17+ import java .util .List ;
1618import java .util .Map ;
1719import lombok .Builder ;
1820import lombok .Data ;
@@ -55,6 +57,13 @@ public class VideoSynthesisParam extends HalfDuplexServiceParam {
5557 /** The input audio url. */
5658 @ Builder .Default private String audioUrl = null ;
5759
60+ /** list of character reference video file urls uploaded by the user */
61+ @ Builder .Default private List <String > referenceVideoUrls = null ;
62+
63+ /** For the description information of the picture and sound of the reference video, corresponding to ref video,
64+ * it needs to be in the order of the url. If the quantity is different, an error will be reported */
65+ @ Builder .Default private List <String > referenceVideoDescription = null ;
66+
5867 /** The extra parameters. */
5968 @ GsonExclude @ Singular protected Map <String , Object > extraInputs ;
6069
@@ -82,6 +91,8 @@ public class VideoSynthesisParam extends HalfDuplexServiceParam {
8291
8392 @ Builder .Default private Boolean audio = null ;
8493
94+ @ Builder .Default private String shotType = null ;
95+
8596 /** The inputs of the model. */
8697 @ Override
8798 public JsonObject getInput () {
@@ -124,6 +135,14 @@ public JsonObject getInput() {
124135 jsonObject .addProperty (TAIL_FRAME , tailFrame );
125136 }
126137
138+ if (referenceVideoUrls != null && !referenceVideoUrls .isEmpty ()) {
139+ jsonObject .add (REFERENCE_VIDEO_URLS , JsonUtils .toJsonArray (referenceVideoUrls ));
140+ }
141+
142+ if (referenceVideoDescription != null && !referenceVideoDescription .isEmpty ()) {
143+ jsonObject .add (REFERENCE_VIDEO_DESCRIPTION , JsonUtils .toJsonArray (referenceVideoDescription ));
144+ }
145+
127146 if (extraInputs != null && !extraInputs .isEmpty ()) {
128147 JsonObject extraInputsJsonObject = JsonUtils .parametersToJsonObject (extraInputs );
129148 JsonUtils .merge (jsonObject , extraInputsJsonObject );
@@ -164,6 +183,9 @@ public Map<String, Object> getParameters() {
164183 if (audio != null ) {
165184 params .put (AUDIO , audio );
166185 }
186+ if (shotType != null ) {
187+ params .put (SHOT_TYPE , shotType );
188+ }
167189 params .putAll (super .getParameters ());
168190 return params ;
169191 }
@@ -200,6 +222,13 @@ public void checkAndUpload() throws NoApiKeyException, UploadFileException {
200222 inputChecks .put (LAST_FRAME_URL , this .lastFrameUrl );
201223 inputChecks .put (HEAD_FRAME , this .headFrame );
202224 inputChecks .put (TAIL_FRAME , this .tailFrame );
225+ int rvs = 0 ;
226+ if (this .referenceVideoUrls != null ) {
227+ rvs = this .referenceVideoUrls .size ();
228+ for (int i = 0 ; i < rvs ; i ++) {
229+ inputChecks .put (REFERENCE_VIDEO_URLS + "[" + i + "]" , this .referenceVideoUrls .get (i ));
230+ }
231+ }
203232
204233 boolean isUpload = PreprocessInputImage .checkAndUploadImage (getModel (), inputChecks , getApiKey ());
205234
@@ -212,6 +241,13 @@ public void checkAndUpload() throws NoApiKeyException, UploadFileException {
212241 this .lastFrameUrl = inputChecks .get (LAST_FRAME_URL );
213242 this .headFrame = inputChecks .get (HEAD_FRAME );
214243 this .tailFrame = inputChecks .get (TAIL_FRAME );
244+ if (rvs > 0 ) {
245+ List <String > newVideos = new ArrayList <>();
246+ for (int i = 0 ; i < rvs ; i ++) {
247+ newVideos .add (inputChecks .get (REFERENCE_VIDEO_URLS + "[" + i + "]" ));
248+ }
249+ this .referenceVideoUrls = newVideos ;
250+ }
215251 }
216252 }
217253
0 commit comments