Recherche avancée

Médias (0)

Mot : - Tags -/xmlrpc

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

Autres articles (106)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

  • Taille des images et des logos définissables

    9 février 2011, par

    Dans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
    Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...)

Sur d’autres sites (9298)

  • Keep getting "discord.ext.commands.errors.CommandInvokeError : Command raised an exception : KeyError : 'source'" error

    22 février 2023, par kris

    Everytime I try to run play command in my bot, I get this error in the terminal, kind of new to coding so not exactly sure whats going on. It was working just fine, then it started not to work.

    


    import discord

from discord.ext import commands

from youtube_dl import YoutubeDL

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', 'noplaylist': 'True'}
        self.FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}

        self.vc = None

    def search_yt(self, item):
        with YoutubeDL(self.YDL_OPTIONS) as ydl:
            try:
                info = ydl.extract_info("ytsearch:%s" % item, download=False)['entries'][0]
            except Exception:
                return False
        return {'sourcffmpege': info['formats'][0]['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(executable="ffmpeg", source=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(executable="ffmpeg", source=m_url, **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())

    @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 the 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.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 the queue")
    async def queue(self, ctx):
        retval = ""

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

        if retval != "":
            await ctx.send(retval)
        else:
            await ctx.send("No music in 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=["l"], help="Kicks the bot from the voice channel")
    async def leave(self, ctx):
        self.is_playing = False
        self.is_paused = False
        await self.vc.disconnect()

async def setup(bot):
    await bot.add_cog(music_cog(bot))


    


    this is my music_cogs.py, this is where error is coming from

    


    was working just fine then it started to give me this error after a while.

    


    raceback (most recent call last):
  File "C:\Users\poopt\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\poopt\Code\cool_bot\cogs\music_cog.py", line 77, in play
    await self.play_music(ctx)
  File "c:\Users\poopt\Code\cool_bot\cogs\music_cog.py", line 44, in play_music
    m_url=self.music_queue[0][0]['source']
KeyError: 'source'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
 line 1349, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\poopt\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\poopt\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'source'


    


  • What is the best way to get duration of a video using ffprobe (ffmpeg) ?

    15 juin 2023, par promaxdev

    Most of the solutions to get duration revolves around parsing the output to get the duration. Even FFProbe official documentation here says that there is no duration stored for MKV, webm, etc.

    


    Take the below examples.

    


    ffprobe -v error -i <inputmkv> -show_entries stream=...,duration,.. -of default=noprint_wrappers=1&#xA;</inputmkv>

    &#xA;

    This gives me the below output. This is not having duration.

    &#xA;

    Image with Duration NA

    &#xA;

    But when I run the same command differently like below, I am getting this output but having duration. Just removed '-v error' part.

    &#xA;

    ffprobe -i <inputmkv> -show_entries stream=...duration,... -of default=noprint_wrappers=1 &#xA;</inputmkv>

    &#xA;

    enter image description here

    &#xA;

    If you notice the same command shows the duration in one place and not in another place.

    &#xA;

    So my question is, What is the best way to get duration in ffmpeg, especially for the video streams ?

    &#xA;

    Edit : I have already explored decoding using null mux option. But that is a costly operation and also need to parse the output.

    &#xA;

  • Variable in nested for loop not working correctly [duplicate]

    30 janvier 2023, par SeanMrnd

    The code below works pretty much as intended, but it works for only one video file at a time. All attempts at nesting it inside a for %%a in (\*.mp4) loop breaks it. The %duration% no longer outputs a value (or I'm doing something wrong), and as such, all of the arithmetic functions break.

    &#xA;

    This code works (open to changes suggestions) :

    &#xA;

    setlocal EnableExtensions EnableDelayedExpansion&#xA;IF EXIST output.gif DEL /F output.gif&#xA;IF EXIST test_preview.mp4 DEL /F test_preview.mp4&#xA;for /F "delims=" %%I in (&#x27;ffprobe.exe -v error -show_entries format^=duration -of default^=noprint_wrappers^=1:nokey^=1 test.mp4 2^>^&amp;1&#x27;) do (&#xA;    set "duration=%%I"&#xA;)&#xA;echo %duration%&#xA;set /a r=%duration%&#xA;set /a d1=r/10&#xA;set /a d2=r*2/10&#xA;set /a d3=r*3/10&#xA;set /a d4=r*4/10&#xA;set /a d5=r*5/10&#xA;set /a d6=r*6/10&#xA;set /a d7=r*7/10&#xA;set /a d8=r*8/10&#xA;set /a d9=r*9/10&#xA;&#xA;ffmpeg -y -ss %d1% -i test.mp4 -c copy -t 1.5 "output/test_output1.mp4"&#xA;ffmpeg -y -ss %d2% -i test.mp4 -c copy -t 1.5 "output/test_output2.mp4"&#xA;ffmpeg -y -ss %d3% -i test.mp4 -c copy -t 1.5 "output/test_output3.mp4"&#xA;ffmpeg -y -ss %d4% -i test.mp4 -c copy -t 1.5 "output/test_output4.mp4"&#xA;ffmpeg -y -ss %d5% -i test.mp4 -c copy -t 1.5 "output/test_output5.mp4"&#xA;ffmpeg -y -ss %d6% -i test.mp4 -c copy -t 1.5 "output/test_output6.mp4"&#xA;ffmpeg -y -ss %d7% -i test.mp4 -c copy -t 1.5 "output/test_output7.mp4"&#xA;ffmpeg -y -ss %d8% -i test.mp4 -c copy -t 1.5 "output/test_output8.mp4"&#xA;ffmpeg -y -ss %d9% -i test.mp4 -c copy -t 1.5 "output/test_output9.mp4"&#xA;(&#xA;    echo file &#x27;output/test_output1.mp4&#x27;&#xA;    echo file &#x27;output/test_output2.mp4&#x27;&#xA;    echo file &#x27;output/test_output3.mp4&#x27;&#xA;    echo file &#x27;output/test_output4.mp4&#x27;&#xA;    echo file &#x27;output/test_output5.mp4&#x27;&#xA;    echo file &#x27;output/test_output6.mp4&#x27; &#xA;    echo file &#x27;output/test_output7.mp4&#x27;&#xA;    echo file &#x27;output/test_output8.mp4&#x27;&#xA;    echo file &#x27;output/test_output9.mp4&#x27;&#xA;)>list.txt&#xA;&#xA;ffmpeg -safe 0 -f concat -i list.txt -c copy test_preview.mp4&#xA;ffmpeg -i test_preview.mp4 -vf scale=320:-1 output.gif&#xA;IF EXIST test_preview.mp4 DEL /F test_preview.mp4&#xA;&#xA;pause&#xA;

    &#xA;

    This code does not, in an attempt to automate this for my whole library I replaced most file name references with %%~na

    &#xA;

    setlocal EnableExtensions EnableDelayedExpansion&#xA;for %%a in (*.mp4) DO (&#xA;    IF EXIST %%~na.gif DEL /F %%~na.gif&#xA;    set /a y=10&#xA;    for /F "delims=" %%I in (&#x27;ffprobe.exe -v error -show_entries format^=duration -of default^=noprint_wrappers^=1:nokey^=1 %%~na.mp4 2^>^&amp;1&#x27;) do set "duration=%%I"&#xA;    echo %duration% %%I&#xA;    set /a r=%duration%&#xA;    set /a d1=r/10&#xA;    set /a d2=r*2/10&#xA;    set /a d3=r*3/10&#xA;    set /a d4=r*4/10&#xA;    set /a d5=r*5/10&#xA;    set /a d6=r*6/10&#xA;    set /a d7=r*7/10&#xA;    set /a d8=r*8/10d&#xA;    set /a d9=r*9/10&#xA;&#xA;    ffmpeg -y -ss %d1% -i "%%~na.mp4" -c copy -t 1.5 "output/%%~na_output1.mp4"&#xA;    ffmpeg -y -ss %d2% -i %%~na.mp4 -c copy -t 1.5 "output/%%~na_output2.mp4"&#xA;    ffmpeg -y -ss %d3% -i %%~na.mp4 -c copy -t 1.5 "output/%%~na_output3.mp4"&#xA;    ffmpeg -y -ss %d4% -i %%~na.mp4 -c copy -t 1.5 "output/%%~na_output4.mp4"&#xA;    ffmpeg -y -ss %d5% -i %%~na.mp4 -c copy -t 1.5 "output/%%~na_output5.mp4"&#xA;    ffmpeg -y -ss %d6% -i %%~na.mp4 -c copy -t 1.5 "output/%%~na_output6.mp4"&#xA;    ffmpeg -y -ss %d7% -i %%~na.mp4 -c copy -t 1.5 "output/%%~na_output7.mp4"&#xA;    ffmpeg -y -ss %d8% -i %%~na.mp4 -c copy -t 1.5 "output/%%~na_output8.mp4"&#xA;    ffmpeg -y -ss %d9% -i %%~na.mp4 -c copy -t 1.5 "output/%%~na_output9.mp4"&#xA;    (&#xA;        echo file &#x27;output/%%~na_output1.mp4&#x27;&#xA;        echo file &#x27;output/%%~na_output2.mp4&#x27;&#xA;        echo file &#x27;output/%%~na_output3.mp4&#x27;&#xA;        echo file &#x27;output/%%~na_output4.mp4&#x27;&#xA;        echo file &#x27;output/%%~na_output5.mp4&#x27;&#xA;        echo file &#x27;output/%%~na_output6.mp4&#x27; &#xA;        echo file &#x27;output/%%~na_output7.mp4&#x27;&#xA;        echo file &#x27;output/%%~na_output8.mp4&#x27;&#xA;        echo file &#x27;output/%%~na_output9.mp4&#x27;&#xA;    )>%%~na_list.txt&#xA;    ffmpeg -safe 0 -f concat -i %%~na_list.txt -c copy %%~na_preview.mp4&#xA;    ffmpeg -i %%~na_preview.mp4 -vf scale=320:-1 output.gif&#xA;    IF EXIST %%~na_preview.mp4 DEL /F %%~na_preview.mp4&#xA;)&#xA;&#xA;pause&#xA;

    &#xA;