본문으로 건너뛰기
버전: 최신 버전

Scripts to Video

주어진 문장을 바탕으로 동영상 콘텐츠를 생성하는 과정을 설명합니다.


1. 프로젝트생성 요청

문장과 옵션을 전달하여 프로젝트생성 요청하세요.

1. API endpoint

https://app.aistudios.com/api/odin/v3/automation/scripts_to_video

1-2. Request parameter

keydesctyperequireddefault
scripts동영상 생성을 위한 문장Stringtrue-
options비디오 생성에 사용할 구성Jsonfalse
options.language비디오에 사용된 언어
언어 코드는 ISO 639-1 표준을 따릅니다.
Stringfalse-
options.duration비디오 시간
(30 | 60 | 90 | 120 | 150 | 180)
Numberfalse-
options.scriptOption스크립트 사용옵션
(AI는 스크립트를 매끄럽게 만드는 데 도움을 줄 수도 있고, 작성한 그대로 원본 버전을 그대로 유지할 수도 있습니다.)
(ai | original)
Stringfalseai
options.objective비디오 영상의 목표 (예. 홍보, 교육, 설명)Stringfalse-
options.audience비디오 영상의 대상 청중(예. 마케터, 학생)Stringfalse-
options.tone비디오 영상의 어조(예. 명확하게, 격식있게)Stringfalse-
options.speed원래 속도와 비교한 비디오 재생 속도
(0.5 ~ 1.5)
Numberfalse1
options.media비디오 생성에 사용된 이미지 정보
(search | free | premium | generative)
Stringfalse-
options.useGenerativeHighQuality고화질 AI 미디어 활성화
(options.media='generative' 경우에만 유효)
(true | false)
Booleanfalsefalse
options.style스타일 정보
(options.media='generative' 경우에만 유효)
(realistic | digitalPainting | sketch | oilPainting | pixelArt | watercolor | lowPoly | cyberpunk | fantasy | anime)
Stringfalserealistic
options.templateId비디오 생성에 사용할 템플릿IDStringfalse-
options.model비디오 생성에 사용할 모델IDStringfalse-
options.voiceOnly비디오 생성에 사용된 모델의 목소리만
(true | false)
Booleanfalsefalse

1-3. Response parameters

keydesctype
projectId동영상 생성 요청한 프로젝트 IDString
automationJobId동영상 생성 요청한 작업 IDString

1-4. Sample Request

curl https://app.aistudios.com/api/odin/v3/automation/scripts_to_video  \
-H "Authorization: ${API KEY}" \
-H "Content-Type: application/json" \
-X POST \
-d '{
"scripts" : "K-Culture is a short-historied term referring to South Korean popular culture.\nThe term was first coined in the late 1990s,1 when various elements of Korean pop culture – from music, to films, dramas, and fashion, food, comics and novels – began to spread overseas, first into neighbouring Asian countries, then further afield.\nThe feverish fondness that Korean pop culture attracted in overseas media soon gave rise to a host of terms such terms as the “Korean Wave” (a.k.a. Hallyu), K-Culture, and so on. In fact, the term K-Culture was quickly reimported back into South Korea, where it has been used readily to describe South Korean pop culture.",
"options" : {
"language": "en",
"scriptOption": "ai",
"speed": 1,
"templateId": "## template id ##",
"model": "## model id ##",
"voiceOnly": false,
}
}'


2. 프로젝트생성 진행상황 확인

요청후 동영상 생성 현재 진행 상황을 확인합니다.

2-1. Api endpoint

GET https://app.aistudios.com/api/odin/v3/automation/progress?projectId=${projectId}

2-2. Response Parameters

KeyDescriptionType
state자동화 프로세스의 현재 상태String
progress비디오 생성 완료 비율Number

2-3. Sample request

import axios from "axios";

const projectId = "your_project_id";
const token = "your_api_key";

axios.get(`https://app.aistudios.com/api/odin/v3/automation/progress/${projectId}`, {}, {
headers: {
"Authorization": token,
"Content-Type": "application/json"
}
})
.then((res) => {
console.log(res.data)
})
.catch((error) => {
console.error(error)
});


3. 내보내기

생성된 프로젝트를 동영상 내보내기 할려면 프로젝트 내보내기 이용하세요.



4. 전체코드

const API_HOST = 'https://app.aistudios.com'

