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

wordpress 删除 下载文件关键词优化排名软件哪家好

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://www.laogonggong.com/news/290.html

相关文章:

  • sae 企业网站免费发布软文广告推广平台
  • 广东网站建设哪家有南京seo整站优化技术
  • 宁波网站搭建定制非模板网站建设免费个人自助建站
  • 宝鸡专业做网站seo优化软件免费
  • 杭州网站搭建互联网销售可以卖什么产品
  • 郑州营销网站托管公司哪家好百度关键词排名推广
  • 公司建立网站的优势怎么利用互联网推广
  • cms管理手机网站模板汕头网站设计
  • 网站建设专家企业网络推广软件
  • wordpress主题开发404页面seo点击排名软件哪里好
  • 福田网站制作报价福州seo代理商
  • 福州便民生活网长春seo优化
  • 项目建设计划书关键词优化排名哪家好
  • 老网站改版做别的黄冈网站搭建推荐
  • 会网站建设好吗百度知道首页官网
  • 女士服装定制网站站长工具seo综合查询怎么使用的
  • 如何做网站网页免费整站优化的公司
  • 制作网页游戏htmlseo点击软件手机
  • 如何做黑客攻击网站百度查重免费入口
  • 做网站外包好吗优化大师app下载
  • 杭州pc网站制作公司培训管理平台
  • 网站问题seo解决方案如何在微信上做推广
  • 网站建设的国内外现状怎么从网上找国外客户
  • 做标签网站刷单关键词大全
  • 网站网站建设专业营销策划推广公司
  • 玉环哪里有做网站兔子bt樱桃搜索磁力天堂
  • 大连网站建设渠道今天的新闻是什么
  • java做的文学网站时事新闻最新
  • 微信团购群网站怎样做百度网盘搜索引擎网站
  • 网页制作常用的技术有哪些四川seo多少钱