Recherche avancée

Médias (0)

Mot : - Tags -/images

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (88)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (7217)

  • My discord music bot works locally, but not on a server [closed]

    8 décembre 2022, par Asmondya

    I have an issue with my discord music bot that I made with discord.js v14.

    


    When I run it locally, it works fine and plays music as it should. But when I put in on a server (here I use Vultr), it doesn't work.

    


    I am not sure but it might come from FFmpeg. I am kinda desperate and cant really figure where the issue is from. I think it is FFmpeg because it is what converts the music.

    


    What happens :

    


    Me: !play a music
Bot: Now playing a music
*and right after, without playing the music*
Bot: Music finished


    


    What should normally happen is that same thing but the "music finished" should be sent when the queue is finished.

    


    The thing is that the bot works perfectly locally, but does this when it is hosted on a server. Also I don't have any error messages or else. It just doesn't play the music like if the music was 0 seconds length.

    


    I tried making sure everything is installed on the server, same as making sure ffmpeg was installed globally and I have the good version of it. Here is the answer I have to the "ffmpeg -version" command :enter image description here.

    


    Does anyone know what could be the issue or what could cause it ? I can show some code if needed, even tho it works perfectly fine locally.

    


    Here's my code :

    


    const { DisTube } = require('distube')
const Discord = require('discord.js')
const { EmbedBuilder } = require('discord.js')
const client = new Discord.Client({
  intents: [
    Discord.GatewayIntentBits.Guilds,
    Discord.GatewayIntentBits.GuildMessages,
    Discord.GatewayIntentBits.GuildVoiceStates,
    Discord.GatewayIntentBits.MessageContent,
  ]
})
const { ActivityType } = require('discord.js')
const fs = require('fs')
const dotenv = require("dotenv")
dotenv.config()
const { SpotifyPlugin } = require('@distube/spotify')
const { SoundCloudPlugin } = require('@distube/soundcloud')
const { YtDlpPlugin } = require('@distube/yt-dlp')

client.distube = new DisTube(client, {
  leaveOnStop: false,
  emitNewSongOnly: true,
  emitAddSongWhenCreatingQueue: false,
  emitAddListWhenCreatingQueue: false,
  plugins: [
    new SpotifyPlugin({
      emitEventsAfterFetching: true
    }),
    new SoundCloudPlugin(),
    new YtDlpPlugin()
  ]
})
client.commands = new Discord.Collection()
client.aliases = new Discord.Collection()

fs.readdir('./commands/', (err, files) => {
  if (err) return console.log('Could not find any commands!')
  const jsFiles = files.filter(f => f.split('.').pop() === 'js')
  if (jsFiles.length <= 0) return console.log('Could not find any commands!')
  jsFiles.forEach(file => {
    const cmd = require(`./commands/${file}`)
    console.log(`Loaded ${file}`)
    client.commands.set(cmd.name, cmd)
    if (cmd.aliases) cmd.aliases.forEach(alias => client.aliases.set(alias, cmd.name))
  })
})

client.on('ready', () => {
  console.log(`${client.user.tag} is ready to play music.`)
})

client.on('messageCreate', async message => {
  if (message.author.bot || !message.guild) return
  const prefix = "!"
  if (!message.content.startsWith(prefix)) return
  const args = message.content.slice(prefix.length).trim().split(/ +/g)
  const command = args.shift().toLowerCase()
  const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command))
  if (!cmd) return
  if (cmd.inVoiceChannel && !message.member.voice.channel) {
    return message.channel.send(`You must be in a voice channel!`)
  }
  try {
    cmd.run(client, message, args)
  } catch (e) {
    console.error(e)
    message.channel.send(`Error: \`${e}\``)
  }
})

// Add filters to the queue status :
// | Filter: \`${queue.filters.names.join(', ') || 'Off'}\` 

const status = queue =>
  `Volume: \`${queue.volume}%\` | Loop: \`${
    queue.repeatMode ? (queue.repeatMode === 2 ? 'All Queue' : 'This Song') : 'Off'
  }\` | Autoplay: \`${queue.autoplay ? 'On' : 'Off'}\``