const GET_TOKEN_API_PATH = '/api/odin/v3/auth/token'
const CREATE_API_PATH = '/api/odin/v3/automation/topic_to_video'
const CREATE_PROGRESS_API_PATH = '/api/odin/v3/automation/progress'
const EXPORT_API_PATH = '/api/odin/v3/editor/project/export'
const EXPORT_PROGRESS_API_PATH = '/api/odin/v3/editor/progress'

const appId = '## your appId ##'
const userKey = '## your userKey ##'

const scripts = "K-Culture is a short-historied term referring to South Korean popular culture.\nThe term was first coined in the late 1990s,1 when various elements of Korean pop culture – from music, to films, dramas, and fashion, food, comics and novels – began to spread overseas, first into neighbouring Asian countries, then further afield.\nThe feverish fondness that Korean pop culture attracted in overseas media soon gave rise to a host of terms such terms as the “Korean Wave” (a.k.a. Hallyu), K-Culture, and so on. In fact, the term K-Culture was quickly reimported back into South Korea, where it has been used readily to describe South Korean pop culture.";
const options = {
"language": "en",
// "duration": 60,
"scriptOption": "ai",
// "objective": "education",
// "audience": "students",
// "tone": "clearly",
"speed": 1,
// "media": "generative",
// "useGenerativeHighQuality": true,
// "style": "digitalPainting",
"templateId": "## template id ##",
"model": "## model id ##", // Michael
"voiceOnly": false,
};

const delay = async (ms = 1000 * 60) => {
await new Promise(r => setTimeout(r, ms))
}

const main = async () => {
try {
/**
* get api token
*/
const token = await fetch(
`${API_HOST}${GET_TOKEN_API_PATH}`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
appId,
userKey
})
}
)
.then((response) => response.json())
.then((response) => {
if (response.success == true) {
return response.data.token
} else {
console.error(`import authentication token error, code:`, response.error.code, `, msg:`, response.error.msg);
throw Error(response);
}
});

console.log('token : ', token);

/**
* create project
*/
const projectId = await fetch(
`${API_HOST}${CREATE_API_PATH}`,
{
method: 'POST',
headers: {
Authorization: token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"scripts": scripts,
"options": options
})
}
)
.then((response) => response.json())
.then((response) => {
if (response.success == true) {
return response.data.projectId
} else {
console.error(`create project error, code:`, response.error.code, `, msg:`, response.error.msg);
throw Error(response);
}
});

console.log('request create project, projectId : ', projectId);

/**
* project progress
*/
let isCreateProjectFinish = false

while (!isCreateProjectFinish) {
const progressData = await fetch(
`${API_HOST}${CREATE_PROGRESS_API_PATH}/?projectId=${projectId}`,
{
method: 'GET',
headers: {
Authorization: token,
},
},
)
.then((response) => response.json())
.then((response) => {
if (response.success === true) {
return response.data
} else {
console.error(`project progress error, code:`, response.error.code, `, msg:`, response.error.msg);
throw Error(response);
}
})

console.log('project creation progress, state: ', progressData.state, ', progress : ', progressData.progress);

if (progressData.state === "finish" && progressData.progress === 100) {
isCreateProjectFinish = true
} else {
await delay()
}
}

/**
* export project
*/
await fetch(
`${API_HOST}${EXPORT_API_PATH}`,
{
method: 'POST',
headers: {
Authorization: token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"projectId": projectId
})
}
)
.then((response) => response.json())
.then((response) => {
if (response.success == true) {
return response.data.projectId
} else {
console.error(`export project error, code:`, response.error.code, `, msg:`, response.error.msg);
throw Error(response);
}
});

console.log('request export project');


/**
* export progress
*/
let isExportFinish = false
let videoUrl = ''

while (!isExportFinish) {
const progressData = await fetch(
`${API_HOST}${EXPORT_PROGRESS_API_PATH}/${projectId}`,
{
method: 'GET',
headers: {
Authorization: token,
}
},
)
.then((response) => response.json())
.then((response) => {
if (response.success === true) {
return response.data
} else {
console.error(`export progress error, code:`, response.error.code, `, msg:`, response.error.msg);
throw Error(response);
}
})

console.log(`export `, progressData.state, `, progress : `, progressData.progress)

if (progressData.progress < 100) {
await delay()
} else {
videoUrl = progressData.downloadUrl
isExportFinish = true
}
}

console.log('videoUrl :', videoUrl);
} catch (error) {
// ...
}

console.log('finish');
}

main()