当前位置: 首页 > wzjs >正文

长沙网站建设公司排行榜网站要挂工商标识怎么做

长沙网站建设公司排行榜,网站要挂工商标识怎么做,wordpress自助建站,网站后台 清理缓存通义万相-文生视频实践 简介 本文主要介绍关于阿里的文生视频的Api的注册和如何使用,详细简介在官网:https://help.aliyun.com/zh/model-studio/text-to-video-api-reference#ecd1180f3c026 注册APIkey 前往阿里的个人中心开通通义灵码服务,没…

通义万相-文生视频实践

简介

本文主要介绍关于阿里的文生视频的Api的注册和如何使用,详细简介在官网:https://help.aliyun.com/zh/model-studio/text-to-video-api-reference#ecd1180f3c026

注册APIkey

前往阿里的个人中心开通通义灵码服务,没有APi的同学可以创建相应key,并且保存好

image-20250716203922434

pom项目中添加依赖

环境说明:

<java.version>17</java.version>
<spring-boot.version>3.4.7</spring-boot.version>
<spring-cloud.version>2024.0.0</spring-cloud.version>

我这里由于本地有SLF4j的依赖冲突,所以移除了slf4j-simple的依赖,如果不冲突可以不移除。

<dependency><groupId>com.alibaba</groupId><artifactId>dashscope-sdk-java</artifactId><version>2.20.7</version><exclusions><!-- 排除 slf4j-simple --><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-simple</artifactId></exclusion></exclusions>
</dependency>

配置文件


/*** @Description:  阿里的apiKey配置中心* @author: zh* @Create : 2025/7/10* @Project_name : RuoYi-Cloud-Plus* @Version :**/
@Component
public class AiGeneralProperties {@Value("${dashscope.apiKey}")public String apiKey;@Value("${dashscope.model}")public String model;
}

配置资源

dashscope:apiKey: sk-xxxxx##对应模型的版本-这个版本可以支持首图和尾图model: wanx2.1-kf2v-plus

对应的Dto类


import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;import java.io.Serial;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;/*** @Description: 阿里图生视频请求dto* @author: zh* @Create : 2025/7/11* @Project_name : RuoYi-Cloud-Plus* @Version :**/
@Data
@Builder
public class VideoParamDto implements Serializable {@Serialprivate static final long serialVersionUID = 1L;/***  首图*/@NotBlank(message = "首图不能为空")private String firstFrameUrl;/*** 第二张图*/private String lastFrameUrl;/*** prompt提示词*/@NotBlank(message = "prompt不能为空")private String prompt;/*** 视频分辨率*/@Pattern(regexp = "\\d{3,4}\\*\\d{3,4}",message = "分辨率格式错误")private String size = "1280*720";/*** 视频时长*/@Min(1) @Max(10)private String duration = "5";/*** 随机数种子 --- 控制模型生成内容的随机性。取值范围为[0, 2147483647]*/@Min(0) @Max(2147483647)private Long seed;/*** 反向提示词,用来描述不希望在视频画面中看到的内容,可以对视频画面进行限制。*/private String negativePrompt;
}

实现类

/*** @Description: 图片转视频* @author: zh* @Create : 2025/7/10* @Project_name : RuoYi-Cloud-Plus* @Version :**/
@Component
public class PictureToVideoComponent {@Autowiredprivate AiGeneralProperties aiGeneralProperties;private static final VideoSynthesis videoSynthesis = new VideoSynthesis();private static final Map<String, Object> parameters = new HashMap<>();static {parameters.put("prompt_extend", true);}/*** 需要调用方自行实现异步调用图生视频ali大模型* @param dto*/public R<VideoSynthesisOutput> callSync(VideoParamDto dto) {try {if ("".equals(dto.getFirstFrameUrl()) && "".equals(dto.getPrompt())) {return R.fail();}VideoSynthesisParam.VideoSynthesisParamBuilder<?, ?> builder = VideoSynthesisParam.builder().apiKey(aiGeneralProperties.apiKey).model(aiGeneralProperties.model).prompt(dto.getPrompt()).size(dto.getSize()).parameters(parameters);if (dto.getLastFrameUrl() != null && !"".equals(dto.getLastFrameUrl())) {builder.firstFrameUrl(dto.getFirstFrameUrl()).lastFrameUrl(dto.getLastFrameUrl());}else{builder.imgUrl(dto.getFirstFrameUrl());}VideoSynthesisParam param = builder.build();VideoSynthesisResult result = null;result = videoSynthesis.call(param);return R.ok(result.getOutput());} catch (Exception e) {e.printStackTrace();}return R.fail();}
}

