Recherche avancée

Médias (1)

Mot : - Tags -/belgique

Autres articles (65)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

Sur d’autres sites (12237)

  • How do I add a queue to my music bot using Discrod.py FFmpeg and youtube_dl ?

    28 septembre 2022, par Виктор Лисичкин

    I'm writing my bot for discord, I can't figure out how to track the end of a song to lose the next one. I sort of figured out the piece of music, but I don't fully understand what to do next. Here is my code for main.py

    


    from discord.ext import commands, tasks
from config import settings
from music_cog import music_cog
bot = commands.Bot(command_prefix='!',intents = discord.Intents.all())

@bot.event
async def on_ready():
    print(f'We have logged in as {bot.user}')
    await bot.add_cog(music_cog(bot))

bot.run(settings['token'])


    


    and And this is for cog with music

    


    from discord.ext import commands
from youtube_dl import YoutubeDL
YDL_OPTIONS = {'format': 'worstaudio/best', 'noplaylist': 'False', 'simulate': 'True',
               'preferredquality': '192', 'preferredcodec': 'mp3', 'key': 'FFmpegExtractAudio'}
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
queue = []
class music_cog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    @commands.command(pass_context=True)
    async def play(self,ctx, *, arg):
        global queue
        queue.append(arg)
        def playing():
            for song in queue:
                with YoutubeDL(YDL_OPTIONS) as ydl:
                    if 'https://' in song:
                        info = ydl.extract_info(song, download=False)
                    else:
                        info = ydl.extract_info(f"ytsearch:{song}", download=False)['entries'][0]

                    url = info['formats'][0]['url']
                    queue.pop(0)
                    vc.play(discord.FFmpegPCMAudio(executable="ffmpeg", source=url, **FFMPEG_OPTIONS))
        voice_client = discord.utils.get(self.bot.voice_clients, guild=ctx.guild)
        if not ctx.message.author.voice:
            await ctx.send("You are not connected to voice chanel")
        elif voice_client:
            queue.append(arg)
        else:
            vc = await ctx.message.author.voice.channel.connect()
            playing()
    @commands.command(pass_context = True)
    async def disconect(self, ctx):
        server = ctx.message.guild.voice_client
        if ctx.message.guild.voice_client:
            await server.disconnect()
        else:
            await ctx.send("I am not connected")

    @commands.command(pass_context=True)
    async def stop(self, ctx):
        server = ctx.message.guild
        voice_channel = server.voice_client
        voice_channel.pause()

    @commands.command(pass_context=True)
    async def resumue(self, ctx):
        server = ctx.message.guild
        voice_channel = server.voice_client
        voice_channel.resume()


    


  • TypeError : 'FFmpegOpusAudio' object is not subscriptable

    12 octobre 2022, par Virat Chauhan

    I am getting this error whenever I try to get the bot to play a song in vc :

    


    await ctx.send('Now playing ' + '**' + str(queues[ctx.message.guild.id]['title'][0]) + '**')
