Recherche avancée

Médias (91)

Autres articles (101)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • L’agrémenter visuellement

    10 avril 2011

    MediaSPIP est basé sur un système de thèmes et de squelettes. Les squelettes définissent le placement des informations dans la page, définissant un usage spécifique de la plateforme, et les thèmes l’habillage graphique général.
    Chacun peut proposer un nouveau thème graphique ou un squelette et le mettre à disposition de la communauté.

  • Possibilité de déploiement en ferme

    12 avril 2011, par

    MediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
    Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)

Sur d’autres sites (8110)

  • Why is my DSharpPlus Slash Command not playing my desired sound using FFMPEG in C# ?

    19 mai 2023, par IngeniousThoughts

    I'm having a problem with my ffmpeg setup the commands work fine but my play command doesn't play my desired sound.

    


    //The command.
        [SlashCommand("play", "plays a sound in a voice channel.")]
        public async Task HowlCommand(InteractionContext ctx, [Choice("ChoiceName", "C:\\My\\Program\\Directory\\Name\\MySound.mp3")]
                                                             [Option("Sound", "Please select a Sound")] string filepath)
        {
            //Creates a slash command used response.
            //Also removes the error message.
            await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder()
                                                                                                                    .WithContent("Playing sound in voice channel. Please wait just a moment!"));
 
            //Checks if the user is not a bot to send the message.
            if (ctx.Member.IsBot)
            {
                return;
            }
            else
            {
                if(filepath != "C:\\My\\Program\\Directory\\Name\\MySound.mp3")
                {
                    var embedmessage = new DiscordMessageBuilder()
                        .AddEmbed(new DiscordEmbedBuilder()
 
                        .WithAuthor("BotName", null, ctx.Client.CurrentApplication.Icon)
                        .WithTitle("Please select the following sound to play:")
                        .WithImageUrl(ctx.Client.CurrentApplication.Icon)
                        .WithFooter("VoiceChannel Error.", "ImageURL.png")
                        .WithTimestamp(DateTime.Now)
                        .Build()
 
                        );
 
                    //Makes the command wait 5 seconds before sending the rest of the command data.
                    await Task.Delay(TimeSpan.FromSeconds(5));
 
                    //Sends the embed in a message.
                    await ctx.Channel.SendMessageAsync(embedmessage);
                }
                else
                {
                    //Makes the command wait 5 seconds before sending the rest of the command data.
                    await Task.Delay(TimeSpan.FromSeconds(5));
 
 
                    var vnext = ctx.Client.GetVoiceNext();
                    var vnc = vnext.GetConnection(ctx.Guild);
                    
                    //if null throws exception.
                    if (vnc == null)
                        throw new System.InvalidOperationException("Not connected in this guild.");
 
 
                    //Gets the mp3 file to use.
                    var ffmpeg = Process.Start(new ProcessStartInfo
                    {
                        FileName = "ffmpeg",
                        Arguments = $@"-i ""{filepath}"" -ac 2 -f s16le -ar 48000 pipe:1",
                        RedirectStandardOutput = true,
                        UseShellExecute = false
                    });
                    Stream pcm = ffmpeg.StandardOutput.BaseStream;
 
                    VoiceTransmitSink transmit = vnc.GetTransmitSink();
                    await pcm.CopyToAsync(transmit);
                    vnc.GetTransmitSink().VolumeModifier = 5;
 
                    //Makes the command wait 10 seconds before sending the rest of the command data.
                    await Task.Delay(TimeSpan.FromSeconds(10));
 
                    //Disconnects the bot from the voice channel.
                    vnc.Disconnect();
                }
            }
        }


    


    //The command.
        [SlashCommand("join", "Joins a voice channel.")]
        public async Task JoinChannel(InteractionContext ctx, [Choice("MyVoiceChannel", "VoiceChannelName")]
                                                             [Option("VoiceChannel", "Please choose a Voice Channel.")] DiscordChannel channel)
        {
            //Creates a slash command used response.
            //Also removes the error message.
            await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder()
                                                                                                                    .WithContent("Joining voice channel. Please wait just a moment!"));
 
            //Checks if the user is not a bot to send the message.
            if (ctx.Member.IsBot)
            {
                return;
            }
            else
            {
                if (channel.Name != "MyVoiceChannelName")
                {
                    var embedmessage = new DiscordMessageBuilder()
                        .AddEmbed(new DiscordEmbedBuilder()
 
                        .WithAuthor("BotName", null, ctx.Client.CurrentApplication.Icon)
                        .WithTitle("Please Create The Following Voice Channel:")
                        .WithImageUrl(ctx.Client.CurrentApplication.Icon)
                        .AddField("VoiceChannel:", "**BotName**" + Environment.NewLine + "Is Case Sensitive: **Yes**")
                        .WithFooter("VoiceChannel Error.", "ImageURL.png")
                        .WithTimestamp(DateTime.Now)
                        .Build()
 
                        );
 
                    //Makes the command wait 5 seconds before sending the rest of the command data.
                    await Task.Delay(TimeSpan.FromSeconds(5));
 
                    //Sends the embed in a message.
                    await ctx.Channel.SendMessageAsync(embedmessage);
                }
                else
                {
                    //Makes the command wait 5 seconds before sending the rest of the command data.
                    await Task.Delay(TimeSpan.FromSeconds(5));
 
 
                    channel = ctx.Member.VoiceState?.Channel;
                    await channel.ConnectAsync();
 
                }
            }
        }
 
    }
}


    


    public sealed class Program&#xA;    {&#xA;        public static DiscordClient Client { get; private set; }&#xA;        public static InteractivityExtension Interactivity { get; private set; }&#xA;        public static CommandsNextExtension Commands { get; private set; }&#xA;        public static VoiceNextExtension VoiceNext { get; private set; }&#xA; &#xA; &#xA;        static async Task Main(string[] args)&#xA;        {&#xA; &#xA;            //Main Window configs specifying the title name and color.&#xA;            Console.BackgroundColor = ConsoleColor.Black;&#xA;            Console.ForegroundColor = ConsoleColor.Magenta;&#xA;            Console.Title = "BotName";&#xA; &#xA;            //1. Get the details of your config.json file by deserialising it&#xA;            var configJsonFile = new JSONReader();&#xA;            await configJsonFile.ReadJSON();&#xA; &#xA;            //2. Setting up the Bot Configuration&#xA;            var discordConfig = new DiscordConfiguration()&#xA;            {&#xA;                Intents = DiscordIntents.All,&#xA;                Token = configJsonFile.token,&#xA;                TokenType = TokenType.Bot,&#xA;                AutoReconnect = true&#xA;            };&#xA; &#xA;            //3. Apply this config to our DiscordClient&#xA;            Client = new DiscordClient(discordConfig);&#xA; &#xA;            //4. Set the default timeout for Commands that use interactivity&#xA;            Client.UseInteractivity(new InteractivityConfiguration()&#xA;            {&#xA;                Timeout = TimeSpan.FromMinutes(2)&#xA;            });&#xA; &#xA;            //5. Set up the Task Handler Ready event&#xA;            Client.Ready &#x2B;= OnClientReady;&#xA; &#xA;            //6. Set up the Commands Configuration&#xA;            var commandsConfig = new CommandsNextConfiguration()&#xA;            {&#xA;                StringPrefixes = new string[] { configJsonFile.prefix },&#xA;                EnableMentionPrefix = true,&#xA;                EnableDms = true,&#xA;                EnableDefaultHelp = false,&#xA;            };&#xA; &#xA;            Commands = Client.UseCommandsNext(commandsConfig);&#xA; &#xA;            //7. Register your commands&#xA;            var slashCommandsConfig = Client.UseSlashCommands();&#xA;            slashCommandsConfig.RegisterCommands<mysoundscommand>(MyGuildID);&#xA; &#xA;            //8. Allows usage of voice channels.&#xA;            var VoiceNext = Client.UseVoiceNext();&#xA; &#xA;            //9. Connect to get the Bot online&#xA;            await Client.ConnectAsync();&#xA;            await Task.Delay(-1);&#xA;        }&#xA; &#xA;        private static Task OnClientReady(DiscordClient sender, ReadyEventArgs e)&#xA;        {&#xA;            return Task.CompletedTask;&#xA;        }&#xA;    }&#xA;</mysoundscommand>

    &#xA;

    SourceCode Link :

    &#xA;

    text

    &#xA;

    playing the playsound slash command but wasn't expecting it to not play the mp3 file.

    &#xA;

    everything else worked fine except when it transmits the sound it doesn't play it.

    &#xA;

  • ffplay does not play hls continuously and it stop after a few first segments

    31 mai 2023, par LeXela-ED

    I am using the following command to read a RTSP stream from an IP camera and record it as HLS :

    &#xA;

    ffmpeg -i rtsp://<user>:<password>@<ip>:<port> -c:v copy -c:a copy -hls_segment_type mpegts -segment_list_type m3u8 -hls_list_size 5 -hls_wrap 5 -hls_time 5 -hls_flags split_by_time -segment_time_delta 1.00 -start_number 1 -segment_list live -reset_timestamps 1 -movflags faststart live.m3u8</port></ip></password></user>

    &#xA;

    However, while I am using ffplay as ffplay -i live.m3u8, it only plays a few first segments. Even VLC does play a few first segments too ! What am I missing ? shall I change my ffmpeg command or what ?

    &#xA;

    Thank you all in advance.

    &#xA;

  • Discord.py repository example : bot can join voice channel, shows voice activity (green ring), but no sound is produced ?

    19 juin 2023, par Jared Robertson

    I copied an example from the discord.py repository to test out a bot with music capabilities. Though the code enables YouTube playback, I am only concerned with local audio playback. See code here : https://github.com/Rapptz/discord.py/blob/v2.3.0/examples/basic_voice.py. I tested this code as is with only the Discord token portion updated (from constants.py). See code below :

    &#xA;

    # This example requires the &#x27;message_content&#x27; privileged intent to function.&#xA;&#xA;#my constants.py with API keys, tokens, etc. stored&#xA;import constants&#xA;&#xA;import asyncio&#xA;&#xA;import discord&#xA;import youtube_dl&#xA;&#xA;from discord.ext import commands&#xA;&#xA;# Suppress noise about console usage from errors&#xA;youtube_dl.utils.bug_reports_message = lambda: &#x27;&#x27;&#xA;&#xA;&#xA;ytdl_format_options = {&#xA;    &#x27;format&#x27;: &#x27;bestaudio/best&#x27;,&#xA;    &#x27;outtmpl&#x27;: &#x27;%(extractor)s-%(id)s-%(title)s.%(ext)s&#x27;,&#xA;    &#x27;restrictfilenames&#x27;: True,&#xA;    &#x27;noplaylist&#x27;: True,&#xA;    &#x27;nocheckcertificate&#x27;: True,&#xA;    &#x27;ignoreerrors&#x27;: False,&#xA;    &#x27;logtostderr&#x27;: False,&#xA;    &#x27;quiet&#x27;: True,&#xA;    &#x27;no_warnings&#x27;: True,&#xA;    &#x27;default_search&#x27;: &#x27;auto&#x27;,&#xA;    &#x27;source_address&#x27;: &#x27;0.0.0.0&#x27;,  # bind to ipv4 since ipv6 addresses cause issues sometimes&#xA;}&#xA;&#xA;ffmpeg_options = {&#xA;    &#x27;options&#x27;: &#x27;-vn&#x27;,&#xA;}&#xA;&#xA;ytdl = youtube_dl.YoutubeDL(ytdl_format_options)&#xA;&#xA;&#xA;class YTDLSource(discord.PCMVolumeTransformer):&#xA;    def __init__(self, source, *, data, volume=0.5):&#xA;        super().__init__(source, volume)&#xA;&#xA;        self.data = data&#xA;&#xA;        self.title = data.get(&#x27;title&#x27;)&#xA;        self.url = data.get(&#x27;url&#x27;)&#xA;&#xA;    @classmethod&#xA;    async def from_url(cls, url, *, loop=None, stream=False):&#xA;        loop = loop or asyncio.get_event_loop()&#xA;        data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))&#xA;&#xA;        if &#x27;entries&#x27; in data:&#xA;            # take first item from a playlist&#xA;            data = data[&#x27;entries&#x27;][0]&#xA;&#xA;        filename = data[&#x27;url&#x27;] if stream else ytdl.prepare_filename(data)&#xA;        return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)&#xA;&#xA;&#xA;class Music(commands.Cog):&#xA;    def __init__(self, bot):&#xA;        self.bot = bot&#xA;&#xA;    @commands.command()&#xA;    async def join(self, ctx, *, channel: discord.VoiceChannel):&#xA;        """Joins a voice channel"""&#xA;&#xA;        if ctx.voice_client is not None:&#xA;            return await ctx.voice_client.move_to(channel)&#xA;&#xA;        await channel.connect()&#xA;&#xA;    @commands.command()&#xA;    async def play(self, ctx, *, query):&#xA;        """Plays a file from the local filesystem"""&#xA;&#xA;        source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))&#xA;        ctx.voice_client.play(source, after=lambda e: print(f&#x27;Player error: {e}&#x27;) if e else None)&#xA;&#xA;        await ctx.send(f&#x27;Now playing: {query}&#x27;)&#xA;&#xA;    @commands.command()&#xA;    async def yt(self, ctx, *, url):&#xA;        """Plays from a url (almost anything youtube_dl supports)"""&#xA;&#xA;        async with ctx.typing():&#xA;            player = await YTDLSource.from_url(url, loop=self.bot.loop)&#xA;            ctx.voice_client.play(player, after=lambda e: print(f&#x27;Player error: {e}&#x27;) if e else None)&#xA;&#xA;        await ctx.send(f&#x27;Now playing: {player.title}&#x27;)&#xA;&#xA;    @commands.command()&#xA;    async def stream(self, ctx, *, url):&#xA;        """Streams from a url (same as yt, but doesn&#x27;t predownload)"""&#xA;&#xA;        async with ctx.typing():&#xA;            player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)&#xA;            ctx.voice_client.play(player, after=lambda e: print(f&#x27;Player error: {e}&#x27;) if e else None)&#xA;&#xA;        await ctx.send(f&#x27;Now playing: {player.title}&#x27;)&#xA;&#xA;    @commands.command()&#xA;    async def volume(self, ctx, volume: int):&#xA;        """Changes the player&#x27;s volume"""&#xA;&#xA;        if ctx.voice_client is None:&#xA;            return await ctx.send("Not connected to a voice channel.")&#xA;&#xA;        ctx.voice_client.source.volume = volume / 100&#xA;        await ctx.send(f"Changed volume to {volume}%")&#xA;&#xA;    @commands.command()&#xA;    async def stop(self, ctx):&#xA;        """Stops and disconnects the bot from voice"""&#xA;&#xA;        await ctx.voice_client.disconnect()&#xA;&#xA;    @play.before_invoke&#xA;    @yt.before_invoke&#xA;    @stream.before_invoke&#xA;    async def ensure_voice(self, ctx):&#xA;        if ctx.voice_client is None:&#xA;            if ctx.author.voice:&#xA;                await ctx.author.voice.channel.connect()&#xA;            else:&#xA;                await ctx.send("You are not connected to a voice channel.")&#xA;                raise commands.CommandError("Author not connected to a voice channel.")&#xA;        elif ctx.voice_client.is_playing():&#xA;            ctx.voice_client.stop()&#xA;&#xA;&#xA;intents = discord.Intents.default()&#xA;intents.message_content = True&#xA;&#xA;bot = commands.Bot(&#xA;    command_prefix=commands.when_mentioned_or("!"),&#xA;    description=&#x27;Relatively simple music bot example&#x27;,&#xA;    intents=intents,&#xA;)&#xA;&#xA;&#xA;@bot.event&#xA;async def on_ready():&#xA;    print(f&#x27;Logged in as {bot.user} (ID: {bot.user.id})&#x27;)&#xA;    print(&#x27;------&#x27;)&#xA;&#xA;&#xA;async def main():&#xA;    async with bot:&#xA;        await bot.add_cog(Music(bot))&#xA;        #referenced my discord token in constants.py&#xA;        await bot.start(constants.discord_token)&#xA;&#xA;&#xA;asyncio.run(main())&#xA;

    &#xA;

    This code should cause the Discord bot to join the voice channel and play a local audio file when the message " !play query" is entered into the Discord text channel, with query in my case being "test.mp3." When " !play test.mp3" is entered, the bot does join the voice channel and appears to generate voice activity, however no sound is heard. No errors are thrown in the output. The bot simply continues on silently.

    &#xA;

    Here's what I've checked and tried :

    &#xA;

      &#xA;
    1. I am in the Discord voice channel. The code will alert that user is not in the voice channel if a user attempts to summon the bot without being in a voice channel.

      &#xA;

    2. &#xA;

    3. FFmpeg is installed and added to PATH. I even stored a copy of the .exe in the project folder.

      &#xA;

    4. &#xA;

    5. I've tried specifying the full path of both FFmpeg (adding the "executable=" arg to the play function) and the audio file (stored at C :/test.mp3 and a copy in the project folder).

      &#xA;

    6. &#xA;

    7. All libraries up to date.

      &#xA;

    8. &#xA;

    9. Reviewed discord.py docs (https://discordpy.readthedocs.io/en/stable/api.html#voice-related) and played around with opuslib (docs say not necessary on Windows, which I'm on) and FFmpegOpusAudio, but results were the same.

      &#xA;

    10. &#xA;

    11. Referenced numerous StackOverflow threads, including every one suggested when I typed the title of this post. Tried each suggestion individually and in various combinations when possible. See a few below :&#xA;Discord.py music_cog, bot joins channel but plays no sound&#xA;Discord.py Music Bot doesn’t play music&#xA;Discord.py Bot Not Playing music

      &#xA;

    12. &#xA;

    13. Double checked my sound is on and volume turned up. My sound is working I can hear the Discord notification when the bot joins the voice channel.

      &#xA;

    14. &#xA;

    15. Issue is the same if I try to play a YouTube file with !yt command. Bot joins channel fine but no sound is produced.

      &#xA;

    16. &#xA;

    &#xA;

    That's everything I can think of at the moment. There seem to be many posts regarding this exact topic and also variations of it. I've been unable to find a clear and consistent answer, nor one the works for me. I am willing to try anything at this point as it is obviously possible, but for whatever reason success eludes me. Thank you in advance for any assistance you are willing to offer.

    &#xA;