client.distube
  .on('playSong', (queue, song) =>
    queue.textChannel.send({
      embeds: [
        new Discord.EmbedBuilder()
          .setTitle('Now playing')
          .setDescription(`\`${song.name}\` - \`${song.formattedDuration}\`\n${status(queue)}\n\nRequested by: \`${song.user.tag}\``)
          .setThumbnail(`${song.thumbnail}`)
      ]
    })
  )
  .on('addSong', (queue, song) =>
    queue.textChannel.send({
      embeds: [
        new Discord.EmbedBuilder()
          .setTitle('Song added to the queue')
          .setDescription(`${song.name} - \`${song.formattedDuration}\`\n\nRequested by: \`${song.user.tag}\``)
          .setThumbnail(`${song.thumbnail}`)
      ]
    })
  )
  .on('addList', (queue, playlist) =>
    queue.textChannel.send({
      embeds: [
        new Discord.EmbedBuilder()
          .setTitle(`Playlist added to the queue`)
          .setDescription(`\`${playlist.name}\` (${
            playlist.songs.length
          } songs)\n${status(queue)}\n\nRequested by: \`${song.user.tag}\``)
          .setThumbnail(`${song.thumbnail}`)
      ]
    })
  )
  .on('error', (channel, e) => {
    if (channel) channel.send(`An error encountered: ${e.toString().slice(0, 1974)}`)
    else console.error(e)
  })
  .on('empty', channel => channel.send('There is no one here. Im alone, again...'))
  .on('searchNoResult', (message, query) =>
    message.channel.send(`No result found for \`${query}\`!`)
  )
  .on('finish', queue => queue.textChannel.send("https://tenor.com/view/end-thats-all-folks-gif-10601784"))

client.on("ready", () => {
  client.user.setPresence({
      activities: [{
        name: 'AURORA',
        type: ActivityType.Listening
      }],
      status: "idle"
  })
})