TypeError: 'FFmpegOpusAudio' object is not subscriptable


    


    Here is the relevant code :

    


      async def playSong(self, ctx, url):
    queues[ctx.message.guild.id]['title'] = []
    with youtube_dl.YoutubeDL(self.YDL_OPTIONS) as ydl:
      info = ydl.extract_info(url, download=False)
      if 'entries' in info:        # if no url is input
        url2 = info['entries'][0]['formats'][0]['url']
        queues[ctx.message.guild.id]['title'].append(info['entries'][0]['title'])
      elif 'formats' in info:      # if url is passed
        url2 = info['formats'][0]['url']
        queues[ctx.message.guild.id]['title'].append(info['title'])
      #print(queues[ctx.message.guild.id]['title'][0])
      stream = await discord.FFmpegOpusAudio.from_probe(url2, **self.FFMPEG_OPTIONS)
    return stream
  
  @commands.command(name='play', help="Plays any song", aliases=['p'])
  async def play(self, ctx, *, url):
    vc = ctx.guild.voice_client
    if not vc.is_playing():
      guild = ctx.message.guild
      
      queues[guild.id] = {}
      stream = await self.playSong(ctx, url)
      queues[guild.id] = stream
      vc.play(stream, after=lambda e: self.queueCheck(guild.id, vc))
      await ctx.send('Now playing ' + '**' + str(queues[ctx.message.guild.id]['title'][0]) + '**')


    


    I am aware that this can be solved with having two dictionaries but I wish to contain all data inside a single structure.

    


  • FFMPEG : Reducing bandwidth usage while trimming youtube audio

    24 octobre 2022, par nash

    I have created a python script which creates audio trims of youtube videos using ffmpeg.

    


    The script works fine for small videos of about <20m, however my intention is to use this for large videos most of which are several hours long.&#xA;It appears ffmpeg may be streaming the entire audio while seeking the trim points, not only is this slow but it adds a lot of unnecessary network overhead, especially since the trims I'm making are barely a minute long.

    &#xA;

    Here is the script :

    &#xA;

    from yt_dlp import YoutubeDL as ydl&#xA;import ffmpeg, sys, getopt&#xA;&#xA;&#xA;default_url = "https://youtu.be/FtutLA63Cp8"&#xA;default_start = "6"&#xA;default_end = "36"&#xA;&#xA;&#xA;def get_secs(time_str) -> int:&#xA;&#xA;    h = "0"&#xA;    m = "0"&#xA;    s = "0"&#xA;&#xA;    time_hms = time_str.split(":")&#xA;&#xA;    if len(time_hms) == 1:&#xA;        s = time_hms[0]&#xA;    elif len(time_hms) == 2:&#xA;        m, s = time_hms&#xA;    elif len(time_hms) == 3:&#xA;        h, m, s = time_hms&#xA;&#xA;    secs = (int(h) * 3600) &#x2B; (int(m) * 60) &#x2B; int(s)&#xA;    return secs&#xA;&#xA;&#xA;# Extract Url&#xA;def get_url(url):&#xA;&#xA;    ydl_opts = {}&#xA;    info = ydl(ydl_opts).extract_info(url, download=False)  # dict of lists&#xA;    # info = ydl.sanitize_info(info)&#xA;&#xA;    title = info["title"].strip() &#x2B; ".mp4"&#xA;&#xA;    formats = info["formats"]  # list of dicts&#xA;    audio_direct_url = ""&#xA;    for format in formats:&#xA;        if format["audio_ext"] != "none":&#xA;            audio_direct_url = format["url"]&#xA;            break&#xA;&#xA;    # return r["formats"][-1]["url"]&#xA;    return audio_direct_url, title&#xA;&#xA;&#xA;def snip_url(url, title, start, end):&#xA;    input = ffmpeg.input(url)&#xA;    pts = "PTS-STARTPTS"&#xA;    audio = input.filter_("atrim", start=start, end=end).filter_("asetpts", pts)&#xA;    out = ffmpeg.output(audio, ("out/" &#x2B; title))&#xA;&#xA;    return ffmpeg.run(out)&#xA;&#xA;&#xA;def mince():&#xA;    pass&#xA;&#xA;&#xA;def main(argv):&#xA;    usage_str = "main.py -u <url> -o <outputfile> -s <starttime> -t <stoptime>"&#xA;    target_url = ""&#xA;    out_filename = ""&#xA;    start_time = default_start&#xA;    stop_time = default_end&#xA;&#xA;    try:&#xA;        opts, args = getopt.getopt(&#xA;            argv, "hu:o:s:t:", ["url=", "ofile=", "start=", "terminate="]&#xA;        )&#xA;&#xA;    except getopt.GetoptError:&#xA;        print(usage_str)&#xA;        sys.exit(2)&#xA;&#xA;    for opt, arg in opts:&#xA;        if opt == "-h":&#xA;            print(usage_str)&#xA;            sys.exit()&#xA;        elif opt in ("-u", "--url"):&#xA;            target_url = arg&#xA;        elif opt in ("-o", "--ofile"):&#xA;            out_filename = arg&#xA;        elif opt in ("-s", "--start"):&#xA;            start_time = arg&#xA;        elif opt in ("-t", "--terminate"):&#xA;            stop_time = arg&#xA;&#xA;        if target_url == "":&#xA;            print(usage_str)&#xA;            sys.exit(2)&#xA;&#xA;        # URLs may have seperators, remove them&#xA;        target_url = target_url.rsplit("?")[0]&#xA;&#xA;    stream_url, title = get_url(target_url)&#xA;    if out_filename != "":&#xA;        title = out_filename&#xA;    start_time = get_secs(start_time)&#xA;    stop_time = get_secs(stop_time)&#xA;    snip_url(stream_url, title, start_time, stop_time)&#xA;&#xA;&#xA;if __name__ == "__main__":&#xA;&#xA;    main(sys.argv[1:])&#xA;</stoptime></starttime></outputfile></url>

    &#xA;

    There is a similar question on this site, however this involves grabbing still frames and not audio sections.

    &#xA;

    I have also looked through both theffmpeg-python and regular ffmpeg documentation and not found anything relevant.

    &#xA;

    Is there a way to get ffmpeg to 'skip' to the desired trim position without streaming the entire audio ? Preferrably using the ffmpeg-python library.

    &#xA;

    If not, are there ways I can reduce the bandwidth overhead and/or speed up this process.

    &#xA;

    I am also open to using other software (preferrably python libraries) similar to ffmpeg that can achieve the same task.

    &#xA;