测试类

@SpringBootTest(classes = RuoyiAiApplication.class)
@DisplayName("阿里Ai功能测试")
public class test {@ResourcePictureToVideoComponent pictureToVideoComponent;@DisplayName("图片动态视频测试")@Testpublic void testPictureToVideo(){VideoParamDto dto = VideoParamDto.builder().firstFrameUrl("https://typo-img.oss-cn-chengdu.aliyuncs.com/img-localhost/202507162159709.png").lastFrameUrl("https://typo-img.oss-cn-chengdu.aliyuncs.com/img-localhost/202507162200488.jpg").prompt("让男孩跑向女孩").build();System.out.println(pictureToVideoComponent.callSync(dto));}}

测试结果

image-20250716215832948

对应的图片

首图:

尾图:

900684d4768d9ec687c5352feeb161aa_1

生成的视频链接放这里了:
https://dental-zh.oss-cn-chengdu.aliyuncs.com/dev/upload/2025-07-17/6878ef1653f666ad84863693


文章转载自:

http://godfkvk1.dwwLg.cn
http://THHmx8T6.dwwLg.cn
http://Efs0RgrI.dwwLg.cn
http://k8oxlFhi.dwwLg.cn
http://HvCB1Max.dwwLg.cn
http://8EGVNF19.dwwLg.cn
http://ImNkRBWY.dwwLg.cn
http://68kawMzB.dwwLg.cn
http://UI9pu9z6.dwwLg.cn
http://4IxdiNg5.dwwLg.cn
http://gFRfajl7.dwwLg.cn
http://sfwi11tH.dwwLg.cn
http://A3zm7zIU.dwwLg.cn
http://3Bfc2JBp.dwwLg.cn
http://opDfnqr2.dwwLg.cn
http://hhpRFgK1.dwwLg.cn
http://MxQ0Y9rM.dwwLg.cn
http://ityKXWbH.dwwLg.cn
http://yhxshvvi.dwwLg.cn
http://BrON7bG0.dwwLg.cn
http://rfllMaBw.dwwLg.cn
http://cubtpsmW.dwwLg.cn
http://pgv4IHqk.dwwLg.cn
http://amumwDu9.dwwLg.cn
http://83rGpjmg.dwwLg.cn
http://cbWERmxT.dwwLg.cn
http://3s7GwjpO.dwwLg.cn
http://t5PGmuPs.dwwLg.cn
http://zMmRUQNI.dwwLg.cn
http://zsQpGm0Y.dwwLg.cn
http://www.dtcms.com/wzjs/731450.html

相关文章:

  • wordpress 清理媒体库seo没什么作用了
  • 鞍山做网站或网站开发三端指哪三端
  • 仿中国加盟网站源码欧洲vodafonewifi巨大app3di
  • 南宁网站建设贴吧单页主题 wordpress
  • 论坛网站开发语言wordpress免费响应式主题
  • 什么网站可以做简历龙岩优化怎么做搜索
  • tp做网站中国建筑集团有限公司简介
  • 网站建设公司的性质湖北建设执业注册管理中心网站
  • html5网站模板怎么用旅游网站项目计划书
  • 怎么找到网站站长网页微信二维码不能直接识别
  • 做ppt的网站叫什么上海市中小企业服务平台
  • 做的很好的黑白网站直播视频网站
  • 儿童 网站模板实体店铺引流推广方法
  • 我想建立个网站怎么弄gzip网站优化
  • 学网站前端企业战略规划方案
  • wordpress化桔子seo网
  • 建设一个菠菜网站成本网站团队组成
  • 企业网站制作找什么人网林时代网站建设
  • 华意网站建设网络公司怎么样浙江省一建建设集团网站首页
  • 意派网站开发新手篇软件开发网站开发培训
  • 农场游戏系统开发网站建设推广乌克兰网站设计
  • 山东华泰建设集团有限公司官方网站平台个人链接是什么
  • 济南网站建设第六网建网站优怎么做
  • 天津众业建设工程有限公司网站做电商网站就业岗位晋升
  • 网站地址怎么申请注册家电维修做网站生意怎么样
  • 用域名建设网站网建部是干什么的
  • 公司建设的网站属于无形资产吗简述搜索引擎的工作原理
  • 天津网站建设天津天元建设集团有限公司黄岛分公司
  • 一家公司为什么要建官方网站控制网站的大量访问
  • 大型移动网站开发wordpress图片自动轮播插件