client.login(process.env.TOKEN)


    


    It does come from my ffpmeg, I need to install one of these packages instead of the npm installation : https://github.com/BtbN/FFmpeg-Builds/releases

    


    How do I install it on a server (Vultr) ?

    


  • Background Video Processing with Rails

    23 octobre 2013, par Matthew Snyder

    I am trying to get uploaded videos to be converted in the background, running windows. Some of what I am using :

    gem 'paperclip'
    gem 'delayed_job_active_record'
    gem 'ffmpeg'

    I have edited the registry to allow the ffmpeg command to be ran from anywhere, I get a popup that I assume is ffmpeg because it goes away too quickly, guess the command is wrong so if anyone knows what's wrong with it please let me know. But the real problem is that it just hangs there, it says :

    [2012-12-09 22:47:03] ERROR invalid body size.
    [2012-12-09 22:47:03] ERROR Errno::ECONNABORTED: An established connection was a
    borted by the software in your host machine.
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:396:i
    n `write'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:396:i
    n `<<'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:396:i
    n `_write_data'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:368:i
    n `send_body_string'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:249:i
    n `send_body'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:152:i
    n `send_response'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:110:in
    `run'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `blo
    ck in start_thread'

    Does anyone know how to properly get this working ? I've went through a few tutorials that have bits and pieces of what I need but I can't get them working together. Here's what I have so far, lemme know if you need more :

    Model :

    class Video < ActiveRecord::Base

     belongs_to :user
     has_many :comments, dependent: :destroy
     attr_accessible :video, :user_id, :video_file_name, :title, :public, :description, :views

     has_attached_file :video, url: "/users/:user_id/videos/:id/:basename_:style.:extension"

     #process_in_background :video #causes death

     validates :video, presence: true
     validates :description, presence: true, length: { minimum: 5, maximum: 100}
     validates :title, presence: true, length: { minimum: 1, maximum: 15 }

     validates_attachment_size :video, less_than: 1.gigabytes
     validates_attachment :video, presence: true

     default_scope order: 'created_at DESC'

     Paperclip.interpolates :user_id do |attachment, style|attachment.instance.user_id
     end

     #before_post_process do |video|
      # false if video.status == "converting"
     #end

     def perform
       command = <<-end_command
         start ffmpeg -i #{ '/public/users/:user_id/videos/:id/:basename_:style.:extension' }  -ar 22050 -ab 32 -s 1280x720 -vcodec webm -r 25 -qscale 8 -f webm -y #{ '/public/users/:user_id/videos/:id/:basename_.webm' }

       end_command
       success = system(command)
       logger.debug 'Converting File: ' + success.to_s
       if success && $?.exitstatus.to_i == 0
         #self.converted!
         self.status = "converted"
       else
         #self.failure!
         self.status = "failed"
       end
     end

     handle_asynchronously :perform

     def self.search(search)
       if search
         find(:all, conditions: ["public = 't' AND title LIKE ?", "%#{search}%"], order: "created_at DESC")
       else
         find(:all, conditions: ["public = 't'"], order: "created_at DESC")
       end
     end

     def self.admin_search(search)
       if search
         find(:all, conditions: ['title LIKE ?', "%#{search}%"], order: "created_at DESC")
       else
         find(:all, order: "created_at DESC")
       end
     end

     private

       # This updates the stored filename with the new flash video file
       def set_new_filename
         #update_attribute(:filename, "#{filename}.#{id}.webm")
         update_attribute(:content_type, "video/x-webm")
       end

    end

    Controller :

    class VideosController < ApplicationController
       before_filter :signed_in_user, only: [:upload, :update, :destroy]
       before_filter :admin_user, only: :admin_index

       def upload
           @video = Video.new
           # generate a unique id for the upload
           @uuid = (0..29).to_a.map {|x| rand(10)}
       end

       def create
           @video = Video.new(params[:video])
           @video.user_id = current_user.id

           if @video.save
               @video.delay.perform
               flash[:success] = "Uploaded Succefully!"
               redirect_to @video.user
               Delayed::Worker.new.start
           else
               render 'upload'
           end
       end

       def show
           @video = Video.find(params[:id])
           @comments = @video.comments.paginate(page: params[:page], per_page: 6)
           if !@video.public
               if !signed_in? || current_user.id != @video.user_id  && !current_user.admin && !current_user.approved?(@video.user)
               flash[:notice] = "Video is private"
               redirect_to root_path
           end
       end
       end

       def update
           @video = Video.find(params[:id])
           if @video.update_attributes(params[:video])
         flash[:success] = "Video preferences saved"
       else
           flash[:fail] = "Failed to update video preferences"
       end
       redirect_to :back
     end

       def destroy
           @video = Video.find(params[:id])
           @video.destroy
           flash[:deleted] = "Deleted Succefully!"
           redirect_to :back
       end

       def index
           @videos = Video.paginate(page: params[:page], per_page: 6).search(params[:search])
       end

       def admin_index
           @videos = Video.paginate(page: params[:page], per_page: 6).admin_search(params[:search])
       end

       def ajax_video_comments
           @video = Video.find(params[:id])
           @comments = @video.comments.paginate(page: params[:page], per_page: 6)

           respond_to do |format|
           format.js   { render partial: 'shared/comments', content_type: 'text/html' }
       end
       end

       def ajax_video_watched
           @video = Video.find(params[:id])
           @video.views += 1
           @video.save
       end

       private

       def signed_in_user
           redirect_to root_path, notice: "Please Login." unless signed_in?
       end

       def admin_user
           redirect_to(root_path) unless current_user.admin?
       end

    end
  • Skipping extractors execution since zero extractors were registered (Use `node —trace-warnings ...` to show where the warning was created)

    28 septembre 2023, par Parkster00

    I'm following a Discord Music Bot tutorial that uses ffmpeg, here is index.js

    


    require("dotenv").config();

const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v9");
const { Client, Collection, Intents } = require('discord.js');
const { Player } = require("discord-player");

const fs = require("node:fs");
const path = require("node:path");

const client = new Client({
    intents: ["Guilds", "GuildMessages", "GuildVoiceStates"]
});

// Set up our commands into an array
const commands = [];
client.commands = new Collection();

const commandsPath = path.join(__dirname, "commands");
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith(".js"));

for (const file of commandFiles) {
    console.log(`${file}`)
    console.log(`${commandsPath}`)
    const filePath = path.join(commandsPath, file);
    console.log(`${filePath}`)
    const command = require(filePath);

    client.commands.set(command.data.name, command);
    commands.push(command.data.toJSON());
}

// Create the player, highest quality audio
client.player = new Player(client, {
    ytdlOptions: {
        quality: "highestaudio",
        highWaterMark: 1 << 25
    }
});

