aiko-chan-ai / discord.js-selfbot-v13

An unofficial discord.js fork for creating selfbots
https://discordjs-self-v13.netlify.app
GNU General Public License v3.0
712 stars 148 forks source link

Invalid stream (No metadata) #1048

Closed 002-sans closed 5 months ago

002-sans commented 5 months ago

Which package has the bugs?

The core library

Issue description

Hi! I tried to make a stream (from a .mp4 link). I had several mistakes that I managed to fix. But the error I can’t fix (even when editing the module) is DiscordStreamClientError: Invalid stream (No metadata)

Code sample

const Discord                 = require('discord.js-selfbot-v13');
const { DiscordStreamClient } = require('discord-stream-client');
const ffmpegPath              = require('@ffmpeg-installer/ffmpeg').path;

const client = new Discord.Client();
new DiscordStreamClient(client);

const token = 'mytoken';

client.login(token);

client.on('ready', async client => {
  console.log('Ready!', client.user.tag);
  const channel = client.channels.cache.get('1206978002316165190');
  const connection = await client.streamClient.joinVoiceChannel(channel, {
    selfDeaf: true,
    selfMute: true,
    selfVideo: false,
  });
  const stream = await connection.createStream();
  const player = client.streamClient.createPlayer(
    'https://dv98.sibnet.ru/44/92/29/4492298.mp4?st=JggFWg3Xngzl_7P5mQVbyA&e=1707866000&stor=58&noip=1&cache=2',
    stream.udp,
    {
        ffmpeg: ffmpegPath
    }
  );
  player.on('error', err => console.error(err));
  player.play({
    kbpsVideo: 7000, // FHD 60fps
    fps: 60,
    hwaccel: true,
    kbpsAudio: 128,
    volume: 1,
  });
});

Package version

latest (djs: 3.1.4, stream-client: 1.4.8)

Node.js version

16.19.0

Operating system

windows

Priority this issue should have

Low (slightly annoying)

Checklist

Additional Information

I got the same error with the video .mp4 u put on github.

aiko-chan-ai commented 5 months ago

try https://github.com/dank074/Discord-video-stream

002-sans commented 5 months ago

I had an error while installing the module but the problem was fixed by forcing the installation `npm i -f'.

The stream system works well this time! I leave the code for those who want:

const { Streamer, streamLivestreamVideo } = require('@dank074/discord-video-stream')        
const Discord = require('discord.js-selfbot-v13');
const { DiscordStreamClient } = require('discord-stream-client');
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
const ffmpeg = require('fluent-ffmpeg')
ffmpeg.setFfmpegPath(ffmpegPath)

const token = '';
const guildId = ""
const channelId = ""
const videolink = ""

const streamer = new Streamer(new Discord.Client());
streamer.client.login(token);

streamer.client.on('ready', async client => {
  console.log('Ready!', client.user.tag);
  await streamer.joinVoice(guildId, channelId);

  const udp = await streamer.createStream();
  udp.mediaConnection.setSpeaking(true);
  udp.mediaConnection.setVideoStatus(true);
  try {
      const res = await streamLivestreamVideo(videolink, udp);
      console.log("Finished playing video " + res);
  } catch (e) {
      console.log(e);
  } finally {
      udp.mediaConnection.setSpeaking(false);
      udp.mediaConnection.setVideoStatus(false);
  }
});