Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const axios = require('axios');
- /**
- * Asu Veo31 AI Video Generator
- * Converte imagens em vídeos usando a API Veo31AI.
- *
- * @example
- * // Command line usage
- * node asuVeo31.js "a cat dancing" "https://example.com/cat.jpg"
- *
- * @By: 𖧄 𝐋𝐔𝐂𝐀𝐒 𝐌𝐎𝐃 𝐃𝐎𝐌𝐈𝐍𝐀 𖧄
- * Canal: https://whatsapp.com/channel/0029Vb69bDnAe5VmzSMwBH11
- *
- */
- async function asuVeo31() {
- const prompt = process.argv[2];
- const image = process.argv[3];
- if (!prompt || !image) {
- console.log('Uso: node asuVeo31.js "prompt" "image_url"');
- console.log('Exemplo: node asuVeo31.js "um gato dançando" "https://example.com/cat.jpg"');
- return;
- }
- const payload = {
- videoPrompt: prompt,
- videoAspectRatio: "16:9",
- videoDuration: 5,
- videoQuality: "540p",
- videoModel: "v4.5",
- videoImageUrl: image,
- videoPublic: false
- };
- try {
- console.log('Iniciando a geração de vídeo...');
- const gen = await axios.post('https://veo31ai.io/api/pixverse-token/gen', payload, {
- headers: { 'Content-Type': 'application/json' }
- });
- const taskId = gen.data.taskId;
- if (!taskId) {
- console.log('Falha ao criar a tarefa');
- return;
- }
- console.log(`Tarefa criada: ${taskId}`);
- console.log('Aguardando a geração do vídeo...');
- let videoUrl = null;
- const timeout = Date.now() + 180000; // 3 minutes timeout
- let attempts = 0;
- while (Date.now() < timeout) {
- attempts++;
- const res = await axios.post('https://veo31ai.io/api/pixverse-token/get', {
- taskId,
- videoPublic: false,
- videoQuality: "540p",
- videoAspectRatio: "16:9",
- videoPrompt: prompt
- }, {
- headers: { 'Content-Type': 'application/json' }
- });
- if (res.data?.videoData?.url) {
- videoUrl = res.data.videoData.url;
- console.log(`Vídeo gerado com sucesso após ${attempts} tentativas!`);
- break;
- }
- process.stdout.write(`Tentar ${attempts}: Vídeo ainda não está pronto....\r`);
- await new Promise(r => setTimeout(r, 5000));
- }
- if (!videoUrl) {
- console.log('\nVídeo não disponível ou falha ao gerar dentro do tempo limite..');
- return;
- }
- console.log('Video URL:', videoUrl);
- return videoUrl;
- } catch (error) {
- console.log('Error:', error.response?.data || error.message);
- }
- }
- // Execute se este arquivo for executado diretamente.
- if (require.main === module) {
- asuVeo31();
- }
- module.exports = asuVeo31
- /*
- EXEMPLO DE USO:
- 1. Como script direto:
- node asuVeo31.js "Um belo pôr do sol sobre as montanhas." "https://example.com/sunset.jpg"
- const asuVeo31 = require('./asuVeo31');
- async function generateVideo() {
- const videoUrl = await asuVeo31(
- "Um belo pôr do sol sobre as montanhas.",
- "https://example.com/sunset.jpg"
- );
- console.log('Generated video:', videoUrl);
- }
- CARACTERÍSTICAS:
- - Gera vídeos de 5 segundos em qualidade 540p
- - Ratio 16:9
- - Usa modelo v4.5 do Veo31AI
- - Timeout de 3 minutos para geração
- */
Advertisement
Add Comment
Please, Sign In to add comment