// Commands are registered
client.on("ready", () => {
    const guild_ids = client.guilds.cache.map(guild => guild.id);

    const rest = new REST({ version: "9" }).setToken(process.env.TOKEN);
    for (const guildId of guild_ids) {
        rest.put(Routes.applicationGuildCommands(process.env.CLIENT_ID, guildId), {
            body: commands
        })
            .then(() => console.log(`Added commands to ${guildId}`))
            .catch(console.error);
    }

});

client.on("interactionCreate", async interaction => {
    if (!interaction.isCommand()) return;

    const command = client.commands.get(interaction.commandName);
    if (!command) return;

    try {
        await command.execute({ client, interaction });
    }
    catch (err) {
        console.error(err);
        await interaction.reply("An error occured while executing that command.");
    }
});

console.log(process.env.TOKEN);
client.login(process.env.TOKEN);


    


    And here is play.js where I think the error originates :

    


    const { SlashCommandBuilder } = require("@discordjs/builders");
const { EmbedBuilder } = require("discord.js");
const { QueryType } = require('discord-player');


module.exports = {
    data: new SlashCommandBuilder()
        .setName("play")
        .setDescription("Plays a song.")
        .addSubcommand(subcommand => {
            return subcommand
                .setName("search")
                .setDescription("Searches for a song.")
                .addStringOption(option => {
                    return option
                        .setName("searchterms")
                        .setDescription("search keywords")
                        .setRequired(true);
                })
        })
        .addSubcommand(subcommand => {
            return subcommand
                .setName("playlist")
                .setDescription("Plays playlist from YT")
                .addStringOption(option => {
                    return option
                        .setName("url")
                        .setDescription("playlist url")
                        .setRequired(true);

                })
        })
        .addSubcommand(subcommand => {
            return subcommand
                .setName("song")
                .setDescription("Plays song from YT")
                .addStringOption(option => {
                    return option
                        .setName("url")
                        .setDescription("url of song")
                        .setRequired(true);

                })
        }),
    execute: async ({ client, interaction }) => {

        if (!interaction.member.voice.channel) {
            await interaction.reply("You must be in a voice channel to use this command.");
            return;
        }

        const queue = await client.player.nodes.create(interaction.guild);

        if (!queue.connection) await queue.connect(interaction.member.voice.channel)

        let embed = new EmbedBuilder();
        if (interaction.options.getSubcommand() === "song") {
            let url = interaction.options.getString('url');

            const result = await client.player.search(url, {
                requestedBy: interaction.user,
                searchEngine: QueryType.YOUTUBE_VIDEO
            });

            console.log(result.tracks);

            if (result.tracks.length === 0) {
                await interaction.reply("no results found");
                return
            }

            const song = result.tracks[0];
            await queue.addTrack(song);

            embed
                .setDescription(`Added **[${song.title}](${song.url})** to the queue.`)
                .setThumbnail(song.thumbnail)
                .setFooter({ text: `Duration: ${song.duration}` });
        }

        else if (interaction.options.getSubcommand() === "playlist") {
            let url = interaction.options.getString('url');

            const result = await client.player.search(url, {
                requestedBy: interaction.SlashCommandBuilder,
                searchEngine: QueryType.YOUTUBE_PLAYLIST,
            });

            if (result.tracks.length === 0) {
                await interaction.reply("no playlist found");
                return
            }

            const playlist = result.playlist;
            await queue.addTracks(playlist);

            embed
                .setDescription(`Added **[${playlist.title}](${playlist.url})** to the queue.`)
                .setThumbnail(playlist.thumbnail)
                .setFooter({ text: `Duration: ${playlist.duration}` });
        }

        else if (interaction.options.getSubcommand() === "search") {
            let url = interaction.options.getString('searchterms');

            const result = await client.player.search(url, {
                requestedBy: interaction.SlashCommandBuilder,
                searchEngine: QueryType.AUTO,
            });

            if (result.tracks.length === 0) {
                await interaction.reply("no results found");
                return
            }

            const song = result.tracks[0]
            await queue.addTrack(song);

            embed
                .setDescription(`Added **[${song.title}](${song.url})** to the queue.`)
                .setThumbnail(song.thumbnail)
                .setFooter({ text: `Duration: ${song.duration}` });
        }

        if (!queue.playing) await queue.play();

        await interaction.reply({
            embeds: [embed]
        })
    }
}


    


    Is ffmpeg called differently now ? Am I doing something wrong ?

    


    I've tried different installs of Ffmpeg and none seem to work, so I'd imagine it originates somewhere in my code.