scripts/readme/full-2k-t2va-h3-regenerate-2k.sh
1.3 KB · 49 lines · bash Raw
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 H3_BASE_VIDEO='./t2va.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": $base_video
24 },
25 "role": "base_video"
26 }
27 ],
28 "resolution": "2K"
29 }' |
30 curl --silent --show-error \
31 --request POST \
32 --url "$MINIMAX_API_BASE/v2/video_regeneration" \
33 --header "Authorization: Bearer $TOKEN" \
34 --header 'Content-Type: application/json' \
35 --data-binary @- |
36 jq -er '.task_id'
37 )
38 # Query again while the task is queued or running.
39 regeneration_result=$(
40 curl --silent --show-error \
41 --request GET \
42 --url "$MINIMAX_API_BASE/v2/query/video_generation/$task_id" \
43 --header "Authorization: Bearer $TOKEN"
44 )
45 echo "$regeneration_result" | jq '{status: .task.status}'
46 # Download the 2K MP4 after the task succeeds.
47 video_url=$(echo "$regeneration_result" | jq -er '.task.content.url')
48 curl --location "$video_url" --output t2va_2k.mp4
49