scripts/readme/full-2k-ref2va-reference-2k-result-by-directly-calling-open-platform-api.sh
1.9 KB · 63 lines · bash Raw
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 H3_BASE_VIDEO='./r2va.mp4'
5 # Encode the local H3-Base video as a Data URL and create the regeneration task.
6 task_id=$(
7 jq -n \
8 --arg prompt "$EXPANDED_PROMPT" \
9 --rawfile base_video <(
10 printf 'data:video/mp4;base64,'
11 base64 -w0 "$H3_BASE_VIDEO"
12 ) \
13 '{
14 "model": "MiniMax-H3",
15 "content": [
16 {
17 "type": "text",
18 "text": $prompt
19 },
20 {
21 "type": "video_url",
22 "video_url": {
23 "url": "https://cdn.hailuoai.com/prod/hailuo_demo/testsets/h3_promo_eval_ref2va/gallery/sr_v2p26_trio_seed42_20260724/inputs/297573323635_00_%E8%A7%86%E9%A2%911_YnyRbxEwio_video_20260525_163755_1927e9d3.mp4"
24 },
25 "role": "reference_video"
26 },
27 {
28 "type": "audio_url",
29 "audio_url": {
30 "url": "https://cdn.hailuoai.com/prod/hailuo_demo/testsets/h3_promo_eval_ref2va/gallery/sr_v2p26_trio_seed42_20260724/inputs/f463d523c5ce_01_%E9%9F%B3%E9%A2%911_RSLcbpzJPo_6%E6%9C%885%E6%97%A5(1).mp3"
31 },
32 "role": "reference_audio"
33 },
34 {
35 "type": "video_url",
36 "video_url": {
37 "url": $base_video
38 },
39 "role": "base_video"
40 }
41 ],
42 "resolution": "2K"
43 }' |
44 curl --silent --show-error \
45 --request POST \
46 --url "$MINIMAX_API_BASE/v2/video_regeneration" \
47 --header "Authorization: Bearer $TOKEN" \
48 --header 'Content-Type: application/json' \
49 --data-binary @- |
50 jq -er '.task_id'
51 )
52 # Query again while the task is queued or running.
53 regeneration_result=$(
54 curl --silent --show-error \
55 --request GET \
56 --url "$MINIMAX_API_BASE/v2/query/video_generation/$task_id" \
57 --header "Authorization: Bearer $TOKEN"
58 )
59 echo "$regeneration_result" | jq '{status: .task.status}'
60 # Download the 2K MP4 after the task succeeds.
61 video_url=$(echo "$regeneration_result" | jq -er '.task.content.url')
62 curl --location "$video_url" --output r2va_2k.mp4
63