Recherche avancée

Médias (3)

Mot : - Tags -/image

Autres articles (82)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • Sélection de projets utilisant MediaSPIP

    29 avril 2011, par

    Les exemples cités ci-dessous sont des éléments représentatifs d’usages spécifiques de MediaSPIP pour certains projets.
    Vous pensez avoir un site "remarquable" réalisé avec MediaSPIP ? Faites le nous savoir ici.
    Ferme MediaSPIP @ Infini
    L’Association Infini développe des activités d’accueil, de point d’accès internet, de formation, de conduite de projets innovants dans le domaine des Technologies de l’Information et de la Communication, et l’hébergement de sites. Elle joue en la matière un rôle unique (...)

Sur d’autres sites (7728)

  • Discord music bot won't join Voice channel

    16 mars 2024, par Skely

    I followed a tutorial for creating a music bot in discord, but it will not join my vc no matter what. Every command works and it gives the correct responses and songs is in the queue. The bot have every permission know to man, but it still won't join. Any way to fix this issue ?
Thanks in advance !!

    


    This is my code and files

    


    main.py

    


    import discord
from discord.ext import commands
import os
import asyncio

from help_cog import help_cog
from music_cog import music_cog

bot = commands.Bot(
    command_prefix="?", 
    intents=discord.Intents.all(),
    help_command=None
)

async def main():
    async with bot:
        await bot.add_cog(help_cog(bot))
        await bot.add_cog(music_cog(bot))
        await bot.start(os.getenv("TOKEN"))

asyncio.run(main())


    


    music_cog.py

    


    import discord
from discord.ext import commands

from yt_dlp import YoutubeDL

import yt_dlp as youtube_dl

