|
6 | 6 | import com.volcengine.service.vod.IVodService;
|
7 | 7 | import com.volcengine.service.vod.impl.VodServiceImpl;
|
8 | 8 | import com.volcengine.service.vod.model.request.VodUploadMaterialRequest;
|
| 9 | +import com.volcengine.model.request.vod.VodStreamUploadRequest; |
9 | 10 | import com.volcengine.service.vod.model.response.VodCommitUploadInfoResponse;
|
10 | 11 |
|
11 | 12 | import java.util.ArrayList;
|
@@ -59,6 +60,54 @@ public static void main(String[] args) {
|
59 | 60 | }
|
60 | 61 | }
|
61 | 62 |
|
| 63 | +// // 视频素材流上传 |
| 64 | +// public static void main(String[] args) { |
| 65 | +// // Create a VOD instance in the specified region. |
| 66 | +// // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); |
| 67 | +// IVodService vodService = VodServiceImpl.getInstance(); |
| 68 | +// |
| 69 | +// // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. |
| 70 | +// // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. |
| 71 | +// // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. |
| 72 | +// // vodService.setAccessKey("your ak"); |
| 73 | +// // vodService.setSecretKey("your sk"); |
| 74 | +// |
| 75 | +// String space = "your space name"; |
| 76 | +// |
| 77 | +// List<Functions> functionsList = new ArrayList<>(); |
| 78 | +// Functions getMetaFunc = Functions.GetMetaFunction(); |
| 79 | +// functionsList.add(getMetaFunc); |
| 80 | +// |
| 81 | +// Functions snapShotFunc = Functions.SnapShotFunction(2.3); |
| 82 | +// functionsList.add(snapShotFunc); |
| 83 | +// |
| 84 | +// Functions addOptionInfo = Functions.AddOptionInfoFunction("素材测试视频", "test", "素材测试,视频文件", Const.CategoryVideo, "mp4"); |
| 85 | +// functionsList.add(addOptionInfo); |
| 86 | +// |
| 87 | +// VodStreamUploadRequest vodUploadMaterialRequest = new VodStreamUploadRequest(); |
| 88 | +// vodUploadMaterialRequest.setSpaceName(space); |
| 89 | +// vodUploadMaterialRequest.setFileType(Const.FileTypeMedia); |
| 90 | +// vodUploadMaterialRequest.setContent(null); |
| 91 | +// vodUploadMaterialRequest.setSize(0L); |
| 92 | +// vodUploadMaterialRequest.setChunkSize(0L); |
| 93 | +// vodUploadMaterialRequest.setFileName("hello/vod/material.mp4"); |
| 94 | +// vodUploadMaterialRequest.setFunctions(JSON.toJSONString(functionsList)); |
| 95 | +// vodUploadMaterialRequest.setStorageClass(0); |
| 96 | +// |
| 97 | +// try { |
| 98 | +// VodCommitUploadInfoResponse vodCommitUploadInfoResponse = vodService.streamUploadMaterial(vodUploadMaterialRequest); |
| 99 | +// if (vodCommitUploadInfoResponse.getResponseMetadata().hasError()) { |
| 100 | +// System.out.println(vodCommitUploadInfoResponse.getResponseMetadata().getError()); |
| 101 | +// System.exit(-1); |
| 102 | +// } |
| 103 | +// System.out.println(vodCommitUploadInfoResponse.toString()); |
| 104 | +// System.out.println(vodCommitUploadInfoResponse.getResult().getData().getMid()); |
| 105 | +// System.out.println(vodCommitUploadInfoResponse.getResponseMetadata().getRequestId()); |
| 106 | +// } catch (Exception e) { |
| 107 | +// e.printStackTrace(); |
| 108 | +// } |
| 109 | +// } |
| 110 | + |
62 | 111 | //// 图片素材上传
|
63 | 112 | // public static void main(String[] args) {
|
64 | 113 | // // Create a VOD instance in the specified region.
|
@@ -106,6 +155,54 @@ public static void main(String[] args) {
|
106 | 155 | // }
|
107 | 156 | // }
|
108 | 157 |
|
| 158 | +// // 图片素材流上传 |
| 159 | +// public static void main(String[] args) { |
| 160 | +// // Create a VOD instance in the specified region. |
| 161 | +// // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); |
| 162 | +// IVodService vodService = VodServiceImpl.getInstance(); |
| 163 | +// |
| 164 | +// // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. |
| 165 | +// // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. |
| 166 | +// // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. |
| 167 | +// // vodService.setAccessKey("your ak"); |
| 168 | +// // vodService.setSecretKey("your sk"); |
| 169 | +// |
| 170 | +// String space = "your space name"; |
| 171 | +// |
| 172 | +// List<Functions> functionsList = new ArrayList<>(); |
| 173 | +// Functions getMetaFunc = Functions.GetMetaFunction(); |
| 174 | +// functionsList.add(getMetaFunc); |
| 175 | +// |
| 176 | +// Functions snapShotFunc = Functions.SnapShotFunction(2.3); |
| 177 | +// functionsList.add(snapShotFunc); |
| 178 | +// |
| 179 | +// Functions addOptionInfo = Functions.AddOptionInfoFunction("素材测试图片", "test", "素材测试,图片文件", Const.CategoryImage, "jpg"); |
| 180 | +// functionsList.add(addOptionInfo); |
| 181 | +// |
| 182 | +// VodStreamUploadRequest vodUploadMaterialRequest = new VodStreamUploadRequest(); |
| 183 | +// vodUploadMaterialRequest.setSpaceName(space); |
| 184 | +// vodUploadMaterialRequest.setFileType(Const.FileTypeImage); |
| 185 | +// vodUploadMaterialRequest.setContent(null); |
| 186 | +// vodUploadMaterialRequest.setSize(0L); |
| 187 | +// vodUploadMaterialRequest.setChunkSize(0L); |
| 188 | +// vodUploadMaterialRequest.setFileName("hello/vod/material.jpeg"); |
| 189 | +// vodUploadMaterialRequest.setFunctions(JSON.toJSONString(functionsList)); |
| 190 | +// vodUploadMaterialRequest.setStorageClass(0); |
| 191 | +// |
| 192 | +// try { |
| 193 | +// VodCommitUploadInfoResponse vodCommitUploadInfoResponse = vodService.streamUploadMaterial(vodUploadMaterialRequest); |
| 194 | +// if (vodCommitUploadInfoResponse.getResponseMetadata().hasError()) { |
| 195 | +// System.out.println(vodCommitUploadInfoResponse.getResponseMetadata().getError()); |
| 196 | +// System.exit(-1); |
| 197 | +// } |
| 198 | +// System.out.println(vodCommitUploadInfoResponse.toString()); |
| 199 | +// System.out.println(vodCommitUploadInfoResponse.getResult().getData().getMid()); |
| 200 | +// System.out.println(vodCommitUploadInfoResponse.getResponseMetadata().getRequestId()); |
| 201 | +// } catch (Exception e) { |
| 202 | +// e.printStackTrace(); |
| 203 | +// } |
| 204 | +// } |
| 205 | + |
109 | 206 | //// 字幕素材上传
|
110 | 207 | // public static void main(String[] args) {
|
111 | 208 | // // Create a VOD instance in the specified region.
|
@@ -153,4 +250,51 @@ public static void main(String[] args) {
|
153 | 250 | // }
|
154 | 251 | // }
|
155 | 252 |
|
| 253 | + // 字幕素材流上传 |
| 254 | +// public static void main(String[] args) { |
| 255 | +// // Create a VOD instance in the specified region. |
| 256 | +// // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); |
| 257 | +// IVodService vodService = VodServiceImpl.getInstance(); |
| 258 | +// |
| 259 | +// // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. |
| 260 | +// // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. |
| 261 | +// // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. |
| 262 | +// // vodService.setAccessKey("your ak"); |
| 263 | +// // vodService.setSecretKey("your sk"); |
| 264 | +// |
| 265 | +// String space = "your space name"; |
| 266 | +// |
| 267 | +// List<Functions> functionsList = new ArrayList<>(); |
| 268 | +// Functions getMetaFunc = Functions.GetMetaFunction(); |
| 269 | +// functionsList.add(getMetaFunc); |
| 270 | +// |
| 271 | +// Functions snapShotFunc = Functions.SnapShotFunction(2.3); |
| 272 | +// functionsList.add(snapShotFunc); |
| 273 | +// |
| 274 | +// Functions addOptionInfo = Functions.AddOptionInfoFunction("素材测试字幕", "test", "素材测试,字幕文件", Const.CategorySubtitle, "vtt"); |
| 275 | +// functionsList.add(addOptionInfo); |
| 276 | +// |
| 277 | +// VodStreamUploadRequest vodUploadMaterialRequest = new VodStreamUploadRequest(); |
| 278 | +// vodUploadMaterialRequest.setSpaceName(space); |
| 279 | +// vodUploadMaterialRequest.setFileType(Const.FileTypeObject); |
| 280 | +// vodUploadMaterialRequest.setContent(null); |
| 281 | +// vodUploadMaterialRequest.setSize(0L); |
| 282 | +// vodUploadMaterialRequest.setChunkSize(0L); |
| 283 | +// vodUploadMaterialRequest.setFileName("hello/vod/material.vtt"); |
| 284 | +// vodUploadMaterialRequest.setFunctions(JSON.toJSONString(functionsList)); |
| 285 | +// vodUploadMaterialRequest.setStorageClass(0); |
| 286 | +// |
| 287 | +// try { |
| 288 | +// VodCommitUploadInfoResponse vodCommitUploadInfoResponse = vodService.streamUploadMaterial(vodUploadMaterialRequest); |
| 289 | +// if (vodCommitUploadInfoResponse.getResponseMetadata().hasError()) { |
| 290 | +// System.out.println(vodCommitUploadInfoResponse.getResponseMetadata().getError()); |
| 291 | +// System.exit(-1); |
| 292 | +// } |
| 293 | +// System.out.println(vodCommitUploadInfoResponse.toString()); |
| 294 | +// System.out.println(vodCommitUploadInfoResponse.getResult().getData().getMid()); |
| 295 | +// System.out.println(vodCommitUploadInfoResponse.getResponseMetadata().getRequestId()); |
| 296 | +// } catch (Exception e) { |
| 297 | +// e.printStackTrace(); |
| 298 | +// } |
| 299 | +// } |
156 | 300 | }
|
0 commit comments