class music_cog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

        self.is_playing = False
        self.is_paused = False

        self.music_queue = []
        self.YDL_OPTIONS = {"format": "bestaudio", "postprocessors": [{"key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "192",}]}
        self.FFMPEG_OPTIONS = {"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5", "options": "-vn"}

        self.vc = None
        print("Success")

    def search_yt(self, item):
        with YoutubeDL(self.YDL_OPTIONS) as ydl:
            try:
                info = ydl.extract_info(f"ytsearch:{item}", download=False)["entries"][0]
            except Exception:
                return False
        return {"source": info["url"], "title": info["title"]}

    def play_next(self):
        if len(self.music_queue) > 0:
            self.is_playing = True

            m_url = self.music_queue[0][0]["source"]

            self.music_queue.pop(0)

            self.vc.play(discord.FFmpegPCMAudio(m_url, **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())
        else:
            self.is_playing = False

    async def play_music(self, ctx):
        if len(self.music_queue) > 0:
            self.is_playing = True
            m_url = self.music_queue[0][0]["source"]

            if self.vc == None or not self.vc.is_connected():
                self.vc = await self.music_queue[0][1].connect()

                if self.vc == None:
                    await ctx.send("Could not connect to the voice channel")
                    return
            else:
                await self.vc.move_to(self.music_queue[0][1])
            
            self.music_queue.pop(0)

            self.vc.play(discord.FFmpegPCMAudio(m_url, **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())

        else:
            self.is_playing = False

    @commands.command(name="play", aliases=["p", "playing"], help="Play the selected song from YouTube")
    async def play(self, ctx, *args):
        query = " ".join(args)

        voice_channel = ctx.author.voice.channel
        if voice_channel is None:
            await ctx.send("Connect to a voice channel!")
        elif self.is_paused:
            self.vc.resume()
        else:
            song = self.search_yt(query)
            if type(song) == type(True):
                await ctx.send("Could not download the song. Incorrect format, try a different keyword")
            else:
                await ctx.send("Song added to queue")
                self.music_queue.append([song, voice_channel])

                if self.is_playing == False:
                    await self.play_music(ctx)
    
    @commands.command(name="pause", help="Pauses the current song being played")
    async def pause(self, ctx, *args):
        if self.is_playing:
            self.is_playing = False
            self.is_paused = True
            self.vc.pause()
        elif self.is_paused:
            self.is_playing = True
            self.is_paused = False
            self.vc.resume()

    @commands.command(name="resume", aliases=["r"], help="Resumes playing the current song")
    async def resume(self, ctx, *args):
        if self.is_paused:
            self.is_playing = True
            self.is_paused = False
            self.vc.resume()
        
    @commands.command(name="skip", aliases=["s"], help="Skips the currently played song")
    async def skip(self, ctx, *args):
        if self.vc != None and self.vc:
            self.vc.stop()
            await self.play_music(ctx)

    @commands.command(name="queue", aliases=["q"], help="Displays all the songs currently in queue")
    async def queue(self, ctx):
        retval = ""

        for i in range(0, len(self.music_queue)):
            if i > 4: break
            retval += self.music_queue[i][0]["title"] + "\n"

        if retval != "":
            await ctx.send(retval)
        else:
            await ctx.send("No music in the current queue")
    
    @commands.command(name="clear", aliases=["c", "bin"], help="Stops the current song and clears the queue")
    async def clear(self, ctx, *args):
        if self.vc != None and self.is_playing:
            self.vc.stop()
        self.music_queue = []
        await ctx.send("Music queue cleared")

    @commands.command(name="leave", aliases=["disconnect", "l", "d"], help="Kick the bot from the voice channel")
    async def leave(self, ctx):
        self.is_playing = False
        self.is_paused = False
        await self.vc.disconnect()


    


    help_cog.py

    


    import discord
from discord.ext import commands

class help_cog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

        self.help_message = """
        Help message
"""

        self.text_channel_text = []
    
    @commands.Cog.listener()
    async def on_ready(self):
        for guild in self.bot.guilds:
            for channel in guild.text_channels:
                self.text_channel_text.append(channel)

        await self.send_to_all(self.help_message)

    async def send_to_all(self, msg):
        for text_channel in self.text_channel_text:
            await text_channel.send(msg)
        
    @commands.command(name="help", help="Displays all the available commands")
    async def help(self, ctx):
        await ctx.send(self.help_message)


    


  • using ffmpeg for live streaming MPEG-TS with windows media services

    14 mars 2012, par Yanniv

    I'm trying to live stream MPEG-TS source to Windows Media service.
    I found how to live stream using RTMP with this code :

    ffmpeg -y -f mpegts -i udp://@:1234 -re -vcodec libx264 -maxrate 700k
    -r 25 -s 640x360 -deinterlace -acodec libvo_aacenc -ab 64k -ac 1 -ar 44100 -f flv "rtmp://rtmp1.youtube.com/videolive?sparams=<stream parameters="parameters" here="here">"
    </stream>
    • How can I convert it to support WM9/VC1 format ?
    • Does ffmpeg support pulling of the stream or only pushing to Windows Media services ?
  • download and fill file on fly

    4 mai 2017, par Gianluca Calabria

    I’m trying to create a service for a client which takes some audio chunks and concatenate them. For this I’m using FFmpeg. The user should also be able to download the result on the fly without waiting for the conversion/concatenation to finish. The idea is to "fill" the file as the process goes on. I cannot work my way around it, is it possible to do ? I’m using a RESTful service which calls a class like this one

    public ReadableRepresentation serveDownloadRequest(Representation entity) throws SystemInitializationException {
       InputStreamChannel inputStreamChannel;
       Form reqParameters=getQuery();
       try {

           String parameters = readStringParameter(reqParameters, AudioCutAndJoinParameters.PARAMETERS, AudioCutAndJoinParameters.PARAMETERS_MANDATORY);
           trace.debug(this.getClass().getSimpleName() + " parameter " + AudioCutAndJoinParameters.PARAMETERS + "=" + parameters);

           String inputUri = readStringParameter(reqParameters, AudioCutAndJoinParameters.INPUT_URI, AudioCutAndJoinParameters.INPUT_URI_MANDATORY);
           trace.debug(this.getClass().getSimpleName() + " parameter " + AudioCutAndJoinParameters.INPUT_URI + "=" + inputUri);

           String markInRelative = readStringParameter(reqParameters, AudioCutAndJoinParameters.MARKIN_ID_RELATIVE, AudioCutAndJoinParameters.MARKIN_ID_RELATIVE_MANDATORY);
           trace.debug(this.getClass().getSimpleName() + " parameter " + AudioCutAndJoinParameters.MARKIN_ID_RELATIVE + "=" + markInRelative);

           String parametersString = readStringParameter(reqParameters, AudioCutAndJoinParameters.PARAMETERS_STRING, AudioCutAndJoinParameters.PARAMETERS_STRING_MANDATORY);
           trace.debug(this.getClass().getSimpleName() + " parameter " + AudioCutAndJoinParameters.PARAMETERS_STRING + "=" + parametersString);

           String cmdFolder = readStringParameter(reqParameters, AudioCutAndJoinParameters.COMMAND_FOLDER, AudioCutAndJoinParameters.COMMAND_FOLDER_MANDATORY);
           trace.debug(this.getClass().getSimpleName() + " parameter " + AudioCutAndJoinParameters.COMMAND_FOLDER + "=" + cmdFolder);

           Map markInIdRelativeMap=JsonEntityManager.getInstance().deserializeMap(markInRelative);
           Map parametersMap=JsonEntityManager.getInstance().deserializeMap(parameters);
           List <string> InputUri= JsonEntityManager.getInstance().deserializeList(inputUri);

           InputStream transcodeOutput = Services.getInstance().runAudioCutAndJoin(parametersMap,markInIdRelativeMap,InputUri,parametersString,cmdFolder);
           inputStreamChannel = new InputStreamChannel(transcodeOutput);

           ReadableRepresentation result = new ReadableRepresentation(inputStreamChannel, MediaType.AUDIO_ALL);

           Disposition disp = new Disposition(Disposition.TYPE_ATTACHMENT);

           disp.setFilename("test-cut.wav");
           result.setDisposition(disp);

           return result;
    </string>

    I’m using the process.getInputStream() as return of my runAudioCutAndJoin but no download happens until the process of conversion/concatenation is done. Can somebody please help me out ?